Always hibernate

This commit is contained in:
Benjamin Bädorf 2022-01-12 17:39:16 +01:00
parent ad99c6152a
commit 578f05b4f1
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
4 changed files with 4 additions and 29 deletions

View file

@ -33,12 +33,10 @@ set $menu exec alacritty --class launcher -e env TERMINAL_COMMAND="alacritty -e"
bindsym $mod+Space exec $menu
# Set shut down, restart and locking features
set $mode_system (l)ock, (e)xit, (s)uspend, (h)ibernate, (r)eboot, (Shift+s)hutdown
set $mode_system (e)xit, (h)ibernate, (r)eboot, (Shift+s)hutdown
bindsym $mod+0 mode "$mode_system"
mode "$mode_system" {
bindsym l exec swaylock-bg, mode "default"
bindsym e exec swaymsg exit, mode "default"
bindsym s exec systemctl suspend, mode "default"
bindsym h exec systemctl hibernate, mode "default"
bindsym r exec systemctl reboot, mode "default"
bindsym Shift+s exec systemctl poweroff, mode "default"

View file

@ -9,12 +9,10 @@ pkgs:
};
Service = {
Type = "simple";
Environment = "PATH=/run/current-system/sw/bin:${pkgs.sway}/bin:${pkgs.swaylock}/bin:${pkgs.swaylock-bg}/bin";
Environment = "PATH=/run/current-system/sw/bin:${pkgs.sway}/bin";
ExecStart = ''${pkgs.swayidle}/bin/swayidle -w \
timeout 600 'swaylock-bg' \
timeout 900 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock-bg'
timeout 300 'swaymsg "output * dpms off"' \
timeout 600 'systemctl hibernate' \
'';
};
Install = {

View file

@ -12,7 +12,6 @@ with final; {
s = writeShellScriptBin "s" (import ./s.nix final);
sway-launcher = writeScriptBin "sway-launcher" (import ./sway-launcher.nix final);
sway-service = writeShellScriptBin "sway-service" (import ./sway-service.nix final);
swaylock-bg = writeScriptBin "swaylock-bg" (import ./swaylock-bg.nix final);
toggle-kbd-layout = writeShellScriptBin "toggle-kbd-layout" (import ./toggle-kbd-layout.nix final);
uhk-agent = import ./uhk-agent.nix final;
wcwd = writeShellScriptBin "wcwd" (import ./wcwd.nix final);

View file

@ -1,20 +0,0 @@
self: with self; ''
# Dependencies:
# swaylock
# Make sure we aren't running twice
RUNNING=$(ps -A | grep swaylock | wc -l)
if [ $RUNNING -ne 0 ]; then
exit 0
fi
IMAGE=$XDG_CONFIG_HOME/wallpaper.jpg
LOCKARGS=""
for OUTPUT in `${sway}/bin/swaymsg -t get_outputs | jq -r '.[].name'`
do
LOCKARGS="''${LOCKARGS} --image ''${OUTPUT}:''${IMAGE}"
IMAGES="''${IMAGES} ''${IMAGE}"
done
exec ${swaylock}/bin/swaylock $LOCKARGS
''