waybar: extract _sway_idle_toggle script

This commit is contained in:
Leonardo Eugênio 2023-05-04 19:32:12 -03:00
parent 8d980ed634
commit 517086541e
4 changed files with 14 additions and 10 deletions

11
scripts/_sway_idle_toggle Normal file
View file

@ -0,0 +1,11 @@
#!/bin/sh
swayidlectl() {
systemctl --user $1 swayidle.service
}
if swayidlectl status > /dev/null; then
swayidlectl stop
else
swayidlectl start
fi

View file

@ -28,6 +28,7 @@ create_scripts
wl-copy-file = [ wl-clipboard fish ]; wl-copy-file = [ wl-clipboard fish ];
_diffr = [ diffr ]; _diffr = [ diffr ];
_thunar-terminal = [ final.terminal ]; _thunar-terminal = [ final.terminal ];
_sway_idle_toggle = [ final.swayidle ];
kak-pager = [ fish final._diffr ]; kak-pager = [ fish final._diffr ];
kak-man-pager = [ final.kak-pager ]; kak-man-pager = [ final.kak-pager ];
musmenu = [ mpc-cli final.wdmenu trash-cli xdg-user-dirs libnotify sd wl-clipboard ]; musmenu = [ mpc-cli final.wdmenu trash-cli xdg-user-dirs libnotify sd wl-clipboard ];

View file

@ -17,14 +17,6 @@ let
systemctl suspend systemctl suspend
''; '';
_sway_idle_toggle = pkgs.writeShellScriptBin "_sway_idle_toggle" ''
if systemctl --user status swayidle > /dev/null; then
systemctl --user stop swayidle.service
else
systemctl --user start swayidle.service
fi
'';
# mod+1 to swich to workspace 1 # mod+1 to swich to workspace 1
# mod+shift+1 to move to workspace 1 # mod+shift+1 to move to workspace 1
workspace_binds = lib.forEachMerge (lib.range 1 10) (i: workspace_binds = lib.forEachMerge (lib.range 1 10) (i:
@ -133,7 +125,7 @@ let
system_binds = { system_binds = {
"--locked Ctrl+${mod}+z" = "exec ${_suspend}/bin/_suspend"; "--locked Ctrl+${mod}+z" = "exec ${_suspend}/bin/_suspend";
"${mod}+Alt+c" = "exec ${_sway_idle_toggle}/bin/_sway_idle_toggle"; "${mod}+Alt+c" = "exec ${pkgs._sway_idle_toggle}/bin/_sway_idle_toggle";
}; };
screenshot_binds = { screenshot_binds = {

View file

@ -106,7 +106,7 @@ in
"custom/caffeine" = { "custom/caffeine" = {
format = "{}"; format = "{}";
exec = "systemctl --user status swayidle > /dev/null && echo || echo "; exec = "systemctl --user status swayidle > /dev/null && echo || echo ";
on-click = "_sway_idle_toggle"; on-click = "${pkgs._sway_idle_toggle}/bin/_sway_idle_toggle";
interval = 1; interval = 1;
tooltip = false; tooltip = false;
}; };