diff --git a/home/home.nix b/home/home.nix index 49d46b6..01d3f63 100644 --- a/home/home.nix +++ b/home/home.nix @@ -47,8 +47,12 @@ in # user interface ui = { - wm.xmonad.enable = true; - bar.polybar.enable = true; + # windows manager + xmonad.enable = true; + # bar + polybar.enable = true; + # lock + betterlockscreen.enable = true; }; # shell @@ -96,14 +100,6 @@ in accounts = secrets.emailAccounts; }; - # TODO: add module for lock screen - services.screen-locker = { - enable = true; - - lockCmd = "/bin/bash -c ${config.home.homeDirectory}/scripts/lock.sh"; - - inactiveInterval = 15; - }; home.file = { "scripts" = { diff --git a/home/ui/bar/default.nix b/home/ui/bar/default.nix deleted file mode 100644 index f20a3e5..0000000 --- a/home/ui/bar/default.nix +++ /dev/null @@ -1 +0,0 @@ -[ ./polybar ] diff --git a/home/ui/betterlockscreen.nix b/home/ui/betterlockscreen.nix new file mode 100644 index 0000000..e9a4627 --- /dev/null +++ b/home/ui/betterlockscreen.nix @@ -0,0 +1,59 @@ +{ lib, config, pkgs, ...}: + +with lib; + +let + cfg = config.ui.betterlockscreen; + + package = config.services.betterlockscreen.package; +in +{ + options.ui.betterlockscreen = { + enable = mkOption { + type = types.bool; + default = false; + description = "Enable betterlockscreen"; + }; + }; + + + config = mkIf cfg.enable { + services.betterlockscreen = { + enable = true; + inactiveInterval = 15; + }; + + systemd.user.timers.updateBetterlockscreenImage = { + Unit = { + Description = "Update betterlockscreen image timer"; + After = [ "graphical-session.target" "timers.target" ]; + }; + + Timer = { + OnUnitActiveSec = "60min"; + OnBootSec = "10s"; + }; + + Install = { + WantedBy = [ "graphical-session.target" "timers.target" ]; + }; + }; + + systemd.user.services.updateBetterlockscreenImage = { + Unit = { + Description = "Update betterlockscreen image"; + After = [ "graphical-session.target" ]; + }; + + Service = { + Type = "oneshot"; + Environment = "PATH=/run/current-system/sw/bin"; + ExecStart = "${package}/bin/betterlockscreen --update ${config.home.homeDirectory}/pictures/wallpapers"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; +} diff --git a/home/ui/default.nix b/home/ui/default.nix index 50ff19e..46461aa 100644 --- a/home/ui/default.nix +++ b/home/ui/default.nix @@ -1 +1,6 @@ -(import ./wm) ++ (import ./bar) +[ + ./xmonad + ./polybar + ./betterlockscreen.nix +] + diff --git a/home/ui/bar/polybar/config.nix b/home/ui/polybar/config.nix similarity index 96% rename from home/ui/bar/polybar/config.nix rename to home/ui/polybar/config.nix index ffd8b07..678a8cc 100644 --- a/home/ui/bar/polybar/config.nix +++ b/home/ui/polybar/config.nix @@ -70,7 +70,7 @@ with lib; }; }; - "module/xmonad" = mkIf config.ui.wm.xmonad.enable { + "module/xmonad" = mkIf config.ui.xmonad.enable { type = "custom/script"; exec = "${pkgs.xmonad-log}/bin/xmonad-log"; tail = true; diff --git a/home/ui/bar/polybar/default.nix b/home/ui/polybar/default.nix similarity index 92% rename from home/ui/bar/polybar/default.nix rename to home/ui/polybar/default.nix index e8d2744..cad76ea 100644 --- a/home/ui/bar/polybar/default.nix +++ b/home/ui/polybar/default.nix @@ -3,7 +3,7 @@ with lib; let - cfg = config.ui.bar.polybar; + cfg = config.ui.polybar; pcfg = config.services.polybar; # TODO: create a theme @@ -14,7 +14,7 @@ let polybarConfig = import ./config.nix { inherit lib config pkgs colors; }; in { - options.ui.bar.polybar = { + options.ui.polybar = { enable = mkOption { type = types.bool; default = false; diff --git a/home/ui/wm/default.nix b/home/ui/wm/default.nix deleted file mode 100644 index 3046618..0000000 --- a/home/ui/wm/default.nix +++ /dev/null @@ -1 +0,0 @@ -[ ./xmonad ] diff --git a/home/ui/wm/xmonad/config.hs b/home/ui/xmonad/config.hs similarity index 99% rename from home/ui/wm/xmonad/config.hs rename to home/ui/xmonad/config.hs index a2f3c76..da2e586 100644 --- a/home/ui/wm/xmonad/config.hs +++ b/home/ui/xmonad/config.hs @@ -290,7 +290,7 @@ myKeys conf = mkKeymap conf $ -- Lock screen - , ("M4-l", spawn "bash ~/scripts/lock.sh") + , ("M4-l", spawn "betterlockscreen --lock") -- Change volume , ("", spawn "amixer -q sset Master toggle") diff --git a/home/ui/wm/xmonad/default.nix b/home/ui/xmonad/default.nix similarity index 88% rename from home/ui/wm/xmonad/default.nix rename to home/ui/xmonad/default.nix index 7340f23..3472cb9 100644 --- a/home/ui/wm/xmonad/default.nix +++ b/home/ui/xmonad/default.nix @@ -4,10 +4,10 @@ with lib; let uiCfg = config.ui; - cfg = uiCfg.wm.xmonad; + cfg = uiCfg.xmonad; in { - options.ui.wm.xmonad = { + options.ui.xmonad = { enable = mkOption { type = types.bool; default = false; @@ -30,7 +30,7 @@ in enable = true; enableContribAndExtras = true; config = ./config.hs; - extraPackages = mkIf uiCfg.bar.polybar.enable (hp: [ + extraPackages = mkIf uiCfg.polybar.enable (hp: [ hp.dbus hp.monad-logger ]); diff --git a/scripts/lock.sh b/scripts/lock.sh deleted file mode 100755 index 6507da6..0000000 --- a/scripts/lock.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -/usr/bin/i3lock -eti $(ls $HOME/pictures/wallpapers/*.png | awk '{ print $1 }' | sort -R | head -n 1)