summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2024-08-17 13:18:49 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2024-08-17 13:18:49 +0200
commit4c55551353bb57a2fa8f25be0f6109fc324546dd (patch)
tree51c08cd0b40d5fe764d9a8132a791f8d647c34ce /accounts/gkleen@sif
parent21311806407ac301702996a4658c1dee2bf5f80e (diff)
downloadnixos-4c55551353bb57a2fa8f25be0f6109fc324546dd.tar
nixos-4c55551353bb57a2fa8f25be0f6109fc324546dd.tar.gz
nixos-4c55551353bb57a2fa8f25be0f6109fc324546dd.tar.bz2
nixos-4c55551353bb57a2fa8f25be0f6109fc324546dd.tar.xz
nixos-4c55551353bb57a2fa8f25be0f6109fc324546dd.zip
...
Diffstat (limited to 'accounts/gkleen@sif')
-rw-r--r--accounts/gkleen@sif/default.nix57
-rw-r--r--accounts/gkleen@sif/hyprland.nix2
-rw-r--r--accounts/gkleen@sif/systemd.nix76
3 files changed, 81 insertions, 54 deletions
diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix
index 47d2212b..e6cbd77d 100644
--- a/accounts/gkleen@sif/default.nix
+++ b/accounts/gkleen@sif/default.nix
@@ -88,55 +88,7 @@ let
88 exec -a "$1" "$@" 88 exec -a "$1" "$@"
89 ''; 89 '';
90 90
91 lockCommand = pkgs.writeShellScript "gtklock" '' 91 lockCommand = "${config.systemd.package}/bin/systemctl --user start gtklock.service";
92 set -x
93
94 export PATH="${lib.makeBinPath [cfg.programs.wpaperd.package pkgs.jq pkgs.coreutils pkgs.gtklock pkgs.imagemagick pkgs.findutils pkgs.libsForQt5.qt5.qttools pkgs.systemd]}:$PATH"
95
96 qdbus org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.KeePassXC.MainWindow.lockAllDatabases
97 systemctl --user --no-block stop gpg-agent.service
98
99 tmpDir=$(mktemp -d --tmpdir="$RUNTIME_DIRECTORY" "gtklock.$(date -uIs).XXXXXXXX")
100
101 args=()
102
103 cp --no-preserve=mode ${pkgs.writeText "gtklock.css" ''
104 #window-box {
105 padding: 64px;
106 /* border: 1px solid black; */
107 border-radius: 4px;
108 box-shadow: rgba(0, 0, 0, 0.8) 0px 4px 12px;
109 /* background-color: white; */
110 background-color: rgba(0, 0, 0, 0.5);
111 }
112 ''} "$tmpDir"/style.css
113
114 monitors=()
115 while IFS= read -r entry; do
116 path=$(jq -r ".path" <<<"$entry")
117 [[ -z "$path" || ! -f "$path" ]] && continue
118 display=$(jq -r ".display" <<<"$entry")
119 monitors+=("$display")
120 # ln -s "$path" "$tmpDir"/"$display"."''${path##*.}"
121 magick "$path" -filter Gaussian -resize 6.25% -define filter:sigma=2.5 -resize 1600% "$tmpDir"/"$display"."''${path##*.}" &
122 done < <(wpaperctl all-wallpapers -j | jq -c ".[]")
123 wait
124 for monitor in "''${monitors[@]}"; do
125 path=$(find "$tmpDir" -name "$monitor"'.*')
126 cat >>"$tmpDir"/style.css <<EOF
127 window#''${monitor} {
128 background-image: url("''${path}");
129 background-repeat: no-repeat;
130 background-size: 100% 100%;
131 background-origin: content-box;
132 }
133 EOF
134 done
135 args+=("-s" "$tmpDir"/style.css)
136
137 args+=("$@")
138 exec gtklock "''${args[@]}"
139 '';
140in { 92in {
141 imports = with flake.nixosModules.userProfiles.${userName}; [ 93 imports = with flake.nixosModules.userProfiles.${userName}; [
142 mpv yt-dlp (args: import ./xcompose.nix (inputs // args)) 94 mpv yt-dlp (args: import ./xcompose.nix (inputs // args))
@@ -659,16 +611,15 @@ in {
659 swayidle = { 611 swayidle = {
660 enable = true; 612 enable = true;
661 events = [ 613 events = [
662 { event = "before-sleep"; command = "${lockCommand} -d"; } 614 { event = "before-sleep"; command = lockCommand; }
663 { event = "after-resume"; command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on"; } 615 { event = "after-resume"; command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on"; }
664 { event = "lock"; command = "${lockCommand} -d"; } 616 { event = "lock"; command = lockCommand; }
665 ]; 617 ];
666 timeouts = [ 618 timeouts = [
667 { timeout = 300; 619 { timeout = 300;
668 command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off"; 620 command = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off";
669 resumeCommand = "${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on";
670 } 621 }
671 { timeout = 330; command = "${lockCommand} -d"; } 622 { timeout = 330; command = lockCommand; }
672 ]; 623 ];
673 extraArgs = [ 624 extraArgs = [
674 "idlehint" "30" 625 "idlehint" "30"
diff --git a/accounts/gkleen@sif/hyprland.nix b/accounts/gkleen@sif/hyprland.nix
index 23cbc972..15491c6f 100644
--- a/accounts/gkleen@sif/hyprland.nix
+++ b/accounts/gkleen@sif/hyprland.nix
@@ -72,6 +72,8 @@ in {
72 disable_hyprland_logo = true; 72 disable_hyprland_logo = true;
73 disable_splash_rendering = true; 73 disable_splash_rendering = true;
74 focus_on_activate = true; 74 focus_on_activate = true;
75 mouse_move_enables_dpms = true;
76 key_press_enables_dpms = true;
75 }; 77 };
76 78
77 cursor = { 79 cursor = {
diff --git a/accounts/gkleen@sif/systemd.nix b/accounts/gkleen@sif/systemd.nix
index be016b09..613d034a 100644
--- a/accounts/gkleen@sif/systemd.nix
+++ b/accounts/gkleen@sif/systemd.nix
@@ -1,7 +1,7 @@
1{ pkgs, lib, config, userName, ... }: 1{ pkgs, lib, config, userName, ... }:
2let 2let
3 inherit (lib) listToAttrs nameValuePair; 3 inherit (lib) listToAttrs nameValuePair;
4 4
5 xmobar = import ./xmobar pkgs.haskellPackages; 5 xmobar = import ./xmobar pkgs.haskellPackages;
6 cfg = config.home-manager.users.${userName}; 6 cfg = config.home-manager.users.${userName};
7 7
@@ -204,6 +204,80 @@ in {
204 WatchdogSec = "2s"; 204 WatchdogSec = "2s";
205 }; 205 };
206 }; 206 };
207 polkit-kde-authentication-agent-1 = {
208 Install = {
209 WantedBy = ["graphical-session.target"];
210 };
211 Unit = {
212 PartOf = ["graphical-session.target"];
213 Requires = ["graphical-session-pre.target"];
214 After = ["graphical-session-pre.target"];
215 };
216 Service = {
217 ExecStart = "${pkgs.kdePackages.polkit-kde-agent-1}/libexec/polkit-kde-authentication-agent-1";
218 Restart = "on-failure";
219 };
220 };
221 gtklock = {
222 Unit = {
223 Requisite = ["graphical-session.target"];
224 PartOf = ["graphical-session.target"];
225 };
226 Service = {
227 Type = "notify";
228 RuntimeDirectory = "gtklock";
229 CacheDirectory = "gtklock";
230 ExecStartPre = [
231 "${pkgs.libsForQt5.qt5.qttools.bin}/bin/qdbus org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.KeePassXC.MainWindow.lockAllDatabases"
232 "${config.systemd.package}/bin/systemctl --user stop gpg-agent.service"
233 (pkgs.writeShellScript "generate-css" ''
234 set -x
235 export PATH="${lib.makeBinPath [cfg.programs.wpaperd.package pkgs.jq pkgs.coreutils pkgs.imagemagick pkgs.findutils]}:$PATH"
236
237 declare -A monitors
238 monitors=()
239 while IFS= read -r entry; do
240 path=$(jq -r ".path" <<<"$entry")
241 [[ -z "$path" || ! -f "$path" ]] && continue
242 blurred_path="$CACHE_DIRECTORY"/"$(b2sum -l 128 <<<"$path" | cut -d' ' -f1)"."''${path##*.}"
243 monitor=$(jq -r ".display" <<<"$entry")
244 if [[ ! -f "$blurred_path" ]]; then
245 mkdir -p "$(dirname "$blurred_path")"
246 magick "$path" -filter Gaussian -resize 6.25% -define filter:sigma=2.5 -resize 1600% "$blurred_path" &
247 fi
248 monitors+=([$monitor]="$blurred_path")
249 done < <(wpaperctl all-wallpapers -j | jq -c ".[]")
250 wait
251
252 cp --no-preserve=mode ${pkgs.writeText "gtklock.css" ''
253 #window-box {
254 padding: 64px;
255 /* border: 1px solid black; */
256 border-radius: 4px;
257 box-shadow: rgba(0, 0, 0, 0.8) 0px 4px 12px;
258 /* background-color: white; */
259 background-color: rgba(0, 0, 0, 0.5);
260 }
261 ''} "$RUNTIME_DIRECTORY"/style.css
262 for monitor in "''${!monitors[@]}"; do
263 cat >>"$RUNTIME_DIRECTORY"/style.css <<EOF
264 window#''${monitor} {
265 background-image: url("''${monitors[$monitor]}");
266 background-repeat: no-repeat;
267 background-size: 100% 100%;
268 background-origin: content-box;
269 }
270 EOF
271 done
272 '')
273 ];
274 NotifyAccess = "all";
275 ExecStart = ''${lib.getExe pkgs.gtklock} -s "''${RUNTIME_DIRECTORY}/style.css" -L ${pkgs.writeShellScript "after-lock" ''
276 ${cfg.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off
277 ${config.systemd.package}/bin/systemd-notify --ready
278 ''}'';
279 };
280 };
207 } // listToAttrs (map ({host, port}: nameValuePair "proxy-to-autossh-socks@${toString port}" { 281 } // listToAttrs (map ({host, port}: nameValuePair "proxy-to-autossh-socks@${toString port}" {
208 Unit = { 282 Unit = {
209 Requires = ["autossh-socks@${host}:${toString (port + 1)}.service" "proxy-to-autossh-socks@${toString port}.socket"]; 283 Requires = ["autossh-socks@${host}:${toString (port + 1)}.service" "proxy-to-autossh-socks@${toString port}.socket"];