mirror of
https://github.com/EdenQwQ/nixos.git
synced 2025-12-26 10:14:58 +08:00
swhkd: add a lib function mkSwhkdrc; move lib to home
This commit is contained in:
parent
f7bc7da5fb
commit
bf6d8df123
17 changed files with 157 additions and 124 deletions
|
|
@ -6,6 +6,7 @@
|
|||
}:
|
||||
{
|
||||
imports = [
|
||||
./lib
|
||||
./programs
|
||||
./tweaks
|
||||
];
|
||||
|
|
|
|||
8
home/lib/default.nix
Normal file
8
home/lib/default.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
imports = [
|
||||
./colorScheme
|
||||
./wallpaper
|
||||
./monitors.nix
|
||||
./swhkd.nix
|
||||
];
|
||||
}
|
||||
53
home/lib/swhkd.nix
Normal file
53
home/lib/swhkd.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
let
|
||||
mkKeyBinding =
|
||||
{
|
||||
key,
|
||||
command,
|
||||
onRelease ? false,
|
||||
swallow ? true,
|
||||
}:
|
||||
let
|
||||
onReleasePrefix = if onRelease then "@" else "";
|
||||
swallowPrefix = if swallow then "" else "~";
|
||||
in
|
||||
''
|
||||
${onReleasePrefix}${swallowPrefix}${key}
|
||||
${command}'';
|
||||
mkMode =
|
||||
{
|
||||
name,
|
||||
swallow ? true,
|
||||
oneoff ? false,
|
||||
keyBindings,
|
||||
}:
|
||||
let
|
||||
swallowStr = if swallow then "swallow" else "";
|
||||
oneoffStr = if oneoff then "oneoff" else "";
|
||||
in
|
||||
''
|
||||
mode ${name} ${swallowStr} ${oneoffStr}
|
||||
''
|
||||
+ (map mkKeyBinding keyBindings |> builtins.concatStringsSep "\n")
|
||||
+ ''
|
||||
\nendmode
|
||||
'';
|
||||
mkSwhkdrc =
|
||||
{
|
||||
keyBindings,
|
||||
includes ? [ ],
|
||||
ignores ? [ ],
|
||||
modes ? [ ],
|
||||
extraConfig ? '''',
|
||||
}:
|
||||
(
|
||||
(map (file: "include ${file}") includes)
|
||||
++ (map (key: "ignore ${key}") ignores)
|
||||
++ (map mkKeyBinding keyBindings)
|
||||
++ (map mkMode modes)
|
||||
|> builtins.concatStringsSep "\n"
|
||||
)
|
||||
+ extraConfig;
|
||||
in
|
||||
{
|
||||
config.lib.swhkd = { inherit mkSwhkdrc; };
|
||||
}
|
||||
|
|
@ -1,88 +1,48 @@
|
|||
{ user, ... }:
|
||||
{ user, config, ... }:
|
||||
{
|
||||
xdg.configFile."niri/swhkd/niri.swhkdrc".text = ''
|
||||
include /home/${user}/.config/swhkd/basic.swhkdrc
|
||||
include /home/${user}/.config/swhkd/tofi.swhkdrc
|
||||
|
||||
super + shift + w
|
||||
/home/${user}/scripts/change-wal-niri
|
||||
|
||||
super + q
|
||||
niri msg action close-window
|
||||
|
||||
super + e
|
||||
niri msg action expand-column-to-available-width
|
||||
|
||||
super + t
|
||||
niri msg action toggle-column-tabbed-display
|
||||
|
||||
super + {left, down, up, right}
|
||||
niri msg action focus-column-{left, down, up, right}
|
||||
|
||||
super + {h, l}
|
||||
niri msg action focus-column-or-monitor-{left, right}
|
||||
|
||||
super + {j, k}
|
||||
niri msg action focus-window-or-workspace-{down, up}
|
||||
|
||||
super + shift + h
|
||||
niri msg action move-column-left-or-to-monitor-left
|
||||
|
||||
super + shift + l
|
||||
niri msg action move-column-right-or-to-monitor-right
|
||||
|
||||
super + shift + j
|
||||
niri msg action move-window-down-or-to-workspace-down
|
||||
|
||||
super + shift + k
|
||||
niri msg action move-window-up-or-to-workspace-up
|
||||
|
||||
super + ctrl + {left, down, up, right}
|
||||
niri msg action focus-monitor-{left, down, up, right}
|
||||
|
||||
super + ctrl + {h, j, k, l}
|
||||
niri msg action focus-monitor-{left, down, up, right}
|
||||
|
||||
super + shift + ctrl + {left, down, up, right}
|
||||
niri msg action move-window-to-monitor-{left, down, up, right}
|
||||
|
||||
super + shift + ctrl + {h, j, k, l}
|
||||
niri msg action move-window-to-monitor-{left, down, up, right}
|
||||
|
||||
super + shift + space
|
||||
niri msg action toggle-window-floating
|
||||
|
||||
super + space
|
||||
niri msg action switch-focus-between-floating-and-tiling
|
||||
|
||||
super + {_, shift +} {1-9}
|
||||
niri msg action {focus\-workspace, move\-window\-to\-workspace} {1-9}
|
||||
|
||||
super + comma
|
||||
niri msg action consume-window-into-column
|
||||
|
||||
super + period
|
||||
niri msg action expel-window-from-column
|
||||
|
||||
super + r
|
||||
niri msg action switch-preset-column-width
|
||||
|
||||
super + f
|
||||
niri msg action maximize-column
|
||||
|
||||
super + shift + f
|
||||
niri msg action fullscreen-window
|
||||
|
||||
super + c
|
||||
niri msg action center-column
|
||||
|
||||
super + {_, shift +} {minus, equal}
|
||||
niri msg action set-{column\-width, window\-height} "{\-, +}10%"
|
||||
|
||||
{ctrl +, alt +} print
|
||||
niri msg action screenshot-{screen, window}
|
||||
|
||||
print
|
||||
niri msg action screenshot
|
||||
'';
|
||||
xdg.configFile."niri/swhkd/niri.swhkdrc".text = config.lib.swhkd.mkSwhkdrc {
|
||||
includes = [
|
||||
"/home/${user}/.config/swhkd/basic.swhkdrc"
|
||||
"/home/${user}/.config/swhkd/tofi.swhkdrc"
|
||||
];
|
||||
keyBindings =
|
||||
let
|
||||
niriAction = key: action: {
|
||||
inherit key;
|
||||
command = "niri msg action ${action}";
|
||||
};
|
||||
in
|
||||
[
|
||||
{
|
||||
key = "super + shift + w";
|
||||
command = "/home/${user}/scripts/change-wal-niri";
|
||||
}
|
||||
(niriAction "super + q" "close-window")
|
||||
(niriAction "super + e" "expand-column-to-available-width")
|
||||
(niriAction "super + t" "toggle-column-tabbed-display")
|
||||
(niriAction "super + {left, down, up, right}" "focus-column-{left, down, up, right}")
|
||||
(niriAction "super + {h, l}" "focus-column-or-monitor-{left, right}")
|
||||
(niriAction "super + {j, k}" "focus-window-or-workspace-{down, up}")
|
||||
(niriAction "super + shift + h" "move-column-left-or-to-monitor-left")
|
||||
(niriAction "super + shift + l" "move-column-right-or-to-monitor-right")
|
||||
(niriAction "super + shift + j" "move-window-down-or-to-workspace-down")
|
||||
(niriAction "super + shift + k" "move-window-up-or-to-workspace-up")
|
||||
(niriAction "super + ctrl + {left, down, up, right}" "focus-monitor-{left, down, up, right}")
|
||||
(niriAction "super + ctrl + {h, j, k, l}" "focus-monitor-{left, down, up, right}")
|
||||
(niriAction "super + shift + ctrl + {left, down, up, right}" "move-window-to-monitor-{left, down, up, right}")
|
||||
(niriAction "super + shift + ctrl + {h, j, k, l}" "move-window-to-monitor-{left, down, up, right}")
|
||||
(niriAction "super + shift + space" "toggle-window-floating")
|
||||
(niriAction "super + space" "switch-focus-between-floating-and-tiling")
|
||||
(niriAction "super + {_, shift +} {1-9}" "{focus-workspace, move-window-to-workspace} {1-9}")
|
||||
(niriAction "super + comma" "consume-window-into-column")
|
||||
(niriAction "super + period" "expel-window-from-column")
|
||||
(niriAction "super + r" "switch-preset-column-width")
|
||||
(niriAction "super + f" "maximize-column")
|
||||
(niriAction "super + shift + f" "fullscreen-window")
|
||||
(niriAction "super + c" "center-column")
|
||||
(niriAction "super + {_, shift +} {minus, equal}" "set-{column-width, window-height} \"{\\-, +}10%\"")
|
||||
(niriAction "{ctrl +, alt +} print" "screenshot-{screen, window}")
|
||||
(niriAction "print" "screenshot")
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,8 +130,6 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
imports = [ ../../../../lib/monitors.nix ];
|
||||
|
||||
programs.waybar = {
|
||||
enable = true;
|
||||
systemd = {
|
||||
|
|
|
|||
|
|
@ -1,36 +1,51 @@
|
|||
{ user, ... }:
|
||||
{ user, config, ... }:
|
||||
{
|
||||
|
||||
xdg.configFile."swhkd/basic.swhkdrc".text = ''
|
||||
super + shift + r
|
||||
pkill -HUP swhkd
|
||||
|
||||
super + alt + c
|
||||
wl-color-picker
|
||||
|
||||
super + b
|
||||
pkill -USR1 .waybar-wrapped
|
||||
|
||||
XF86AudioMute
|
||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
|
||||
|
||||
XF86AudioMicMute
|
||||
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
|
||||
|
||||
XF86AudioRaiseVolume
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+
|
||||
|
||||
XF86AudioLowerVolume
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-
|
||||
'';
|
||||
xdg.configFile."swhkd/tofi.swhkdrc".text = ''
|
||||
super + x
|
||||
/home/${user}/scripts/tofi/powermenu
|
||||
|
||||
super + shift + c
|
||||
/home/${user}/scripts/tofi/colorscheme
|
||||
|
||||
super + {_, shift +} p
|
||||
sh -c $(tofi-{run, drun})
|
||||
'';
|
||||
xdg.configFile."swhkd/basic.swhkdrc".text = config.lib.swhkd.mkSwhkdrc {
|
||||
keyBindings = [
|
||||
{
|
||||
key = "super + shift + r";
|
||||
command = "pkill -HUP swhkd";
|
||||
}
|
||||
{
|
||||
key = "super + alt + c";
|
||||
command = "wl-color-picker";
|
||||
}
|
||||
{
|
||||
key = "super + b";
|
||||
command = "pkill -USR1 .waybar-wrapped";
|
||||
}
|
||||
{
|
||||
key = "XF86AudioMute";
|
||||
command = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
|
||||
}
|
||||
{
|
||||
key = "XF86AudioMicMute";
|
||||
command = "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
|
||||
}
|
||||
{
|
||||
key = "XF86AudioRaiseVolume";
|
||||
command = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+";
|
||||
}
|
||||
{
|
||||
key = "XF86AudioLowerVolume";
|
||||
command = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-";
|
||||
}
|
||||
];
|
||||
};
|
||||
xdg.configFile."swhkd/tofi.swhkdrc".text = config.lib.swhkd.mkSwhkdrc {
|
||||
keyBindings = [
|
||||
{
|
||||
key = "super + x";
|
||||
command = "/home/${user}/scripts/tofi/powermenu";
|
||||
}
|
||||
{
|
||||
key = "super + shift + c";
|
||||
command = "/home/${user}/scripts/tofi/colorscheme";
|
||||
}
|
||||
{
|
||||
key = "super + {_, shift +} p";
|
||||
command = "sh -c $(tofi-{run, drun})";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ let
|
|||
../home
|
||||
../nix/nixpkgs.nix
|
||||
../sharedConfig.nix
|
||||
../lib/colorScheme
|
||||
../lib/wallpaper
|
||||
inputs.nur.modules.homeManager.default
|
||||
inputs.stylix.homeManagerModules.stylix
|
||||
inputs.niri.homeModules.niri
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue