dotfiles/modules/graphical/i3.nix

244 lines
8.6 KiB
Nix
Raw Normal View History

2022-05-12 12:44:03 +00:00
{ config, pkgs, lib, ... }:
let
2022-05-15 02:38:26 +00:00
lockCmd = ''exec i3lock --nofork --color "${config.gui.colorscheme.base00}"'';
2022-05-12 12:44:03 +00:00
in {
2022-04-29 01:56:21 +00:00
2022-04-30 02:29:50 +00:00
config = lib.mkIf config.services.xserver.enable {
2022-04-29 02:55:42 +00:00
2022-05-02 03:16:03 +00:00
services.xserver.windowManager = {
i3 = {
enable = true;
package = pkgs.i3-gaps;
};
};
2022-04-29 01:56:21 +00:00
2022-04-30 02:29:50 +00:00
environment.systemPackages = with pkgs; [
dmenu # Launcher
feh # Wallpaper
playerctl # Media control
];
home-manager.users.${config.user}.xsession.windowManager.i3 = {
2022-04-30 12:42:08 +00:00
enable = true;
2022-05-02 03:16:03 +00:00
package = pkgs.i3-gaps;
2022-04-30 12:42:08 +00:00
config = let
2022-04-30 21:27:42 +00:00
modifier = "Mod4"; # Super key
2022-05-08 19:30:05 +00:00
ws1 = "1:I";
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";
2022-04-30 02:29:50 +00:00
in {
2022-04-30 21:27:42 +00:00
modifier = modifier;
2022-04-30 12:42:08 +00:00
assigns = {
2022-04-30 21:40:24 +00:00
"${ws1}" = [{ class = "Firefox"; }];
"${ws2}" = [{ class = "Alacritty"; }];
2022-05-08 19:30:05 +00:00
"${ws3}" = [{ class = "discord"; }];
2022-04-30 21:40:24 +00:00
"${ws4}" = [{ class = "Steam"; }];
2022-04-30 02:29:50 +00:00
};
2022-04-30 12:42:08 +00:00
bars = [{ command = "echo"; }]; # Disable i3bar
colors = let
background = config.gui.colorscheme.base00;
inactiveBackground = config.gui.colorscheme.base01;
border = config.gui.colorscheme.base01;
inactiveBorder = config.gui.colorscheme.base01;
text = config.gui.colorscheme.base07;
inactiveText = config.gui.colorscheme.base04;
urgentBackground = config.gui.colorscheme.base08;
2022-05-02 03:16:03 +00:00
indicator = "#00000000";
2022-04-30 12:42:08 +00:00
in {
background = config.gui.colorscheme.base00;
2022-04-30 12:42:08 +00:00
focused = {
2022-05-02 03:16:03 +00:00
inherit background indicator text border;
2022-04-30 12:42:08 +00:00
childBorder = background;
};
focusedInactive = {
inherit indicator;
background = inactiveBackground;
2022-05-02 03:16:03 +00:00
border = inactiveBorder;
2022-04-30 12:42:08 +00:00
childBorder = inactiveBackground;
text = inactiveText;
};
# placeholder = { };
unfocused = {
inherit indicator;
background = inactiveBackground;
2022-05-02 03:16:03 +00:00
border = inactiveBorder;
2022-04-30 12:42:08 +00:00
childBorder = inactiveBackground;
text = inactiveText;
};
urgent = {
inherit text indicator;
background = urgentBackground;
border = urgentBackground;
childBorder = urgentBackground;
};
2022-04-30 02:29:50 +00:00
};
2022-04-30 12:42:08 +00:00
floating.modifier = modifier;
focus = {
2022-05-07 13:24:17 +00:00
mouseWarping = true;
2022-05-01 16:10:38 +00:00
newWindow = "urgent";
2022-05-06 13:46:49 +00:00
followMouse = false;
2022-04-30 02:29:50 +00:00
};
2022-04-30 12:42:08 +00:00
keybindings = {
# PulseAudio adjust volume
"XF86AudioRaiseVolume" = "exec --no-startup-id pamixer -i 2";
"XF86AudioLowerVolume" = "exec --no-startup-id pamixer -d 2";
"XF86AudioMute" = "exec --no-startup-id pamixer -t";
"XF86AudioMicMute" =
"exec --no-startup-id pamixer --default-source -t";
# Adjust screen brightness
"Shift+F12" =
2022-05-15 18:31:13 +00:00
"exec ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ddcutil --display 2 setvcp 10 + 30";
2022-04-30 12:42:08 +00:00
"Shift+F11" =
2022-05-15 18:31:13 +00:00
"exec ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ddcutil --display 2 setvcp 10 - 30";
2022-04-30 12:42:08 +00:00
"XF86MonBrightnessUp" =
2022-05-15 18:31:13 +00:00
"exec ddcutil --display 1 setvcp 10 + 30 && sleep 1; exec ddcutil --display 2 setvcp 10 + 30";
2022-04-30 12:42:08 +00:00
"XF86MonBrightnessDown" =
2022-05-15 18:31:13 +00:00
"exec ddcutil --display 1 setvcp 10 - 30 && sleep 1; exec ddcutil --display 2 setvcp 10 - 30";
2022-04-30 12:42:08 +00:00
# Media player controls
"XF86AudioPlay" = "exec playerctl play-pause";
"XF86AudioStop" = "exec playerctl stop";
"XF86AudioNext" = "exec playerctl next";
"XF86AudioPrev" = "exec playerctl previous";
# Launchers
"${modifier}+Return" =
"exec alacritty; workspace ${ws2}; layout tabbed";
2022-05-04 01:11:31 +00:00
"${modifier}+space" =
"exec --no-startup-id ${config.gui.launcherCommand}";
2022-05-15 19:24:16 +00:00
"${modifier}+Shift+s" =
"exec --no-startup-id ${config.gui.systemdSearch}";
2022-04-30 12:42:08 +00:00
"${modifier}+Shift+c" = "reload";
"${modifier}+Shift+r" = "restart";
2022-04-30 16:07:58 +00:00
"${modifier}+Shift+q" = ''
2022-04-30 12:42:08 +00:00
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'"'';
2022-05-12 12:44:03 +00:00
"${modifier}+Shift+x" = lockCmd;
2022-04-30 12:42:08 +00:00
# Window options
2022-04-30 16:07:58 +00:00
"${modifier}+q" = "kill";
"${modifier}+b" = "exec ${config.gui.toggleBarCommand}";
2022-05-07 14:25:41 +00:00
"${modifier}+f" = "fullscreen toggle";
2022-04-30 12:42:08 +00:00
"${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";
2022-04-30 16:07:58 +00:00
"${modifier}+t" = "layout tabbed";
2022-04-30 12:42:08 +00:00
"${modifier}+e" = "layout toggle split";
"${modifier}+Shift+space" = "floating toggle";
2022-04-30 16:07:58 +00:00
"${modifier}+Control+space" = "focus mode_toggle";
2022-04-30 12:42:08 +00:00
"${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
2022-05-15 00:41:05 +00:00
"${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}";
2022-04-30 12:42:08 +00:00
# Move screens
"${modifier}+Control+l" = "move workspace to output right";
"${modifier}+Control+h" = "move workspace to output left";
# Resizing
"${modifier}+r" = ''mode "resize"'';
2022-05-15 00:38:21 +00:00
"${modifier}+Control+Shift+h" = "resize shrink width 10 px or 10 ppt";
"${modifier}+Control+Shift+j" = "resize grow height 10 px or 10 ppt";
"${modifier}+Control+Shift+k" =
"resize shrink height 10 px or 10 ppt";
"${modifier}+Control+Shift+l" = "resize grow width 10 px or 10 ppt";
2022-04-30 02:29:50 +00:00
};
2022-05-15 00:38:21 +00:00
modes = { };
startup = [
{
command = "feh --bg-fill ${config.gui.wallpaper}";
always = true;
notification = false;
}
{
command = "i3-msg workspace ${ws1}";
notification = false;
}
];
2022-04-30 12:42:08 +00:00
window = {
2022-05-02 03:16:03 +00:00
border = 0;
hideEdgeBorders = "smart";
2022-04-30 14:21:43 +00:00
titlebar = false;
2022-04-30 12:42:08 +00:00
};
workspaceAutoBackAndForth = false;
workspaceOutputAssign = [ ];
2022-05-04 00:32:47 +00:00
# gaps = {
# bottom = 8;
# top = 8;
# left = 8;
# right = 8;
# horizontal = 15;
# vertical = 15;
# inner = 15;
# outer = 0;
# smartBorders = "off";
# smartGaps = false;
# };
2022-04-30 02:29:50 +00:00
};
extraConfig = "";
};
};
2022-04-29 02:12:16 +00:00
2022-04-29 01:56:21 +00:00
}