partial success of i3 and sxhkd

This commit is contained in:
Noah Masur 2023-08-09 08:36:07 -04:00
parent 97c94e6b6a
commit 6ea3da93db
4 changed files with 62 additions and 67 deletions

View File

@ -13,7 +13,7 @@
"$cmd_duration" "$cmd_duration"
"$character" "$character"
]; ];
right_format = "$nix_shell"; # right_format = "$nix_shell";
character = { character = {
success_symbol = "[](bold green)"; success_symbol = "[](bold green)";
error_symbol = "[](bold red)"; error_symbol = "[](bold red)";

View File

@ -5,6 +5,7 @@
./fonts.nix ./fonts.nix
./gtk.nix ./gtk.nix
./i3.nix ./i3.nix
./keybinds.nix
./picom.nix ./picom.nix
./polybar.nix ./polybar.nix
./rofi.nix ./rofi.nix

View File

@ -15,7 +15,7 @@ let
"7" = "7:VII"; "7" = "7:VII";
"8" = "8:VIII"; "8" = "8:VIII";
"9" = "9:IX"; "9" = "9:IX";
"0" = "10:X"; "10" = "10:X";
}; };
in { in {
@ -124,30 +124,18 @@ in {
extraConfig = ""; extraConfig = "";
}; };
programs.sxhkd.keybindings = let services.sxhkd.keybindings = let
# Shortcuts # Shortcuts
binds =
config.home-manager.users.${config.user}.programs.sxhkd.keybindings;
i3-msg = "${pkgs.i3}/bin/i3-msg"; i3-msg = "${pkgs.i3}/bin/i3-msg";
# Create an attrset of keybinds to actions for every workspace by number
bindAll = let workspaceNums = builtins.attrNames workspaces;
in keybindFunction: actionFunction:
# 1 -> "keybind + 1" -> "some action on ws 1"
lib.genAttrs (map keybindFunction workspaceNums) actionFunction;
# Look up the name of the workspace based on its number
lookup = num: builtins.getAttr num workspaces;
in { in {
# Window navigation # Window navigation
"super + {h,j,k,l}" = ''${i3-msg} "focus {left,down,up,right}"''; "super + {_,shift +}{h,j,k,l}" =
"super + {Left,Down,Up,Right}" = binds."super + {h,j,k,l}"; ''${i3-msg} "{focus,move} {left,down,up,right}"'';
"super + shift + {h,j,k,l}" = ''${i3-msg} "move {left,down,up,right}"''; "super + {_,shift +}{Left,Down,Up,Right}" =
"super + shift + {Left,Down,Up,Right}" = ''${i3-msg} "{focus,move} {left,down,up,right}"'';
binds."super + shift + {h,j,k,l}";
"super + q" = ''${i3-msg} "kill"''; "super + q" = ''${i3-msg} "kill"'';
"super + f" = ''${i3-msg} "fullscreen toggle"''; "super + f" = ''${i3-msg} "fullscreen toggle"'';
@ -166,21 +154,17 @@ in {
# Restart and reload # Restart and reload
"super + shift + {c,r}" = ''${i3-msg} "{reload,restart}"''; "super + shift + {c,r}" = ''${i3-msg} "{reload,restart}"'';
} "super + {1-9,0}" = ''${i3-msg} "workspace {1-9,10}"'';
"super + shift + {1-9,0}" = ''
WORKSPACE={1-9,10};
${i3-msg} "move container to workspace $WORKSPACE; workspace $WORKSPACE"'';
# Bind super + workspace -> switch to workspace "super + r : {h,j,k,l}" =
// (bindAll (num: "super + ${num}") ''${i3-msg} "resize {shrink,grow} width 10px or 10 ppt"'';
(num: ''${i3-msg} "workspace ${lookup num}"'')) "super + r : {j,k}" =
''${i3-msg} "resize {shrink,grow} height 10px or 10 ppt"'';
# Bind super + shift + workspace -> move to workspace };
// (bindAll (num: "super + shift + ${num}") (num:
''
${i3-msg} "move container to workspace ${lookup num}; workspace ${
lookup num
}"''));
lockScreenCommand =
"${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span";
programs.fish.functions = { programs.fish.functions = {
update-lock-screen = lib.mkIf config.services.xserver.enable { update-lock-screen = lib.mkIf config.services.xserver.enable {
@ -202,6 +186,9 @@ in {
}; };
lockScreenCommand =
"${pkgs.betterlockscreen}/bin/betterlockscreen --lock --display 1 --blur 0.5 --span";
# Ref: https://github.com/betterlockscreen/betterlockscreen/blob/next/system/betterlockscreen%40.service # Ref: https://github.com/betterlockscreen/betterlockscreen/blob/next/system/betterlockscreen%40.service
systemd.services.lock = { systemd.services.lock = {
enable = config.services.xserver.enable; enable = config.services.xserver.enable;

View File

@ -1,45 +1,52 @@
{ config, pkgs, ... }: { config, pkgs, ... }: {
let home-manager.users.${config.user} = {
services.sxhkd = {
enable = true;
keybindings = {
binds = config.home-manager.users.${config.user}.programs.sxhkd.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}" = ''
${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 {- 30,+ 30} && sleep 1; \\
${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 {- 30,+ 30}
'';
in { # Media controls
"XF86Audio{Play,Stop,Next,Prev}" =
"${pkgs.playerctl}/bin/playerctl {play-pause,stop,next,previous}";
home-manager.users.${config.user}.programs.sxhkd = { # Toggle bar
enable = true; "super + b" = config.toggleBarCommand;
keybindings = {
# Adjust screen brightness (TODO: replace with pkgs.light?) # Launchers
"shift + {F11,F12}" = '' "super + Return" = config.terminal;
${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 {- 30,+ 30} && sleep 1; \\ "super + space" = config.launcherCommand;
${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 {- 30,+ 30} "super + shift + s" = config.systemdSearch;
''; "super + shift + a" = config.audioSwitchCommand;
"XF86MonBrightness{Down,Up}" = binds."shift + {F11,F12}"; "alt + Tab" = config.altTabCommand;
"super + shift + period" = config.powerCommand;
# Media controls "super + shift + m" = config.brightnessCommand;
"XF86Audio{Play,Stop,Next,Prev}" = "super + c" = config.calculatorCommand;
"${pkgs.playerctl}/bin/playerctl {play-pause,stop,next,previous}"; "super + shift + x" = config.lockScreenCommand;
"super + alt + h" =
# Toggle bar "${config.terminal} sh -c '${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
"super + b" = config.toggleBarCommand; "super + alt + r" =
"${config.terminal} sh -c 'doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'";
# 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 + 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'";
};
}; };
xsession.windowManager.i3.config.startup = [{
command = "pkill sxhkd; sxhkd";
always = true;
notification = false;
}];
}; };
} }