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"
"$character"
];
right_format = "$nix_shell";
# right_format = "$nix_shell";
character = {
success_symbol = "[](bold green)";
error_symbol = "[](bold red)";

View File

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

View File

@ -15,7 +15,7 @@ let
"7" = "7:VII";
"8" = "8:VIII";
"9" = "9:IX";
"0" = "10:X";
"10" = "10:X";
};
in {
@ -124,30 +124,18 @@ in {
extraConfig = "";
};
programs.sxhkd.keybindings = let
services.sxhkd.keybindings = let
# Shortcuts
binds =
config.home-manager.users.${config.user}.programs.sxhkd.keybindings;
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 {
# Window navigation
"super + {h,j,k,l}" = ''${i3-msg} "focus {left,down,up,right}"'';
"super + {Left,Down,Up,Right}" = binds."super + {h,j,k,l}";
"super + shift + {h,j,k,l}" = ''${i3-msg} "move {left,down,up,right}"'';
"super + shift + {Left,Down,Up,Right}" =
binds."super + shift + {h,j,k,l}";
"super + {_,shift +}{h,j,k,l}" =
''${i3-msg} "{focus,move} {left,down,up,right}"'';
"super + {_,shift +}{Left,Down,Up,Right}" =
''${i3-msg} "{focus,move} {left,down,up,right}"'';
"super + q" = ''${i3-msg} "kill"'';
"super + f" = ''${i3-msg} "fullscreen toggle"'';
@ -166,21 +154,17 @@ in {
# Restart and reload
"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
// (bindAll (num: "super + ${num}")
(num: ''${i3-msg} "workspace ${lookup num}"''))
"super + r : {h,j,k,l}" =
''${i3-msg} "resize {shrink,grow} width 10px or 10 ppt"'';
"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 = {
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
systemd.services.lock = {
enable = config.services.xserver.enable;

View File

@ -1,12 +1,7 @@
{ config, pkgs, ... }:
{ config, pkgs, ... }: {
let
binds = config.home-manager.users.${config.user}.programs.sxhkd.keybindings;
in {
home-manager.users.${config.user}.programs.sxhkd = {
home-manager.users.${config.user} = {
services.sxhkd = {
enable = true;
keybindings = {
@ -15,7 +10,10 @@ in {
${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}" = 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
"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'";
};
};
xsession.windowManager.i3.config.startup = [{
command = "pkill sxhkd; sxhkd";
always = true;
notification = false;
}];
};
}