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,12 +1,7 @@
{ config, pkgs, ... }: { config, pkgs, ... }: {
let home-manager.users.${config.user} = {
services.sxhkd = {
binds = config.home-manager.users.${config.user}.programs.sxhkd.keybindings;
in {
home-manager.users.${config.user}.programs.sxhkd = {
enable = true; enable = true;
keybindings = { keybindings = {
@ -15,7 +10,10 @@ in {
${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 {- 30,+ 30} && sleep 1; \\ ${pkgs.ddcutil}/bin/ddcutil --display 1 setvcp 10 {- 30,+ 30} && sleep 1; \\
${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 {- 30,+ 30} ${pkgs.ddcutil}/bin/ddcutil --display 2 setvcp 10 {- 30,+ 30}
''; '';
"XF86MonBrightness{Down,Up}" = binds."shift + {F11,F12}"; "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}
'';
# Media controls # Media controls
"XF86Audio{Play,Stop,Next,Prev}" = "XF86Audio{Play,Stop,Next,Prev}" =
@ -40,6 +38,15 @@ in {
"${config.terminal} sh -c 'doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName} || read'"; "${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;
}];
}; };
} }