From fbb6fe70ff26c276367e8fe28a08c81bdd41113b Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:18:20 +0200 Subject: [PATCH] rearrange folders --- home/scripts/{system => battery}/default.nix | 32 ++------------------ home/scripts/default.nix | 3 +- home/scripts/notification/default.nix | 27 +++++++++++++++++ 3 files changed, 32 insertions(+), 30 deletions(-) rename home/scripts/{system => battery}/default.nix (57%) create mode 100644 home/scripts/notification/default.nix diff --git a/home/scripts/system/default.nix b/home/scripts/battery/default.nix similarity index 57% rename from home/scripts/system/default.nix rename to home/scripts/battery/default.nix index dd560e7..4f2c1ab 100644 --- a/home/scripts/system/default.nix +++ b/home/scripts/battery/default.nix @@ -1,31 +1,5 @@ { pkgs, ... }: - let - - notif = pkgs.writeShellScriptBin "notif" '' - # Shell script to send custom notifications - NOTIF_FOLDER="/tmp/notif" - sender_id=$1 # To overwrite existing notifications - message=$2 - extraargs="" - description="" - if [[ $3 == "extraargs="* ]]; then - extraargs=$(echo "$3" | sed 's/extraargs=//g') - else - description="$3" - extraargs="$4" - fi - - [[ -d "$NOTIF_FOLDER" ]] || mkdir $NOTIF_FOLDER - [[ -f "$NOTIF_FOLDER/$sender_id" ]] || echo "0" > "$NOTIF_FOLDER/$sender_id" - - old_notification_id=$(cat "$NOTIF_FOLDER/$sender_id") - - ${pkgs.libnotify}/bin/notify-send "$message" \ - $extraargs \ - --replace-id="$old_notification_id" --print-id > "$NOTIF_FOLDER/$sender_id" - ''; - battery-watch = pkgs.writeShellScriptBin "battery-watch" '' while true;do battery-plugged & @@ -54,9 +28,9 @@ let notif "battery" "󰁻 Low battery" "Battery level is $BATTERY_LEVEL%" elif [[ $BATTERY_LEVEL -le 10 ]] && [[ $BATTERY_STATUS == "Discharging" ]]; then notif "battery" "󰁺 Very low battery" "Battery level is $BATTERY_LEVEL%" - elif [[ $BATTERY_LEVEL -eq 100 ]] && [[ $BATTERY_STATUS -ne "Discharging" ]]; then - notif "battery" "󰁹 Fully charged" + # elif [[ $BATTERY_LEVEL -eq 100 ]] && [[ $BATTERY_STATUS -ne "Discharging" ]]; then + # notif "battery" "󰁹 Fully charged" fi ''; -in { home.packages = [ notif battery-watch battery-plugged battery-level ]; } +in { home.packages = [ battery-watch battery-plugged battery-level ]; } diff --git a/home/scripts/default.nix b/home/scripts/default.nix index 9a13c83..c96171b 100644 --- a/home/scripts/default.nix +++ b/home/scripts/default.nix @@ -8,7 +8,8 @@ ./screenshot ./startup ./nerdfont_fzf - ./system + ./notification + ./battery ./compress ./misc ./tofi diff --git a/home/scripts/notification/default.nix b/home/scripts/notification/default.nix new file mode 100644 index 0000000..d105920 --- /dev/null +++ b/home/scripts/notification/default.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: +let + notif = pkgs.writeShellScriptBin "notif" '' + # Shell script to send custom notifications + NOTIF_FOLDER="/tmp/notif" + sender_id=$1 # To overwrite existing notifications + message=$2 + extraargs="" + description="" + if [[ $3 == "extraargs="* ]]; then + extraargs=$(echo "$3" | sed 's/extraargs=//g') + else + description="$3" + extraargs="$4" + fi + + [[ -d "$NOTIF_FOLDER" ]] || mkdir $NOTIF_FOLDER + [[ -f "$NOTIF_FOLDER/$sender_id" ]] || echo "0" > "$NOTIF_FOLDER/$sender_id" + + old_notification_id=$(cat "$NOTIF_FOLDER/$sender_id") + + ${pkgs.libnotify}/bin/notify-send "$message" \ + $extraargs \ + --replace-id="$old_notification_id" --print-id > "$NOTIF_FOLDER/$sender_id" + ''; + +in { home.packages = [ notif ]; }