diff options
Diffstat (limited to 'accounts/gkleen@sif')
-rw-r--r-- | accounts/gkleen@sif/hyprland.nix | 4 | ||||
-rw-r--r-- | accounts/gkleen@sif/systemd.nix | 55 |
2 files changed, 58 insertions, 1 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 = { |