graphical/sway: add option to only lock screen

feat/authelia
Benjamin Yule Bädorf 2024-03-21 13:20:31 +01:00
parent 429a6bf3e5
commit 5c13335a52
Signed by: b12f
GPG Key ID: 729956E1124F8F26
4 changed files with 28 additions and 11 deletions

View File

@ -2,35 +2,36 @@
pkgs,
psCfg,
...
}:
}: with pkgs;
''
# Set shut down, restart and locking features
''
+ (
if psCfg.core.hibernation.enable
then ''
set $mode_system (e)xit, (h)ibernate, (r)eboot, (Shift+s)hutdown
set $mode_system (e)xit, (l)ock, (h)ibernate, (r)eboot, (Shift+s)hutdown
''
else ''
set $mode_system (e)xit, (r)eboot, (Shift+s)hutdown
set $mode_system (e)xit, (l)ock, (r)eboot, (Shift+s)hutdown
''
)
+ ''
bindsym $mod+0 mode "$mode_system"
mode "$mode_system" {
bindsym e exec swaymsg exit, mode "default"
bindsym e exec ${sway}/bin/swaymsg exit, mode "default"
bindsym l exec ${swaylock-bg}/bin/swaylock-bg, mode "default"
''
+ (
if psCfg.core.hibernation.enable
then ''
bindsym h exec systemctl hibernate, mode "default"
bindsym h exec ${systemd}/bin/systemctl hibernate, mode "default"
''
else ""
)
+ ''
bindsym r exec systemctl reboot, mode "default"
bindsym Shift+s exec systemctl poweroff, mode "default"
bindsym r exec ${systemd}/bin/systemctl reboot, mode "default"
bindsym Shift+s exec ${systemd}/bin/systemctl poweroff, mode "default"
# exit system mode: "Enter" or "Escape"
bindsym Return mode "default"

View File

@ -13,11 +13,13 @@
Service = {
Type = "simple";
Environment = "PATH=/run/current-system/sw/bin:${pkgs.sway}/bin:${pkgs.swayidle}/bin";
ExecStart = ''
ExecStart = with pkgs; ''
swayidle -w \
before-sleep 'systemctl hibernate'
timeout 120 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
timeout 150 'systemctl hibernate'
before-sleep '${systemd}/bin/systemctl hibernate' \
timeout 120 '${swaylock-bg}/bin/swaylock-bg' \
timeout 130 '${sway}/bin/swaymsg "output * dpms off"' \
resume '${sway}/bin/swaymsg "output * dpms on"' \
timeout 300 '${systemd}/bin/systemctl hibernate'
'';
};
Install = {

View File

@ -18,6 +18,7 @@ with prev; {
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 = writeShellScriptBin "swaylock-bg" (import ./swaylock-bg.nix final);
toggle-kbd-layout = writeShellScriptBin "toggle-kbd-layout" (import ./toggle-kbd-layout.nix final);
wcwd = writeShellScriptBin "wcwd" (import ./wcwd.nix final);
drone-docker-runner = writeShellScriptBin "drone-docker-runner" (import ./drone-docker-runner.nix final);

View File

@ -0,0 +1,13 @@
self:
with self; ''
# Dependencies:
# swaylock
IMAGE="$XDG_CONFIG_HOME/wallpaper.jpg"
LOCKARGS=""
for OUTPUT in $(${sway}/bin/swaymsg --type get_outputs | ${jq}/bin/jq --raw-output '.[].name')
do
LOCKARGS="''${LOCKARGS} --image ''${OUTPUT}:''${IMAGE}"
done
exec ${swaylock}/bin/swaylock --scaling fill --daemonize $LOCKARGS
''