sway: add scripts to suspend and toggle sway idle

This commit is contained in:
Leonardo Eugênio 2022-08-04 19:58:09 -03:00
parent 2d09c02d4c
commit e9e6b6f76a

View file

@ -163,6 +163,21 @@ let
''; '';
volumesh = volumesh =
pkgs.writeShellScriptBin "volumesh" (builtins.readFile ./scripts/volumesh); pkgs.writeShellScriptBin "volumesh" (builtins.readFile ./scripts/volumesh);
_lock = pkgs.writeShellScriptBin "_lock" ''
swaylock -f
systemctl --user start swayidle.service
'';
_suspend = pkgs.writeShellScriptBin "_suspend" ''
${_lock}/bin/_lock
systemctl suspend
'';
_sway_idle_toggle = pkgs.writeShellScriptBin "_sway_idle_toggle" ''
if pidof swayidle > /dev/null; then
systemctl --user stop swayidle.service
else
systemctl --user start swayidle.service
fi
'';
in { in {
# Home Manager needs a bit of information about you and the # Home Manager needs a bit of information about you and the
# paths it should manage. # paths it should manage.
@ -499,7 +514,7 @@ in {
layer = "top"; layer = "top";
modules-left = [ "sway/workspaces" "sway/mode" ]; modules-left = [ "sway/workspaces" "sway/mode" ];
modules-center = [ "clock" ]; modules-center = [ "clock" ];
modules-right = [ "pulseaudio" "network" ]; modules-right = [ "custom/caffeine" "pulseaudio" "network" ];
network = { network = {
interval = 5; interval = 5;
tooltip = false; tooltip = false;
@ -534,6 +549,13 @@ in {
format = "<b>{:%H:%M %a %d/%m}</b>"; format = "<b>{:%H:%M %a %d/%m}</b>";
tooltip = false; tooltip = false;
}; };
"custom/caffeine" = {
format = "{}";
exec = "pidof swayidle > /dev/null && echo || echo ";
on-click = "_sway_idle_toggle";
interval = 1;
tooltip = false;
};
pulseaudio = { pulseaudio = {
interval = 5; interval = 5;
tooltip = false; tooltip = false;
@ -828,7 +850,10 @@ in {
XF86AudioNext = "exec playerctl next"; XF86AudioNext = "exec playerctl next";
XF86AudioPrev = "exec playerctl previous"; XF86AudioPrev = "exec playerctl previous";
}; };
system_binds = { "Ctrl+${mod}+z" = "exec systemctl suspend"; }; system_binds = {
"--locked Ctrl+${mod}+z" = "exec ${_suspend}/bin/_suspend";
"${mod}+Alt+c" = "exec ${_sway_idle_toggle}/bin/_sway_idle_toggle";
};
in { in {
"${mod}+Return" = "exec ${terminal}"; "${mod}+Return" = "exec ${terminal}";
"${mod}+Ctrl+Return" = "exec thunar"; "${mod}+Ctrl+Return" = "exec thunar";