diff options
| -rw-r--r-- | accounts/gkleen@sif/hyprland.nix | 4 | ||||
| -rw-r--r-- | accounts/gkleen@sif/systemd.nix | 55 | ||||
| -rw-r--r-- | home-modules/lmu-hausschrift/default.nix | 37 |
3 files changed, 83 insertions, 13 deletions
diff --git a/accounts/gkleen@sif/hyprland.nix b/accounts/gkleen@sif/hyprland.nix index 645a2f22..052f35b0 100644 --- a/accounts/gkleen@sif/hyprland.nix +++ b/accounts/gkleen@sif/hyprland.nix | |||
| @@ -184,6 +184,10 @@ in { | |||
| 184 | "CTRL, comma, exec, dunstctl history-pop" | 184 | "CTRL, comma, exec, dunstctl history-pop" |
| 185 | 185 | ||
| 186 | "$mainMod ALT, E, exec, emacsclient -c" | 186 | "$mainMod ALT, E, exec, emacsclient -c" |
| 187 | "$mainMod ALT, Y, exec, ${pkgs.writeShellScript "yt-dlp" '' | ||
| 188 | export PATH="${lib.makeBinPath (with pkgs; [ wl-clipboard-rs socat ])}:$PATH" | ||
| 189 | socat STDIO UNIX-CONNECT:"$XDG_RUNTIME_DIR"/yt-dlp.sock <<<$'{ "urls": ["'"$(wl-paste)"$'"] }' | ||
| 190 | ''}" | ||
| 187 | 191 | ||
| 188 | ", XF86MonBrightnessUp, exec, lightctl -d -e4 -n1 up" | 192 | ", XF86MonBrightnessUp, exec, lightctl -d -e4 -n1 up" |
| 189 | ", XF86MonBrightnessDown, exec, lightctl -d -e4 -n1 down" | 193 | ", XF86MonBrightnessDown, exec, lightctl -d -e4 -n1 down" |
diff --git a/accounts/gkleen@sif/systemd.nix b/accounts/gkleen@sif/systemd.nix index 09d058de..b7bf902e 100644 --- a/accounts/gkleen@sif/systemd.nix +++ b/accounts/gkleen@sif/systemd.nix | |||
| @@ -278,6 +278,47 @@ in { | |||
| 278 | ''}''; | 278 | ''}''; |
| 279 | }; | 279 | }; |
| 280 | }; | 280 | }; |
| 281 | "yt-dlp@" = { | ||
| 282 | Service = { | ||
| 283 | Type = "notify"; | ||
| 284 | RuntimeDirectory = "%N"; | ||
| 285 | StandardInput = "socket"; | ||
| 286 | StandardOutput = "journal"; | ||
| 287 | WatchdogSec = "10s"; | ||
| 288 | Environment = [ | ||
| 289 | "PATH=${lib.makeBinPath (with pkgs; [atomicparsley ffmpeg-headless rtmpdump])}" | ||
| 290 | ]; | ||
| 291 | ExecStart = pkgs.writers.writePython3 "yt-dlp" { | ||
| 292 | libraries = with pkgs.python3Packages; [ yt-dlp sdnotify ]; | ||
| 293 | } '' | ||
| 294 | import json | ||
| 295 | from yt_dlp import YoutubeDL, parse_options | ||
| 296 | from sys import stdin | ||
| 297 | from sdnotify import SystemdNotifier | ||
| 298 | from os import environ | ||
| 299 | from pathlib import Path | ||
| 300 | |||
| 301 | |||
| 302 | n = SystemdNotifier() | ||
| 303 | args = json.load(stdin) | ||
| 304 | ydl_opts = { | ||
| 305 | **parse_options().ydl_opts, | ||
| 306 | 'progress_hooks': [lambda _d: n.notify('WATCHDOG=1')], | ||
| 307 | 'postprocessor_hooks': [lambda _d: n.notify('WATCHDOG=1')], | ||
| 308 | 'progress_with_newline': True, | ||
| 309 | 'progress_delta': 5, | ||
| 310 | 'paths': { | ||
| 311 | 'home': str(Path.home() / 'media'), | ||
| 312 | 'temp': str(Path(environ['RUNTIME_DIRECTORY'])), | ||
| 313 | }, | ||
| 314 | **(args['params'] if 'params' in args else {}), | ||
| 315 | } | ||
| 316 | with YoutubeDL(ydl_opts) as ytdl: | ||
| 317 | n.notify('READY=1') | ||
| 318 | ytdl.download(args['urls']) | ||
| 319 | ''; | ||
| 320 | }; | ||
| 321 | }; | ||
| 281 | } // listToAttrs (map ({host, port}: nameValuePair "proxy-to-autossh-socks@${toString port}" { | 322 | } // listToAttrs (map ({host, port}: nameValuePair "proxy-to-autossh-socks@${toString port}" { |
| 282 | Unit = { | 323 | Unit = { |
| 283 | Requires = ["autossh-socks@${host}:${toString (port + 1)}.service" "proxy-to-autossh-socks@${toString port}.socket"]; | 324 | Requires = ["autossh-socks@${host}:${toString (port + 1)}.service" "proxy-to-autossh-socks@${toString port}.socket"]; |
| @@ -294,7 +335,19 @@ in { | |||
| 294 | Install = { | 335 | Install = { |
| 295 | WantedBy = ["default.target"]; | 336 | WantedBy = ["default.target"]; |
| 296 | }; | 337 | }; |
| 297 | }) [8118 8120]); | 338 | }) [8118 8120]) // { |
| 339 | "yt-dlp" = { | ||
| 340 | Socket = { | ||
| 341 | SocketMode = "0600"; | ||
| 342 | Accept = true; | ||
| 343 | ListenStream = "%t/yt-dlp.sock"; | ||
| 344 | TriggerLimitIntervalSec = 0; | ||
| 345 | }; | ||
| 346 | Install = { | ||
| 347 | WantedBy = ["sockets.target"]; | ||
| 348 | }; | ||
| 349 | }; | ||
| 350 | }; | ||
| 298 | timers = { | 351 | timers = { |
| 299 | sync-keepass = { | 352 | sync-keepass = { |
| 300 | Timer = { | 353 | Timer = { |
diff --git a/home-modules/lmu-hausschrift/default.nix b/home-modules/lmu-hausschrift/default.nix index c3344947..ceaf7252 100644 --- a/home-modules/lmu-hausschrift/default.nix +++ b/home-modules/lmu-hausschrift/default.nix | |||
| @@ -24,24 +24,37 @@ with lib; | |||
| 24 | ''; | 24 | ''; |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | systemd.user.services.sops-nix = { | 27 | systemd.user.services.unpack-lmu-hausschrift = { |
| 28 | Unit = { | ||
| 29 | ConditionPathExists = [ | ||
| 30 | "!%h/.local/share/lmu-hausschrift" | ||
| 31 | "!%t/lmu-hausschrift" | ||
| 32 | ]; | ||
| 33 | }; | ||
| 34 | Unit = { | ||
| 35 | After = ["sops-nix.service"]; | ||
| 36 | }; | ||
| 37 | Install = { | ||
| 38 | WantedBy = ["sops-nix.service"]; | ||
| 39 | }; | ||
| 28 | Service = { | 40 | Service = { |
| 29 | ExecStartPost = pkgs.writeShellScript "unpack-lmu-hausschrift.sh" '' | 41 | UMask = "07077"; |
| 42 | Environment = [ | ||
| 43 | "PATH=${lib.makeBinPath (with pkgs; [gnutar coreutils])}" | ||
| 44 | ]; | ||
| 45 | ExecStart = pkgs.writeShellScript "unpack-lmu-hausschrift.sh" '' | ||
| 30 | set -xe | 46 | set -xe |
| 31 | 47 | ||
| 32 | out=''${XDG_RUNTIME_DIR:-/tmp}/lmu-hausschrift | 48 | out=''${XDG_RUNTIME_DIR:-/tmp}/lmu-hausschrift |
| 33 | src="${config.sops.secrets."lmu-hausschrift.tar.zstd".path}" | 49 | src="${config.sops.secrets."lmu-hausschrift.tar.zstd".path}" |
| 34 | src=''${src#"%r/"} | 50 | if [[ "$src" =~ ^%r ]]; then |
| 35 | src=''${XDG_RUNTIME_DIR:-/tmp}/"''${src}" | 51 | src=''${src#"%r/"} |
| 36 | 52 | src=''${XDG_RUNTIME_DIR:-/tmp}/"''${src}" | |
| 37 | umask 07077 | ||
| 38 | |||
| 39 | if [[ ! -d "''${out}" ]]; then | ||
| 40 | ${pkgs.coreutils}/bin/mkdir -p "''${out}" | ||
| 41 | ${pkgs.gnutar}/bin/tar -xaf "''${src}" -C "''${out}" | ||
| 42 | |||
| 43 | ${pkgs.coreutils}/bin/ln -sfT "''${out}" "${config.home.homeDirectory}/.local/share/lmu-hausschrift" | ||
| 44 | fi | 53 | fi |
| 54 | |||
| 55 | mkdir -p "''${out}" | ||
| 56 | tar -xaf "''${src}" -C "''${out}" | ||
| 57 | ln -sfT "''${out}" "${config.home.homeDirectory}/.local/share/lmu-hausschrift" | ||
| 45 | ''; | 58 | ''; |
| 46 | }; | 59 | }; |
| 47 | }; | 60 | }; |
