nixos-config/home/x/i3.nix

137 lines
3.7 KiB
Nix
Raw Normal View History

2021-04-19 14:29:38 +02:00
{ config, lib, pkgs, ... }:
let
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;
2021-04-19 14:29:38 +02:00
in
{
config = lib.mkIf isEnabled {
2021-04-19 15:51:50 +02:00
my.home = {
flameshot.enable = true;
};
2021-04-19 14:29:38 +02:00
2021-04-20 00:47:23 +02:00
home.packages = with pkgs; [
betterlockscreen
];
2021-04-19 14:29:38 +02:00
xsession.windowManager.i3 = {
enable = true;
config = {
inherit modifier;
bars =
2021-04-19 14:58:52 +02:00
let
barConfigPath =
config.xdg.configFile."i3status-rust/config-top.toml".target;
in
2021-04-19 14:29:38 +02:00
[
{
2021-04-19 14:58:52 +02:00
statusCommand = "i3status-rs ${barConfigPath}";
2021-04-19 14:29:38 +02:00
position = "top";
fonts = {
names = [ "DejaVuSansMono" "FontAwesome5Free" ];
size = 9.0;
};
2021-04-19 14:58:52 +02:00
colors = i3Theme.bar;
# 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 = {
inherit (i3Theme)
focused
focusedInactive
unfocused
urgent
;
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 = {
names = [ "DejaVu Sans Mono" ];
size = 8.0;
};
2021-04-19 14:29:38 +02:00
keybindings = lib.mkOptionDefault {
"${modifier}+Shift+e" = ''mode "${logoutMode}"'';
"${modifier}+i" = "exec emacsclient -c";
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
2021-07-25 16:28:06 +02:00
"XF86MonBrightnessDown" = "exec --no-startup-id light -U 5";
"XF86MonBrightnessUp" = "exec --no-startup-id light -A 5";
2021-04-20 00:47:23 +02:00
"${modifier}+l" = "exec --no-startup-id betterlockscreen --lock";
2021-04-19 14:29:38 +02:00
};
modes =
let
makeModeBindings = attrs: attrs // {
"Escape" = "mode default";
"Return" = "mode default";
};
in
2021-04-20 00:47:37 +02:00
lib.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
};
terminal = myTerminal;
2021-04-20 00:52:36 +02:00
assigns = {
"10" = [
{ class = "Slack"; }
{ class = "discord"; }
2021-04-20 00:52:36 +02:00
];
};
window.commands = [
{ 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
{
criteria = { class = "Spotify"; };
command = "move --no-auto-back-and-forth to workspace 8";
}
];
2021-04-19 14:29:38 +02:00
};
};
};
}