~b12f/pub-solar-os

578f05b4f16e2aed4a1a862e764c981081aff72d — Benjamin Bädorf 2 years ago ad99c61 feat/hibernate-always
Always hibernate
4 files changed, 4 insertions(+), 29 deletions(-)

M modules/sway/config/config.d/custom-keybindings.conf
M modules/sway/swayidle.service.nix
M pkgs/default.nix
D pkgs/swaylock-bg.nix
M modules/sway/config/config.d/custom-keybindings.conf => modules/sway/config/config.d/custom-keybindings.conf +1 -3
@@ 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"

M modules/sway/swayidle.service.nix => modules/sway/swayidle.service.nix +3 -5
@@ 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 = {

M pkgs/default.nix => pkgs/default.nix +0 -1
@@ 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);

D pkgs/swaylock-bg.nix => pkgs/swaylock-bg.nix +0 -20
@@ 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
''