nix/lock: add service to update image cache

This commit is contained in:
Dmitriy Pleshevskiy 2022-08-28 23:35:11 +03:00
parent 1c8d04a6e3
commit f1bcf6fc0c
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
10 changed files with 78 additions and 22 deletions

View file

@ -47,8 +47,12 @@ in
# user interface # user interface
ui = { ui = {
wm.xmonad.enable = true; # windows manager
bar.polybar.enable = true; xmonad.enable = true;
# bar
polybar.enable = true;
# lock
betterlockscreen.enable = true;
}; };
# shell # shell
@ -96,14 +100,6 @@ in
accounts = secrets.emailAccounts; 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 = { home.file = {
"scripts" = { "scripts" = {

View file

@ -1 +0,0 @@
[ ./polybar ]

View file

@ -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" ];
};
};
};
}

View file

@ -1 +1,6 @@
(import ./wm) ++ (import ./bar) [
./xmonad
./polybar
./betterlockscreen.nix
]

View file

@ -70,7 +70,7 @@ with lib;
}; };
}; };
"module/xmonad" = mkIf config.ui.wm.xmonad.enable { "module/xmonad" = mkIf config.ui.xmonad.enable {
type = "custom/script"; type = "custom/script";
exec = "${pkgs.xmonad-log}/bin/xmonad-log"; exec = "${pkgs.xmonad-log}/bin/xmonad-log";
tail = true; tail = true;

View file

@ -3,7 +3,7 @@
with lib; with lib;
let let
cfg = config.ui.bar.polybar; cfg = config.ui.polybar;
pcfg = config.services.polybar; pcfg = config.services.polybar;
# TODO: create a theme # TODO: create a theme
@ -14,7 +14,7 @@ let
polybarConfig = import ./config.nix { inherit lib config pkgs colors; }; polybarConfig = import ./config.nix { inherit lib config pkgs colors; };
in in
{ {
options.ui.bar.polybar = { options.ui.polybar = {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;

View file

@ -1 +0,0 @@
[ ./xmonad ]

View file

@ -290,7 +290,7 @@ myKeys conf = mkKeymap conf $
-- Lock screen -- Lock screen
, ("M4-l", spawn "bash ~/scripts/lock.sh") , ("M4-l", spawn "betterlockscreen --lock")
-- Change volume -- Change volume
, ("<XF86AudioMute>", spawn "amixer -q sset Master toggle") , ("<XF86AudioMute>", spawn "amixer -q sset Master toggle")

View file

@ -4,10 +4,10 @@ with lib;
let let
uiCfg = config.ui; uiCfg = config.ui;
cfg = uiCfg.wm.xmonad; cfg = uiCfg.xmonad;
in in
{ {
options.ui.wm.xmonad = { options.ui.xmonad = {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
@ -30,7 +30,7 @@ in
enable = true; enable = true;
enableContribAndExtras = true; enableContribAndExtras = true;
config = ./config.hs; config = ./config.hs;
extraPackages = mkIf uiCfg.bar.polybar.enable (hp: [ extraPackages = mkIf uiCfg.polybar.enable (hp: [
hp.dbus hp.dbus
hp.monad-logger hp.monad-logger
]); ]);

View file

@ -1,2 +0,0 @@
#!/bin/bash
/usr/bin/i3lock -eti $(ls $HOME/pictures/wallpapers/*.png | awk '{ print $1 }' | sort -R | head -n 1)