diff options
Diffstat (limited to 'accounts')
-rw-r--r-- | accounts/gkleen@sif/default.nix | 3 | ||||
-rw-r--r-- | accounts/gkleen@sif/niri/default.nix | 19 | ||||
-rw-r--r-- | accounts/gkleen@sif/niri/mako.nix | 1 | ||||
-rw-r--r-- | accounts/gkleen@sif/utils/async-yt-dlp.nix | 57 |
4 files changed, 76 insertions, 4 deletions
diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index 36a81f83..1686a278 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix | |||
@@ -282,6 +282,9 @@ in { | |||
282 | pro = "$HOME/projects/pro"; | 282 | pro = "$HOME/projects/pro"; |
283 | media = "$HOME/media"; | 283 | media = "$HOME/media"; |
284 | }; | 284 | }; |
285 | zsh.zsh-abbr.globalAbbreviations = { | ||
286 | "J" = "| jq '.'"; | ||
287 | }; | ||
285 | 288 | ||
286 | obs-studio = { | 289 | obs-studio = { |
287 | enable = true; | 290 | enable = true; |
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index af1af07a..09482c51 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix | |||
@@ -45,7 +45,6 @@ let | |||
45 | ''; | 45 | ''; |
46 | }; | 46 | }; |
47 | focus-or-spawn-action = config.lib.niri.actions.spawn (lib.getExe focus_or_spawn); | 47 | focus-or-spawn-action = config.lib.niri.actions.spawn (lib.getExe focus_or_spawn); |
48 | focus-or-spawn-action-app_id = app_id: focus-or-spawn-action ''select(.app_id == "${app_id}")''; | ||
49 | 48 | ||
50 | with_adjacent_workspace = pkgs.writeShellApplication { | 49 | with_adjacent_workspace = pkgs.writeShellApplication { |
51 | name = "with-adjacent-workspace"; | 50 | name = "with-adjacent-workspace"; |
@@ -84,7 +83,7 @@ let | |||
84 | }; | 83 | }; |
85 | with-adjacent-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_adjacent_workspace) "^${lib.concatMapStringsSep "|" ({ name, ...}: name) cfg.scratchspaces}$"; | 84 | with-adjacent-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_adjacent_workspace) "^${lib.concatMapStringsSep "|" ({ name, ...}: name) cfg.scratchspaces}$"; |
86 | focus-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | 85 | focus-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; |
87 | move-column-to-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}''; | 86 | move-column-to-adjacent-workspace = direction: with-adjacent-workspace-action direction ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}, "focus": true}}}''; |
88 | 87 | ||
89 | with_unnamed_workspace = pkgs.writeShellApplication { | 88 | with_unnamed_workspace = pkgs.writeShellApplication { |
90 | name = "with-unnamed-workspace"; | 89 | name = "with-unnamed-workspace"; |
@@ -171,6 +170,17 @@ in { | |||
171 | type = lib.types.nullOr lib.types.str; | 170 | type = lib.types.nullOr lib.types.str; |
172 | default = null; | 171 | default = null; |
173 | }; | 172 | }; |
173 | moveKey = lib.mkOption { | ||
174 | type = lib.types.nullOr lib.types.str; | ||
175 | default = let | ||
176 | keys = lib.splitString "+" config.key; | ||
177 | defMoveKey = lib.concatStringsSep "+" (lib.flatten [ | ||
178 | (lib.take (lib.length keys - 1) keys) | ||
179 | ["Shift"] | ||
180 | (lib.takeEnd 1 keys) | ||
181 | ]); | ||
182 | in if config.key == null then null else defMoveKey; | ||
183 | }; | ||
174 | spawn = lib.mkOption { | 184 | spawn = lib.mkOption { |
175 | type = lib.types.nullOr (lib.types.listOf lib.types.str); | 185 | type = lib.types.nullOr (lib.types.listOf lib.types.str); |
176 | default = null; | 186 | default = null; |
@@ -851,7 +861,7 @@ in { | |||
851 | "Mod+Shift+Asterisk".action = kdl.magic-leaf "move-column-to-workspace" "vid"; | 861 | "Mod+Shift+Asterisk".action = kdl.magic-leaf "move-column-to-workspace" "vid"; |
852 | 862 | ||
853 | "Mod+Plus".action = with-unnamed-workspace-action ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; | 863 | "Mod+Plus".action = with-unnamed-workspace-action ''{"Action":{"FocusWorkspace":{"reference":{"Id": .id}}}}''; |
854 | "Mod+Shift+Plus".action = with-unnamed-workspace-action ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}}}}''; | 864 | "Mod+Shift+Plus".action = with-unnamed-workspace-action ''{"Action":{"MoveColumnToWorkspace":{"reference":{"Id": .id}, "focus": true}}}''; |
855 | 865 | ||
856 | "Mod+M".action = consume-or-expel-window-left; | 866 | "Mod+M".action = consume-or-expel-window-left; |
857 | "Mod+W".action = consume-or-expel-window-right; | 867 | "Mod+W".action = consume-or-expel-window-right; |
@@ -923,13 +933,14 @@ in { | |||
923 | "Mod+Comma".action = spawn makoctl "restore"; | 933 | "Mod+Comma".action = spawn makoctl "restore"; |
924 | 934 | ||
925 | "Mod+Control+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"FocusWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; | 935 | "Mod+Control+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"FocusWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; |
926 | "Mod+Control+Shift+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"MoveColumnToWorkspace\":{\"reference\":{\"Id\": $workspace_id}}}}"; | 936 | "Mod+Control+Shift+W".action = with-empty-unnamed-workspace-action "{\"Action\":{\"MoveColumnToWorkspace\":{\"reference\":{\"Id\": $workspace_id}, \"focus\": true}}}"; |
927 | 937 | ||
928 | "Mod+X".action = set-dynamic-cast-window; | 938 | "Mod+X".action = set-dynamic-cast-window; |
929 | "Mod+Shift+X".action = set-dynamic-cast-monitor; | 939 | "Mod+Shift+X".action = set-dynamic-cast-monitor; |
930 | "Mod+Control+Shift+X".action = clear-dynamic-cast-target; | 940 | "Mod+Control+Shift+X".action = clear-dynamic-cast-target; |
931 | })) | 941 | })) |
932 | (map ({ name, selector, spawn, key, ...}: if key != null && selector != null && spawn != null then bind key { action = focus-or-spawn-action selector name spawn; } else null) cfg.scratchspaces) | 942 | (map ({ name, selector, spawn, key, ...}: if key != null && selector != null && spawn != null then bind key { action = focus-or-spawn-action selector name spawn; } else null) cfg.scratchspaces) |
943 | (map ({ name, moveKey, ...}: if moveKey != null then bind moveKey { action = kdl.magic-leaf "move-column-to-workspace" name; } else null) cfg.scratchspaces) | ||
933 | ] | 944 | ] |
934 | )) | 945 | )) |
935 | ]; | 946 | ]; |
diff --git a/accounts/gkleen@sif/niri/mako.nix b/accounts/gkleen@sif/niri/mako.nix index 274441ab..810bff89 100644 --- a/accounts/gkleen@sif/niri/mako.nix +++ b/accounts/gkleen@sif/niri/mako.nix | |||
@@ -21,6 +21,7 @@ | |||
21 | "urgency=critical".background-color = "#900000dd"; | 21 | "urgency=critical".background-color = "#900000dd"; |
22 | "app-name=Element".group-by = "summary"; | 22 | "app-name=Element".group-by = "summary"; |
23 | "app-name=poweralertd" = { | 23 | "app-name=poweralertd" = { |
24 | history = false; | ||
24 | ignore-timeout = true; | 25 | ignore-timeout = true; |
25 | default-timeout = 2000; | 26 | default-timeout = 2000; |
26 | }; | 27 | }; |
diff --git a/accounts/gkleen@sif/utils/async-yt-dlp.nix b/accounts/gkleen@sif/utils/async-yt-dlp.nix new file mode 100644 index 00000000..c3b82ec5 --- /dev/null +++ b/accounts/gkleen@sif/utils/async-yt-dlp.nix | |||
@@ -0,0 +1,57 @@ | |||
1 | { writers, python3Packages, ... }: | ||
2 | |||
3 | writers.writePython3Bin "async-yt-dlp" { | ||
4 | libraries = with python3Packages; [ yt-dlp ]; | ||
5 | flakeIgnore = ["E501"]; | ||
6 | } '' | ||
7 | import sys | ||
8 | import os | ||
9 | |||
10 | import yt_dlp | ||
11 | import yt_dlp.options | ||
12 | from collections import namedtuple | ||
13 | import socket | ||
14 | from pathlib import Path | ||
15 | import json | ||
16 | |||
17 | create_parser = yt_dlp.options.create_parser | ||
18 | |||
19 | |||
20 | def parse_patched_options(opts): | ||
21 | patched_parser = create_parser() | ||
22 | patched_parser.defaults.update({ | ||
23 | 'ignoreerrors': False, | ||
24 | 'retries': 0, | ||
25 | 'fragment_retries': 0, | ||
26 | 'extract_flat': False, | ||
27 | 'concat_playlist': 'never', | ||
28 | }) | ||
29 | yt_dlp.options.create_parser = lambda: patched_parser | ||
30 | try: | ||
31 | return yt_dlp.parse_options(opts) | ||
32 | finally: | ||
33 | yt_dlp.options.create_parser = create_parser | ||
34 | |||
35 | |||
36 | default_opts = parse_patched_options([]).ydl_opts | ||
37 | |||
38 | |||
39 | def cli_to_api(opts): | ||
40 | opts = parse_patched_options(opts) | ||
41 | urls = opts.urls | ||
42 | opts = opts.ydl_opts | ||
43 | |||
44 | diff = {k: v for k, v in opts.items() if default_opts[k] != v} | ||
45 | if 'postprocessors' in diff: | ||
46 | diff['postprocessors'] = [pp for pp in diff['postprocessors'] | ||
47 | if pp not in default_opts['postprocessors']] | ||
48 | return namedtuple('Options', ('params', 'urls'))(diff, urls) | ||
49 | |||
50 | |||
51 | if __name__ == '__main__': | ||
52 | opts = cli_to_api(sys.argv[1:]) | ||
53 | with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock: | ||
54 | sock.connect(str(Path(os.environ["XDG_RUNTIME_DIR"]) / "yt-dlp.sock").encode('utf-8')) | ||
55 | with sock.makefile(mode='w', buffering=1, encoding='utf-8') as fh: | ||
56 | json.dump(opts._asdict(), fh) | ||
57 | '' | ||