mirror of
https://github.com/EdenQwQ/nixos.git
synced 2026-07-16 22:16:51 +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 = [
|
imports = [
|
||||||
|
./lib
|
||||||
./programs
|
./programs
|
||||||
./tweaks
|
./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 = ''
|
xdg.configFile."niri/swhkd/niri.swhkdrc".text = config.lib.swhkd.mkSwhkdrc {
|
||||||
include /home/${user}/.config/swhkd/basic.swhkdrc
|
includes = [
|
||||||
include /home/${user}/.config/swhkd/tofi.swhkdrc
|
"/home/${user}/.config/swhkd/basic.swhkdrc"
|
||||||
|
"/home/${user}/.config/swhkd/tofi.swhkdrc"
|
||||||
super + shift + w
|
];
|
||||||
/home/${user}/scripts/change-wal-niri
|
keyBindings =
|
||||||
|
let
|
||||||
super + q
|
niriAction = key: action: {
|
||||||
niri msg action close-window
|
inherit key;
|
||||||
|
command = "niri msg action ${action}";
|
||||||
super + e
|
};
|
||||||
niri msg action expand-column-to-available-width
|
in
|
||||||
|
[
|
||||||
super + t
|
{
|
||||||
niri msg action toggle-column-tabbed-display
|
key = "super + shift + w";
|
||||||
|
command = "/home/${user}/scripts/change-wal-niri";
|
||||||
super + {left, down, up, right}
|
}
|
||||||
niri msg action focus-column-{left, down, up, right}
|
(niriAction "super + q" "close-window")
|
||||||
|
(niriAction "super + e" "expand-column-to-available-width")
|
||||||
super + {h, l}
|
(niriAction "super + t" "toggle-column-tabbed-display")
|
||||||
niri msg action focus-column-or-monitor-{left, right}
|
(niriAction "super + {left, down, up, right}" "focus-column-{left, down, up, right}")
|
||||||
|
(niriAction "super + {h, l}" "focus-column-or-monitor-{left, right}")
|
||||||
super + {j, k}
|
(niriAction "super + {j, k}" "focus-window-or-workspace-{down, up}")
|
||||||
niri msg action 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")
|
||||||
super + shift + h
|
(niriAction "super + shift + j" "move-window-down-or-to-workspace-down")
|
||||||
niri msg action move-column-left-or-to-monitor-left
|
(niriAction "super + shift + k" "move-window-up-or-to-workspace-up")
|
||||||
|
(niriAction "super + ctrl + {left, down, up, right}" "focus-monitor-{left, down, up, right}")
|
||||||
super + shift + l
|
(niriAction "super + ctrl + {h, j, k, l}" "focus-monitor-{left, down, up, right}")
|
||||||
niri msg action move-column-right-or-to-monitor-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}")
|
||||||
super + shift + j
|
(niriAction "super + shift + space" "toggle-window-floating")
|
||||||
niri msg action move-window-down-or-to-workspace-down
|
(niriAction "super + space" "switch-focus-between-floating-and-tiling")
|
||||||
|
(niriAction "super + {_, shift +} {1-9}" "{focus-workspace, move-window-to-workspace} {1-9}")
|
||||||
super + shift + k
|
(niriAction "super + comma" "consume-window-into-column")
|
||||||
niri msg action move-window-up-or-to-workspace-up
|
(niriAction "super + period" "expel-window-from-column")
|
||||||
|
(niriAction "super + r" "switch-preset-column-width")
|
||||||
super + ctrl + {left, down, up, right}
|
(niriAction "super + f" "maximize-column")
|
||||||
niri msg action focus-monitor-{left, down, up, right}
|
(niriAction "super + shift + f" "fullscreen-window")
|
||||||
|
(niriAction "super + c" "center-column")
|
||||||
super + ctrl + {h, j, k, l}
|
(niriAction "super + {_, shift +} {minus, equal}" "set-{column-width, window-height} \"{\\-, +}10%\"")
|
||||||
niri msg action focus-monitor-{left, down, up, right}
|
(niriAction "{ctrl +, alt +} print" "screenshot-{screen, window}")
|
||||||
|
(niriAction "print" "screenshot")
|
||||||
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
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,8 +130,6 @@ let
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ ../../../../lib/monitors.nix ];
|
|
||||||
|
|
||||||
programs.waybar = {
|
programs.waybar = {
|
||||||
enable = true;
|
enable = true;
|
||||||
systemd = {
|
systemd = {
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,51 @@
|
||||||
{ user, ... }:
|
{ user, config, ... }:
|
||||||
{
|
{
|
||||||
|
xdg.configFile."swhkd/basic.swhkdrc".text = config.lib.swhkd.mkSwhkdrc {
|
||||||
xdg.configFile."swhkd/basic.swhkdrc".text = ''
|
keyBindings = [
|
||||||
super + shift + r
|
{
|
||||||
pkill -HUP swhkd
|
key = "super + shift + r";
|
||||||
|
command = "pkill -HUP swhkd";
|
||||||
super + alt + c
|
}
|
||||||
wl-color-picker
|
{
|
||||||
|
key = "super + alt + c";
|
||||||
super + b
|
command = "wl-color-picker";
|
||||||
pkill -USR1 .waybar-wrapped
|
}
|
||||||
|
{
|
||||||
XF86AudioMute
|
key = "super + b";
|
||||||
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
|
command = "pkill -USR1 .waybar-wrapped";
|
||||||
|
}
|
||||||
XF86AudioMicMute
|
{
|
||||||
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
|
key = "XF86AudioMute";
|
||||||
|
command = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
|
||||||
XF86AudioRaiseVolume
|
}
|
||||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+
|
{
|
||||||
|
key = "XF86AudioMicMute";
|
||||||
XF86AudioLowerVolume
|
command = "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
|
||||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-
|
}
|
||||||
'';
|
{
|
||||||
xdg.configFile."swhkd/tofi.swhkdrc".text = ''
|
key = "XF86AudioRaiseVolume";
|
||||||
super + x
|
command = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+";
|
||||||
/home/${user}/scripts/tofi/powermenu
|
}
|
||||||
|
{
|
||||||
super + shift + c
|
key = "XF86AudioLowerVolume";
|
||||||
/home/${user}/scripts/tofi/colorscheme
|
command = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-";
|
||||||
|
}
|
||||||
super + {_, shift +} p
|
];
|
||||||
sh -c $(tofi-{run, drun})
|
};
|
||||||
'';
|
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
|
../home
|
||||||
../nix/nixpkgs.nix
|
../nix/nixpkgs.nix
|
||||||
../sharedConfig.nix
|
../sharedConfig.nix
|
||||||
../lib/colorScheme
|
|
||||||
../lib/wallpaper
|
|
||||||
inputs.nur.modules.homeManager.default
|
inputs.nur.modules.homeManager.default
|
||||||
inputs.stylix.homeManagerModules.stylix
|
inputs.stylix.homeManagerModules.stylix
|
||||||
inputs.niri.homeModules.niri
|
inputs.niri.homeModules.niri
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue