From 4befb01e03879b14ed9d488b33b90e528690c2ad Mon Sep 17 00:00:00 2001 From: Filippo Berto Date: Tue, 16 Aug 2022 19:48:57 +0200 Subject: [PATCH] Auto brightness + dunst notification --- hm_modules/screen_locker.nix | 10 +++++++--- hm_modules/sxhkd.nix | 2 +- hm_modules/xidlehook.nix | 23 ++++++----------------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/hm_modules/screen_locker.nix b/hm_modules/screen_locker.nix index c3d4643..6045e4c 100644 --- a/hm_modules/screen_locker.nix +++ b/hm_modules/screen_locker.nix @@ -1,8 +1,12 @@ { pkgs, ... }: { services.screen-locker = { - enable = false; - lockCmd = "${pkgs.lockscreen}"; - inactiveInterval = 10; # miutes + enable = true; + lockCmd = "${pkgs.lockscreen}/bin/lockscreen"; + inactiveInterval = 2; # minutes + xautolock.extraOptions = [ + "-secure" + "-lockaftersleep" + ]; }; } diff --git a/hm_modules/sxhkd.nix b/hm_modules/sxhkd.nix index aab4186..6f9be69 100644 --- a/hm_modules/sxhkd.nix +++ b/hm_modules/sxhkd.nix @@ -55,7 +55,7 @@ "{XF86AudioLowerVolume,XF86AudioMute,XF86AudioRaiseVolume}" = "pamixer {-d 2 -u,-t,-i 2 -u} && dunstify -r 1 Volume `pamixer --get-volume-human`"; "XF86Audio{Next,Play,Prev}" = "playerctl {next,play-pause,previous}"; "super + alt + {Right,Down,Left}" = "playerctl {next,play-pause,previous}"; - "XF86MonBrightness{Up,Down}" = "xbacklight {+,-}10%"; + "XF86MonBrightness{Up,Down}" = ''xbacklight -{inc,dec} 10 && dunstify -r 2 Luminosità `printf "%.0f" $(xbacklight -get)`''; "Print" = "gnome-screenshot -i"; }; }; diff --git a/hm_modules/xidlehook.nix b/hm_modules/xidlehook.nix index bcb2878..a49cd28 100644 --- a/hm_modules/xidlehook.nix +++ b/hm_modules/xidlehook.nix @@ -3,31 +3,20 @@ with lib; let - xscreensaverCmd = "${pkgs.xscreensaver}/bin/xscreensaver-command -activate"; - lockCmd = "${pkgs.lockscreen}/bin/lockscreen"; + xbacklightCmd = "${pkgs.xorg.xbacklight}/bin/xbacklight"; + lightLevel = 10; in { services.xidlehook = { enable = true; - # not-when-audio = false; + not-when-audio = true; not-when-fullscreen = true; timers = [ { - command = lockCmd; - delay = 300; - } - { - command = xscreensaverCmd; - delay = 120; + command = "${xbacklightCmd} -get > /tmp/xbacklight_v && ${xbacklightCmd} -set ${toString lightLevel}"; + canceller = "${xbacklightCmd} -set $(cat /tmp/xbacklight_v || echo 100)"; + delay = 30; } ]; }; - services.xscreensaver = { - enable = true; - settings = { - mode = "blank"; - fadeTicks = 20; - lock = false; - }; - }; }