mirror of
https://github.com/nmasur/dotfiles
synced 2024-12-27 13:24:53 +00:00
move keybinds to sxhkd
This commit is contained in:
parent
cc0325b431
commit
f16ef49792
@ -11,23 +11,10 @@
|
||||
|
||||
config = lib.mkIf (config.gui.enable && config.kitty.enable) {
|
||||
|
||||
# Set the Rofi-Systemd terminal for viewing logs
|
||||
# Using optionalAttrs because only available in NixOS
|
||||
environment = { } // lib.attrsets.optionalAttrs
|
||||
(builtins.hasAttr "sessionVariables" config.environment) {
|
||||
sessionVariables.ROFI_SYSTEMD_TERM = "${pkgs.kitty}/bin/kitty";
|
||||
};
|
||||
terminal = "${pkgs.kitty}/bin/kitty";
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
# Set the i3 terminal
|
||||
xsession.windowManager.i3.config.terminal =
|
||||
lib.mkIf pkgs.stdenv.isLinux "kitty";
|
||||
|
||||
# Set the Rofi terminal for running programs
|
||||
programs.rofi.terminal =
|
||||
lib.mkIf pkgs.stdenv.isLinux "${pkgs.kitty}/bin/kitty";
|
||||
|
||||
# Display images in the terminal
|
||||
programs.fish.shellAliases = {
|
||||
icat = "kitty +kitten icat";
|
||||
|
@ -13,14 +13,6 @@
|
||||
|
||||
options = {
|
||||
|
||||
launcherCommand = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Command to use for launching";
|
||||
};
|
||||
systemdSearch = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Command to use for interacting with systemd";
|
||||
};
|
||||
altTabCommand = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Command to use for choosing windows";
|
||||
@ -37,14 +29,30 @@
|
||||
type = lib.types.str;
|
||||
description = "Command to use for quick calculations";
|
||||
};
|
||||
toggleBarCommand = lib.mkOption {
|
||||
launcherCommand = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Command to hide and show the status bar.";
|
||||
description = "Command to use for launching";
|
||||
};
|
||||
lockScreenCommand = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Command to use to lock the screen";
|
||||
};
|
||||
powerCommand = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Command to use for power options menu";
|
||||
};
|
||||
systemdSearch = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Command to use for interacting with systemd";
|
||||
};
|
||||
terminal = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Package to use for graphical terminal";
|
||||
};
|
||||
toggleBarCommand = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Command to hide and show the status bar.";
|
||||
};
|
||||
wallpaper = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Wallpaper background image file";
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
let
|
||||
|
||||
lockCmd =
|
||||
"${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span";
|
||||
lockUpdate =
|
||||
"${pkgs.betterlockscreen}/bin/betterlockscreen --update ${config.wallpaper} --display 1 --span";
|
||||
|
||||
@ -29,12 +27,6 @@ in {
|
||||
ws2 = "2:II";
|
||||
ws3 = "3:III";
|
||||
ws4 = "4:IV";
|
||||
ws5 = "5:V";
|
||||
ws6 = "6:VI";
|
||||
ws7 = "7:VII";
|
||||
ws8 = "8:VIII";
|
||||
ws9 = "9:IX";
|
||||
ws10 = "10:X";
|
||||
in {
|
||||
modifier = modifier;
|
||||
assigns = {
|
||||
@ -92,118 +84,6 @@ in {
|
||||
followMouse = false;
|
||||
};
|
||||
keybindings = {
|
||||
|
||||
# Adjust screen brightness
|
||||
"Shift+F12" =
|
||||
"exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30";
|
||||
"Shift+F11" =
|
||||
"exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30";
|
||||
"XF86MonBrightnessUp" =
|
||||
"exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 + 30";
|
||||
"XF86MonBrightnessDown" =
|
||||
"exec ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 - 30";
|
||||
|
||||
# Media player controls
|
||||
"XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
|
||||
"XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop";
|
||||
"XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next";
|
||||
"XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous";
|
||||
|
||||
# Launchers
|
||||
"${modifier}+Return" =
|
||||
"exec --no-startup-id kitty; workspace ${ws2}; layout tabbed";
|
||||
"${modifier}+space" =
|
||||
"exec --no-startup-id ${config.launcherCommand}";
|
||||
"${modifier}+Shift+s" =
|
||||
"exec --no-startup-id ${config.systemdSearch}";
|
||||
"${modifier}+Shift+a" =
|
||||
"exec --no-startup-id ${config.audioSwitchCommand}";
|
||||
"Mod1+Tab" = "exec --no-startup-id ${config.altTabCommand}";
|
||||
"${modifier}+Shift+period" =
|
||||
"exec --no-startup-id ${config.powerCommand}";
|
||||
"${modifier}+Shift+m" =
|
||||
"exec --no-startup-id ${config.brightnessCommand}";
|
||||
"${modifier}+c" =
|
||||
"exec --no-startup-id ${config.calculatorCommand}";
|
||||
"${modifier}+Shift+c" = "reload";
|
||||
"${modifier}+Shift+r" = "restart";
|
||||
"${modifier}+Shift+q" = ''
|
||||
exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"'';
|
||||
"${modifier}+Shift+x" = "exec ${lockCmd}";
|
||||
"${modifier}+Mod1+h" =
|
||||
"exec --no-startup-id kitty sh -c '${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
|
||||
"${modifier}+Mod1+r" =
|
||||
"exec --no-startup-id kitty sh -c 'doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
|
||||
|
||||
# Window options
|
||||
"${modifier}+q" = "kill";
|
||||
"${modifier}+b" = "exec ${config.toggleBarCommand}";
|
||||
"${modifier}+f" = "fullscreen toggle";
|
||||
"${modifier}+h" = "focus left";
|
||||
"${modifier}+j" = "focus down";
|
||||
"${modifier}+k" = "focus up";
|
||||
"${modifier}+l" = "focus right";
|
||||
"${modifier}+Left" = "focus left";
|
||||
"${modifier}+Down" = "focus down";
|
||||
"${modifier}+Up" = "focus up";
|
||||
"${modifier}+Right" = "focus right";
|
||||
"${modifier}+Shift+h" = "move left";
|
||||
"${modifier}+Shift+j" = "move down";
|
||||
"${modifier}+Shift+k" = "move up";
|
||||
"${modifier}+Shift+l" = "move right";
|
||||
"${modifier}+Shift+Left" = "move left";
|
||||
"${modifier}+Shift+Down" = "move down";
|
||||
"${modifier}+Shift+Up" = "move up";
|
||||
"${modifier}+Shift+Right" = "move right";
|
||||
|
||||
# Tiling
|
||||
"${modifier}+i" = "split h";
|
||||
"${modifier}+v" = "split v";
|
||||
"${modifier}+s" = "layout stacking";
|
||||
"${modifier}+t" = "layout tabbed";
|
||||
"${modifier}+e" = "layout toggle split";
|
||||
"${modifier}+Shift+space" = "floating toggle";
|
||||
"${modifier}+Control+space" = "focus mode_toggle";
|
||||
"${modifier}+a" = "focus parent";
|
||||
|
||||
# Workspaces
|
||||
"${modifier}+1" = "workspace ${ws1}";
|
||||
"${modifier}+2" = "workspace ${ws2}";
|
||||
"${modifier}+3" = "workspace ${ws3}";
|
||||
"${modifier}+4" = "workspace ${ws4}";
|
||||
"${modifier}+5" = "workspace ${ws5}";
|
||||
"${modifier}+6" = "workspace ${ws6}";
|
||||
"${modifier}+7" = "workspace ${ws7}";
|
||||
"${modifier}+8" = "workspace ${ws8}";
|
||||
"${modifier}+9" = "workspace ${ws9}";
|
||||
"${modifier}+0" = "workspace ${ws10}";
|
||||
|
||||
# Move windows
|
||||
"${modifier}+Shift+1" =
|
||||
"move container to workspace ${ws1}; workspace ${ws1}";
|
||||
"${modifier}+Shift+2" =
|
||||
"move container to workspace ${ws2}; workspace ${ws2}";
|
||||
"${modifier}+Shift+3" =
|
||||
"move container to workspace ${ws3}; workspace ${ws3}";
|
||||
"${modifier}+Shift+4" =
|
||||
"move container to workspace ${ws4}; workspace ${ws4}";
|
||||
"${modifier}+Shift+5" =
|
||||
"move container to workspace ${ws5}; workspace ${ws5}";
|
||||
"${modifier}+Shift+6" =
|
||||
"move container to workspace ${ws6}; workspace ${ws6}";
|
||||
"${modifier}+Shift+7" =
|
||||
"move container to workspace ${ws7}; workspace ${ws7}";
|
||||
"${modifier}+Shift+8" =
|
||||
"move container to workspace ${ws8}; workspace ${ws8}";
|
||||
"${modifier}+Shift+9" =
|
||||
"move container to workspace ${ws9}; workspace ${ws9}";
|
||||
"${modifier}+Shift+0" =
|
||||
"move container to workspace ${ws10}; workspace ${ws10}";
|
||||
|
||||
# Move screens
|
||||
"${modifier}+Control+l" = "move workspace to output right";
|
||||
"${modifier}+Control+h" = "move workspace to output left";
|
||||
|
||||
# Resizing
|
||||
"${modifier}+r" = ''mode "resize"'';
|
||||
"${modifier}+Control+Shift+h" =
|
||||
@ -232,6 +112,7 @@ in {
|
||||
notification = false;
|
||||
}
|
||||
];
|
||||
terminal = config.terminal;
|
||||
window = {
|
||||
border = 0;
|
||||
hideEdgeBorders = "smart";
|
||||
@ -239,22 +120,13 @@ in {
|
||||
};
|
||||
workspaceAutoBackAndForth = false;
|
||||
workspaceOutputAssign = [ ];
|
||||
# gaps = {
|
||||
# bottom = 8;
|
||||
# top = 8;
|
||||
# left = 8;
|
||||
# right = 8;
|
||||
# horizontal = 15;
|
||||
# vertical = 15;
|
||||
# inner = 15;
|
||||
# outer = 0;
|
||||
# smartBorders = "off";
|
||||
# smartGaps = false;
|
||||
# };
|
||||
};
|
||||
extraConfig = "";
|
||||
};
|
||||
|
||||
lockScreenCommand =
|
||||
"${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span";
|
||||
|
||||
programs.fish.functions = {
|
||||
update-lock-screen = lib.mkIf config.services.xserver.enable {
|
||||
description = "Update lockscreen with wallpaper";
|
||||
@ -278,14 +150,14 @@ in {
|
||||
# Ref: https://github.com/betterlockscreen/betterlockscreen/blob/next/system/betterlockscreen%40.service
|
||||
systemd.services.lock = {
|
||||
enable = config.services.xserver.enable;
|
||||
description = "Lock the screen on resume from suspend";
|
||||
description = "Lock the screen before suspend";
|
||||
before = [ "sleep.target" "suspend.target" ];
|
||||
serviceConfig = {
|
||||
User = config.user;
|
||||
Type = "simple";
|
||||
Environment = "DISPLAY=:0";
|
||||
TimeoutSec = "infinity";
|
||||
ExecStart = lockCmd;
|
||||
ExecStart = config.lockScreenCommand;
|
||||
ExecStartPost = "${pkgs.coreutils-full}/bin/sleep 1";
|
||||
};
|
||||
wantedBy = [ "sleep.target" "suspend.target" ];
|
||||
|
100
modules/nixos/graphical/keybinds.nix
Normal file
100
modules/nixos/graphical/keybinds.nix
Normal file
@ -0,0 +1,100 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
|
||||
keybindings =
|
||||
config.home-manager.users.${config.user}.programs.sxhkd.keybindings;
|
||||
|
||||
workspaceBindings = let
|
||||
workspaces = {
|
||||
"1" = "1:I";
|
||||
"2" = "2:II";
|
||||
"3" = "3:III";
|
||||
"4" = "4:IV";
|
||||
"5" = "5:V";
|
||||
"6" = "6:VI";
|
||||
"7" = "7:VII";
|
||||
"8" = "8:VIII";
|
||||
"9" = "9:IX";
|
||||
"0" = "10:X";
|
||||
};
|
||||
|
||||
# Create an attrset of keybinds to actions for every workspace by number
|
||||
bindAll = keybindFunction: actionFunction:
|
||||
(lib.genAttrs (map keybindFunction (builtins.attrNames workspaces))
|
||||
actionFunction);
|
||||
|
||||
# Look up the name of the workspace based on its number
|
||||
lookup = num: builtins.getAttr num workspaces;
|
||||
|
||||
in (bindAll (num: "super + ${num}")
|
||||
(num: ''${pkgs.i3}/bin/i3-msg "workspace ${lookup num}"''))
|
||||
// (bindAll (num: "super + shift + ${num}") (num:
|
||||
''
|
||||
${pkgs.i3}/bin/i3-msg "move container to workspace ${
|
||||
lookup num
|
||||
}; workspace ${lookup num}"''));
|
||||
|
||||
in {
|
||||
|
||||
home-manager.users.${config.user}.programs.sxhkd = {
|
||||
enable = true;
|
||||
keybindings = {
|
||||
|
||||
# Adjust screen brightness (TODO: replace with pkgs.light?)
|
||||
"shift + {F11,F12}" = ''
|
||||
${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 {- 30,+ 30} && sleep 1; \\
|
||||
${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 {- 30,+ 30}
|
||||
'';
|
||||
"XF86MonBrightness{Down,Up}" = keybindings."shift + {F11,F12}";
|
||||
|
||||
# Media controls
|
||||
"XF86Audio{Play,Stop,Next,Prev}" =
|
||||
"${pkgs.playerctl}/bin/playerctl {play-pause,stop,next,previous}";
|
||||
|
||||
# Window management
|
||||
"super + q" = ''${pkgs.i3}/bin/i3-msg "kill"'';
|
||||
"super + b" = config.toggleBarCommand;
|
||||
"super + f" = ''${pkgs.i3}/bin/i3-msg "fullscreen toggle"'';
|
||||
"super + {h,j,k,l}" =
|
||||
''${pkgs.i3}/bin/i3-msg "focus {left,down,up,right}"'';
|
||||
"super + {Left,Down,Up,Right}" = keybindings."super + {h,j,k,l}";
|
||||
"super + shift + {h,j,k,l}" =
|
||||
''${pkgs.i3}/bin/i3-msg "move {left,down,up,right}"'';
|
||||
"super + shift + {Left,Down,Up,Right}" =
|
||||
keybindings."super + shift + {h,j,k,l}";
|
||||
|
||||
# Screen management
|
||||
"super + control + l" =
|
||||
''${pkgs.i3}/bin/i3-msg "move workspace to output right"'';
|
||||
"super + control + h" =
|
||||
''${pkgs.i3}/bin/i3-msg "move workspace to output left"'';
|
||||
|
||||
# Window layouts and tiling
|
||||
"super + {i,v}" = ''${pkgs.i3}/bin/i3-msg "split {h,v}"'';
|
||||
"super + {s,t,e}" =
|
||||
''${pkgs.i3}/bin/i3-msg "layout {stacking,tabbed,toggle split}"'';
|
||||
"super + shift + space" = ''${pkgs.i3}/bin/i3-msg "floating toggle"'';
|
||||
"super + control + space" = ''${pkgs.i3}/bin/i3-msg "focus mode_toggle"'';
|
||||
"super + a" = ''${pkgs.i3}/bin/i3-msg "focus parent"'';
|
||||
|
||||
# Launchers
|
||||
"super + Return" = config.terminal;
|
||||
"super + space" = config.launcherCommand;
|
||||
"super + shift + s" = config.systemdSearch;
|
||||
"super + shift + a" = config.audioSwitchCommand;
|
||||
"alt + Tab" = config.altTabCommand;
|
||||
"super + shift + period" = config.powerCommand;
|
||||
"super + shift + m" = config.brightnessCommand;
|
||||
"super + c" = config.calculatorCommand;
|
||||
"super + shift + {c,r}" = ''${pkgs.i3}/bin/i3-msg "{reload,restart}"'';
|
||||
"super + shift + x" = config.lockScreenCommand;
|
||||
"super + alt + h" =
|
||||
"${config.terminal} sh -c '${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
|
||||
"super + alt + r" =
|
||||
"${config.terminal} sh -c 'doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
|
||||
|
||||
} // workspaceBindings;
|
||||
|
||||
};
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) {
|
||||
config = lib.mkIf config.services.xserver.enable {
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
services.picom = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) {
|
||||
config = lib.mkIf config.services.xserver.enable {
|
||||
|
||||
toggleBarCommand = "polybar-msg cmd toggle";
|
||||
|
||||
|
@ -8,11 +8,10 @@ in {
|
||||
|
||||
imports = [ ./rofi/power.nix ./rofi/brightness.nix ];
|
||||
|
||||
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) {
|
||||
config = lib.mkIf config.services.xserver.enable {
|
||||
|
||||
# Set the Rofi-Systemd terminal for viewing logs
|
||||
environment.sessionVariables.ROFI_SYSTEMD_TERM =
|
||||
lib.mkIf config.kitty.enable "${pkgs.kitty}/bin/kitty";
|
||||
environment.sessionVariables.ROFI_SYSTEMD_TERM = config.terminal;
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
@ -24,6 +23,13 @@ in {
|
||||
programs.rofi = {
|
||||
enable = true;
|
||||
cycle = true;
|
||||
extraConfig = {
|
||||
show-icons = true;
|
||||
kb-cancel = "Escape,Super+space";
|
||||
modi = "window,run,ssh,emoji,calc,systemd";
|
||||
sort = true;
|
||||
# levenshtein-sort = true;
|
||||
};
|
||||
location = "center";
|
||||
pass = { };
|
||||
plugins = [ pkgs.rofi-calc pkgs.rofi-emoji pkgs.rofi-systemd ];
|
||||
@ -143,15 +149,9 @@ in {
|
||||
};
|
||||
|
||||
};
|
||||
terminal = config.terminal;
|
||||
xoffset = 0;
|
||||
yoffset = -20;
|
||||
extraConfig = {
|
||||
show-icons = true;
|
||||
kb-cancel = "Escape,Super+space";
|
||||
modi = "window,run,ssh,emoji,calc,systemd";
|
||||
sort = true;
|
||||
# levenshtein-sort = true;
|
||||
};
|
||||
};
|
||||
|
||||
home.file.".local/share/rofi/themes" = {
|
||||
|
0
modules/nixos/graphical/rofi/brightness.nix
Executable file → Normal file
0
modules/nixos/graphical/rofi/brightness.nix
Executable file → Normal file
0
modules/nixos/graphical/rofi/power.nix
Executable file → Normal file
0
modules/nixos/graphical/rofi/power.nix
Executable file → Normal file
@ -1,16 +1,21 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
{ config, lib, ... }: {
|
||||
|
||||
config = lib.mkIf config.gui.enable {
|
||||
|
||||
programs.sway.enable = true;
|
||||
programs.sway = {
|
||||
enable = true;
|
||||
package = null; # Use home-manager Sway instead
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
wayland.windowManager.sway.enable = true;
|
||||
wayland.windowManager.sway.config =
|
||||
config.home-manager.users.${config.user}.xsession.windowManager.i3.config;
|
||||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
config =
|
||||
config.home-manager.users.${config.user}.xsession.windowManager.i3.config;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user