dotfiles/nix/modules/nixos/i3.nix

158 lines
4 KiB
Nix
Raw Normal View History

2024-11-10 00:14:55 +00:00
{
config,
2024-11-10 00:14:55 +00:00
inputs,
lib,
2024-11-10 00:14:55 +00:00
pkgs,
self,
username,
...
}:
with lib;
2024-11-10 00:14:55 +00:00
let
theme = import "${self}/nix/lib/theme" { inherit pkgs; };
2024-11-10 00:14:55 +00:00
modifier = "Mod4";
in
{
options.features.desktop.i3.enable = mkEnableOption "Enable i3";
2024-11-10 00:14:55 +00:00
config = mkIf config.features.desktop.i3.enable {
services = {
cron = {
2024-11-10 00:14:55 +00:00
enable = true;
systemCronJobs = [
"* * * * * opdavies ${pkgs.notify-battery}/bin/notify-battery"
2024-11-10 00:14:55 +00:00
];
};
displayManager.defaultSession = "none+i3";
xserver = {
displayManager.lightdm.enable = true;
windowManager.i3 = {
enable = true;
extraPackages = with pkgs; [
i3status
i3lock
i3blocks
2024-11-10 00:14:55 +00:00
];
};
};
};
2024-11-10 00:14:55 +00:00
environment.systemPackages = with pkgs; [
acpi
libnotify
];
2024-11-10 00:14:55 +00:00
home-manager.users.${username} = {
xsession.windowManager.i3 = {
enable = true;
2024-11-10 00:14:55 +00:00
config = {
assigns = {
"7" = [ { class = "vlc"; } ];
"8" = [ { class = "0ad"; } ];
"9" = [
{ class = "Slack"; }
{ class = "discord"; }
];
};
2024-11-10 00:14:55 +00:00
defaultWorkspace = "workspace number 1";
2024-11-10 00:14:55 +00:00
modifier = modifier;
2024-11-10 00:14:55 +00:00
keybindings = inputs.nixpkgs.lib.mkOptionDefault {
"${modifier}+d" = "exec rofi -show drun";
2024-11-10 00:14:55 +00:00
"${modifier}+Shift+b" = "exec ${pkgs.firefox}/bin/firefox";
"${modifier}+Shift+f" = "exec ${pkgs.xfce.thunar}/bin/thunar";
2024-11-10 00:14:55 +00:00
# Change focus.
"${modifier}+h" = "focus left";
"${modifier}+j" = "focus down";
"${modifier}+k" = "focus up";
"${modifier}+l" = "focus right";
2024-11-10 00:14:55 +00:00
# Move focused window.
"${modifier}+Shift+h" = "move left";
"${modifier}+Shift+j" = "move down";
"${modifier}+Shift+k" = "move up";
"${modifier}+Shift+l" = "move right";
2024-11-10 00:14:55 +00:00
"${modifier}+Shift+s" = "exec ${pkgs.flameshot}/bin/flameshot gui";
"${modifier}+Shift+p" = "exec ${pkgs.autorandr}/bin/autorandr --change";
"${modifier}+Shift+y" = "exec ${pkgs.copyq}/bin/copyq toggle";
2024-11-10 00:14:55 +00:00
"XF86AudioRaiseVolume" = "exec pamixer -ui 2 && pamixer --get-volume";
"XF86AudioLowerVolume" = "exec pamixer -ud 2 && pamixer --get-volume";
"XF86AudioMute" = ''exec pamixer --toggle-mute && ( [ "$(pamixer --get-mute)" = "true" ] && echo 0'';
"XF86MonBrightnessDown" = "exec brightnessctl set 5%- | sed -En 's/.*(([0-9]+)%).*/1/p'";
"XF86MonBrightnessUp" = "exec brightnessctl set +5% | sed -En 's/.*(([0-9]+)%).*/1/p'";
};
terminal = "alacritty";
};
extraConfig = ''
set $laptop eDP-1
bindswitch --reload --locked lid:on output $laptop disable
bindswitch --reload --locked lid:off output $laptop enable
exec_always --no-startup-id caffeine
exec_always --no-startup-id ${pkgs.autorandr}/bin/autorandr --change
smart_borders on
smart_gaps on
for_window [class="copyq"] floating enable
for_window [class="zoom"] floating enable
# xprop | grep -i class
'';
config = {
bars = [
{
position = "bottom";
statusCommand = "${pkgs.i3status}/bin/i3status";
trayOutput = "none";
}
];
2024-11-10 00:14:55 +00:00
gaps = {
smartBorders = "on";
smartGaps = true;
};
2024-11-10 00:14:55 +00:00
};
};
programs.i3status = {
enable = true;
2024-11-10 00:14:55 +00:00
general.colors = false;
2024-11-10 00:14:55 +00:00
modules = {
"battery all".settings.last_full_capacity = true;
2024-11-10 00:14:55 +00:00
"tztime local".settings.format = "%d-%m-%Y %H:%M:%S";
cpu_temperature.enable = false;
ipv6.enable = false;
load.enable = false;
};
2024-11-10 00:14:55 +00:00
};
2024-11-25 08:03:59 +00:00
services.dunst = {
enable = true;
2024-11-25 08:03:59 +00:00
settings.global.follow = "keyboard";
};
2024-11-25 08:03:59 +00:00
};
2024-11-10 00:14:55 +00:00
};
}