summaryrefslogtreecommitdiff
path: root/accounts
diff options
context:
space:
mode:
Diffstat (limited to 'accounts')
-rw-r--r--accounts/gkleen@sif/default.nix6
-rw-r--r--accounts/gkleen@sif/niri/default.nix35
-rw-r--r--accounts/gkleen@sif/niri/mako.nix1
-rw-r--r--accounts/gkleen@sif/utils/async-yt-dlp.nix57
4 files changed, 94 insertions, 5 deletions
diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix
index e07362fc..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;
@@ -320,6 +323,9 @@ in {
320 "kitty_mod+n" = "detach_window"; 323 "kitty_mod+n" = "detach_window";
321 "kitty_mod+m" = "detach_window ask"; 324 "kitty_mod+m" = "detach_window ask";
322 }; 325 };
326 extraConfig = ''
327 envinclude KITTY_CONF_*
328 '';
323 }; 329 };
324 fuzzel = { 330 fuzzel = {
325 enable = true; 331 enable = true;
diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix
index 924d3843..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;
@@ -711,7 +721,21 @@ in {
711 "Mod+Slash".action = show-hotkey-overlay; 721 "Mod+Slash".action = show-hotkey-overlay;
712 722
713 "Mod+Return".action = spawn terminal; 723 "Mod+Return".action = spawn terminal;
714 "Mod+Shift+Return".action = spawn terminal (lib.getExe config.programs.nushell.package); 724 "Mod+Shift+Return".action =
725 let
726 nushellKitty = pkgs.symlinkJoin {
727 name = "nushell-kitty";
728 paths = [ config.programs.kitty.package ];
729 buildInputs = [ pkgs.makeWrapper ];
730 postBuild = ''
731 wrapProgram $out/bin/kitty \
732 --add-flags "--config ${pkgs.writeText "kitty.conf" ''
733 include $HOME/${config.xdg.configFile."kitty/kitty.conf".target}
734 shell ${lib.getExe config.programs.nushell.package}
735 ''}"
736 '';
737 };
738 in spawn (lib.getExe' nushellKitty "kitty");
715 "Mod+Q".action = close-window; 739 "Mod+Q".action = close-window;
716 "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package); 740 "Mod+O".action = spawn (lib.getExe config.programs.fuzzel.package);
717 "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path"; 741 "Mod+Shift+O".action = spawn (lib.getExe config.programs.fuzzel.package) "--list-executables-in-path";
@@ -837,7 +861,7 @@ in {
837 "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";
838 862
839 "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}}}}'';
840 "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}}}'';
841 865
842 "Mod+M".action = consume-or-expel-window-left; 866 "Mod+M".action = consume-or-expel-window-left;
843 "Mod+W".action = consume-or-expel-window-right; 867 "Mod+W".action = consume-or-expel-window-right;
@@ -909,13 +933,14 @@ in {
909 "Mod+Comma".action = spawn makoctl "restore"; 933 "Mod+Comma".action = spawn makoctl "restore";
910 934
911 "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}}}}";
912 "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}}}";
913 937
914 "Mod+X".action = set-dynamic-cast-window; 938 "Mod+X".action = set-dynamic-cast-window;
915 "Mod+Shift+X".action = set-dynamic-cast-monitor; 939 "Mod+Shift+X".action = set-dynamic-cast-monitor;
916 "Mod+Control+Shift+X".action = clear-dynamic-cast-target; 940 "Mod+Control+Shift+X".action = clear-dynamic-cast-target;
917 })) 941 }))
918 (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)
919 ] 944 ]
920 )) 945 ))
921 ]; 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
3writers.writePython3Bin "async-yt-dlp" {
4 libraries = with python3Packages; [ yt-dlp ];
5 flakeIgnore = ["E501"];
6} ''
7import sys
8import os
9
10import yt_dlp
11import yt_dlp.options
12from collections import namedtuple
13import socket
14from pathlib import Path
15import json
16
17create_parser = yt_dlp.options.create_parser
18
19
20def 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
36default_opts = parse_patched_options([]).ydl_opts
37
38
39def 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
51if __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''