mirror of
https://github.com/lightly-toasted/nix-config.git
synced 2025-12-10 03:49:44 +00:00
refactor(mouse-actions): use absolute paths
This commit is contained in:
parent
1c99f9d063
commit
e9f087deed
6 changed files with 42 additions and 72 deletions
|
|
@ -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"
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue