diff --git a/home/modules/graphical/mouse-actions/actions/autoclick.nix b/home/modules/graphical/mouse-actions/actions/autoclick.nix index 7d625df..0f8eee8 100644 --- a/home/modules/graphical/mouse-actions/actions/autoclick.nix +++ b/home/modules/graphical/mouse-actions/actions/autoclick.nix @@ -1,9 +1,9 @@ { pkgs, ... }: -let - script = pkgs.writeShellScriptBin "autoclick-action" '' +{ + package = pkgs.writeShellScriptBin "autoclick-action" '' if ! command -v ydotool >/dev/null 2>&1; then - notify-send -r 120000 "Autoclicker" "This tool requires ydotool to be installed on your system." + ${pkgs.libnotify}/bin/notify-send -r 120000 "Autoclicker" "This tool requires ydotool to be installed on your system." fi AUTOCLICK_FILE="/run/user/$(id -u)/autoclick" @@ -15,11 +15,11 @@ let current=$(cat "$AUTOCLICK_FILE") if [ "$current" = "0" ]; then echo "1" > "$AUTOCLICK_FILE" - notify-send -r 120000 "Autoclicker" "Stopped" + ${pkgs.libnotify}/bin/notify-send -r 120000 "Autoclicker" "Stopped" exit 0 else echo "0" > "$AUTOCLICK_FILE" - notify-send -r 120000 "Autoclicker" "Started" + ${pkgs.libnotify}/bin/notify-send -r 120000 "Autoclicker" "Started" fi while :; do @@ -31,10 +31,4 @@ let fi done ''; -in -{ - package = pkgs.symlinkJoin { - name = "autoclick-action"; - paths = [ script pkgs.libnotify ]; - }; } diff --git a/home/modules/graphical/mouse-actions/actions/deafen.nix b/home/modules/graphical/mouse-actions/actions/deafen.nix index ba9d867..8a32f3a 100644 --- a/home/modules/graphical/mouse-actions/actions/deafen.nix +++ b/home/modules/graphical/mouse-actions/actions/deafen.nix @@ -1,13 +1,7 @@ { pkgs, ... }: -let - script = pkgs.writeShellScriptBin "deafen-action" '' - hyprctl dispatch sendshortcut CTRL+SHIFT, D, 'class:^(vesktop)$' - ''; -in { - package = pkgs.symlinkJoin { - name = "deafen-action"; - paths = [ script pkgs.hyprland ]; - }; + package = pkgs.writeShellScriptBin "deafen-action" '' + ${pkgs.hyprland}/bin/hyprctl dispatch sendshortcut CTRL+SHIFT, D, 'class:^(vesktop)$' + ''; } diff --git a/home/modules/graphical/mouse-actions/actions/flick.nix b/home/modules/graphical/mouse-actions/actions/flick.nix index daa23f6..3b4b8b2 100644 --- a/home/modules/graphical/mouse-actions/actions/flick.nix +++ b/home/modules/graphical/mouse-actions/actions/flick.nix @@ -1,18 +1,12 @@ { pkgs, ... }: -let - script = pkgs.writeShellScriptBin "flick-action" '' +{ + package = pkgs.writeShellScriptBin "flick-action" '' if ! command -v ydotool >/dev/null 2>&1; then - notify-send -r 120000 "Flick" "This tool requires ydotool to be installed on your system." + ${pkgs.libnotify}/bin/notify-send -r 120000 "Flick" "This tool requires ydotool to be installed on your system." fi ydotool mousemove -- 800 0 sleep 0.03 ydotool mousemove -- -800 0 ''; -in -{ - package = pkgs.symlinkJoin { - name = "autoclick-action"; - paths = [ script pkgs.libnotify ]; - }; } diff --git a/home/modules/graphical/mouse-actions/actions/sober-lag.nix b/home/modules/graphical/mouse-actions/actions/sober-lag.nix index c13b77a..21bf18c 100644 --- a/home/modules/graphical/mouse-actions/actions/sober-lag.nix +++ b/home/modules/graphical/mouse-actions/actions/sober-lag.nix @@ -1,27 +1,27 @@ { pkgs, ... }: -let - script = pkgs.writeShellScriptBin "sober-lag-action" '' - roblox_pid=$(ps aux | grep "[s]ober --" | sort -k3 -nr | head -n 1 | awk '{print $2}') - if [ -z "$roblox_pid" ]; then - notify-send "sober-lag.sh" "Sober is not running." - exit 1 - fi - - pgid=$(ps -o pgid= -p "$roblox_pid" | xargs) - if [ -z "$pgid" ]; then - notify-send "sober-lag.sh" "Could not find PGID for PID $roblox_pid." - exit 1 - fi - - kill -STOP -- "-$pgid" - sleep 0.2 - kill -CONT -- "-$pgid" - ''; -in { - package = pkgs.symlinkJoin { - name = "sober-lag-action"; - paths = [ script pkgs.procps pkgs.gawk pkgs.gnugrep pkgs.gnused pkgs.coreutils pkgs.libnotify ]; - }; + package = pkgs.writeShellScriptBin "sober-lag-action" '' + roblox_pid=$(${pkgs.procps}/bin/ps aux \ + | ${pkgs.gnugrep}/bin/grep "[s]ober --" \ + | ${pkgs.coreutils}/bin/sort -k3 -nr \ + | ${pkgs.coreutils}/bin/head -n 1 \ + | ${pkgs.gawk}/bin/awk '{print $2}') + + if [ -z "$roblox_pid" ]; then + ${pkgs.libnotify}/bin/notify-send "sober-lag.sh" "Sober is not running." + exit 1 + fi + + pgid=$(${pkgs.procps}/bin/ps -o pgid= -p "$roblox_pid" | ${pkgs.coreutils}/bin/xargs) + + if [ -z "$pgid" ]; then + ${pkgs.libnotify}/bin/notify-send "sober-lag.sh" "Could not find PGID for PID $roblox_pid." + exit 1 + fi + + ${pkgs.coreutils}/bin/kill -STOP -- "-$pgid" + ${pkgs.coreutils}/bin/sleep 0.2 + ${pkgs.coreutils}/bin/kill -CONT -- "-$pgid" + ''; } diff --git a/home/modules/graphical/mouse-actions/cycle.nix b/home/modules/graphical/mouse-actions/cycle.nix index 1acd5d2..b5b8c8f 100644 --- a/home/modules/graphical/mouse-actions/cycle.nix +++ b/home/modules/graphical/mouse-actions/cycle.nix @@ -1,7 +1,7 @@ { pkgs }: -let - script = pkgs.writeShellScriptBin "cycle-mouse-action" '' +{ + package = pkgs.writeShellScriptBin "cycle-mouse-action" '' STATE_FILE="$HOME/.config/mouse-actions/state" mkdir -p "$(dirname "$STATE_FILE")" @@ -21,10 +21,4 @@ let echo "$NEW_ACTION" > "$STATE_FILE.tmp" mv "$STATE_FILE.tmp" "$STATE_FILE" ''; -in -{ - package = pkgs.symlinkJoin { - name = "cycle-mouse-action"; - paths = [ script pkgs.libnotify ]; - }; } diff --git a/home/modules/graphical/mouse-actions/run.nix b/home/modules/graphical/mouse-actions/run.nix index d7ce8ad..31d562c 100644 --- a/home/modules/graphical/mouse-actions/run.nix +++ b/home/modules/graphical/mouse-actions/run.nix @@ -1,7 +1,7 @@ { pkgs, actions }: -let - script = pkgs.writeShellScriptBin "run-mouse-action" '' +{ + package = pkgs.writeShellScriptBin "run-mouse-action" '' STATE_FILE="$HOME/.config/mouse-actions/state" if [ ! -f "$STATE_FILE" ]; then @@ -12,23 +12,17 @@ let case "$ACTION_NAME" in "deafen") - systemd-run --user ${actions.deafen.package}/bin/deafen-action + ${pkgs.systemd}/bin/systemd-run --user ${actions.deafen.package}/bin/deafen-action ;; "sober-lag") - systemd-run --user ${actions.sober-lag.package}/bin/sober-lag-action + ${pkgs.systemd}/bin/systemd-run --user ${actions.sober-lag.package}/bin/sober-lag-action ;; "autoclick") - systemd-run --user ${actions.autoclick.package}/bin/autoclick-action + ${pkgs.systemd}/bin/systemd-run --user ${actions.autoclick.package}/bin/autoclick-action ;; "flick") - systemd-run --user ${actions.flick.package}/bin/flick-action + ${pkgs.systemd}/bin/systemd-run --user ${actions.flick.package}/bin/flick-action ;; esac ''; -in -{ - package = pkgs.symlinkJoin { - name = "run-mouse-action"; - paths = [ script pkgs.systemd ]; - }; }