nixos-config/home/x/i3.nix

165 lines
4.7 KiB
Nix
Raw Normal View History

2022-04-10 11:54:58 +02:00
{
config,
lib,
pkgs,
...
}: let
inherit
(lib)
2022-01-11 16:08:21 +01:00
mkIf
mkOptionDefault
2022-04-10 11:54:58 +02:00
;
2022-01-11 16:08:21 +01:00
2021-04-19 14:29:38 +02:00
isEnabled = config.my.home.x.enable;
myTerminal =
# FIXME: fix when terminal is setup in home
# if config.my.home.terminal.program != null
if true
then "alacritty"
else "i3-sensible-terminal";
alt = "Mod1"; # `Alt` key
modifier = "Mod4"; # `Super` key
logoutMode = "[L]ogout, [S]uspend, [P]oweroff, [R]eboot";
2021-04-19 14:58:52 +02:00
i3Theme = config.my.theme.i3Theme;
2022-04-10 11:54:58 +02:00
in {
2022-01-11 16:08:21 +01:00
config = mkIf isEnabled {
2021-04-19 15:51:50 +02:00
my.home = {
flameshot.enable = true;
};
2021-04-19 14:29:38 +02:00
2022-09-26 12:48:14 +02:00
home.packages = [pkgs.betterlockscreen pkgs.playerctl];
2021-04-20 00:47:23 +02:00
2022-12-01 15:11:20 +01:00
# used to control music
services.playerctld.enable = true;
2021-04-19 14:29:38 +02:00
xsession.windowManager.i3 = {
enable = true;
config = {
inherit modifier;
2022-04-10 11:54:58 +02:00
bars = let
barConfigPath =
config.xdg.configFile."i3status-rust/config-top.toml".target;
in [
{
statusCommand = "i3status-rs ~/${barConfigPath}";
2022-04-10 11:54:58 +02:00
position = "top";
fonts = {
names = ["DejaVuSansMono" "FontAwesome6Free"];
2022-04-10 11:54:58 +02:00
size = 9.0;
};
colors = i3Theme.bar;
trayOutput = "primary";
# disable mouse scroll wheel in bar
extraConfig = ''
bindsym button4 nop
bindsym button5 nop
'';
}
];
2021-04-19 14:29:38 +02:00
2021-04-20 01:05:53 +02:00
colors = {
2022-04-10 11:54:58 +02:00
inherit
(i3Theme)
focused
focusedInactive
unfocused
urgent
2022-04-10 11:54:58 +02:00
;
2021-04-20 01:05:53 +02:00
};
2021-04-19 14:29:38 +02:00
focus = {
followMouse = true;
mouseWarping = true;
};
2021-04-22 01:25:37 +02:00
workspaceAutoBackAndForth = true;
fonts = {
2022-04-10 11:54:58 +02:00
names = ["DejaVu Sans Mono"];
size = 8.0;
};
2021-04-19 14:29:38 +02:00
2022-01-11 16:08:21 +01:00
keybindings = mkOptionDefault {
2021-04-19 14:29:38 +02:00
"${modifier}+Shift+e" = ''mode "${logoutMode}"'';
2022-10-10 14:25:25 +02:00
"${modifier}+b" = "exec --no-startup-id bluetoothctl power on";
"${modifier}+i" = "exec emacsclient --create-frame";
"${modifier}+o" = "exec emacsclient --create-frame --eval '(load \"${config.xdg.configHome}/doom/launch-agenda.el\")'";
2021-04-20 00:38:08 +02:00
# Volume handling
"XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5%";
"XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5%";
"XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle";
"XF86AudioMicMute" = "exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle";
2021-04-20 00:47:23 +02:00
2022-09-26 12:48:14 +02:00
# I need play-pause everywhere because somehow, keycode 172 seems to
# be interpreted as pause everytime when sent by my keyboard. Ugh,
# computers.
"XF86AudioPlay" = "exec --no-startup-id playerctl play-pause";
"XF86AudioPause" = "exec --no-startup-id playerctl play-pause";
"XF86AudioPrev" = "exec --no-startup-id playerctl previous";
"XF86AudioNext" = "exec --no-startup-id playerctl next";
2021-07-25 16:28:06 +02:00
"XF86MonBrightnessDown" = "exec --no-startup-id light -U 5";
"XF86MonBrightnessUp" = "exec --no-startup-id light -A 5";
"${modifier}+XF86MonBrightnessDown" = "exec --no-startup-id light -U 0.1";
"${modifier}+XF86MonBrightnessUp" = "exec --no-startup-id light -A 0.1";
2021-07-25 16:28:06 +02:00
2021-04-20 00:47:23 +02:00
"${modifier}+l" = "exec --no-startup-id betterlockscreen --lock";
2021-07-29 11:22:39 +02:00
"${modifier}+d" = "exec ${pkgs.rofi}/bin/rofi -show run";
2021-04-19 14:29:38 +02:00
};
2022-04-10 11:54:58 +02:00
modes = let
makeModeBindings = attrs:
attrs
// {
2021-04-19 14:29:38 +02:00
"Escape" = "mode default";
"Return" = "mode default";
};
2022-04-10 11:54:58 +02:00
in
mkOptionDefault {
"${logoutMode}" = makeModeBindings {
"l" = "exec --no-startup-id i3-msg exit, mode default";
"s" = "exec --no-startup-id betterlockscreen --suspend, mode default";
"p" = "exec --no-startup-id systemctl poweroff, mode default";
"r" = "exec --no-startup-id systemctl reboot, mode default";
2021-04-19 14:29:38 +02:00
};
2022-04-10 11:54:58 +02:00
};
2021-04-19 14:29:38 +02:00
terminal = myTerminal;
2021-04-20 00:52:36 +02:00
assigns = {
"10" = [
2022-04-10 11:54:58 +02:00
{class = "Slack";}
{class = "discord";}
2021-04-20 00:52:36 +02:00
];
};
window.commands = [
2022-04-10 11:54:58 +02:00
{
command = "border pixel 2";
criteria = {class = "Alacritty";};
}
# NOTE: should be done with an assign command, but Spotify doesn't set
# its class until after initialization, so has to be done this way.
#
# See https://i3wm.org/docs/userguide.html#assign_workspace
{
2022-04-10 11:54:58 +02:00
criteria = {class = "Spotify";};
command = "move --no-auto-back-and-forth to workspace 8";
}
];
2021-04-19 14:29:38 +02:00
};
};
};
}