marleyos/modules/home/xorg/i3/default.nix

183 lines
5.1 KiB
Nix
Raw Normal View History

2024-11-18 20:37:50 -08:00
{
lib,
config,
2024-11-23 13:09:53 -08:00
pkgs,
2024-11-18 20:37:50 -08:00
...
2025-01-06 20:29:08 -08:00
}: let
inherit
(lib)
2024-11-23 13:09:53 -08:00
mkEnableOption
mkIf
concatMapAttrs
map
range
listToAttrs
getExe
;
inherit (lib.marleyos) enabled disabled;
2024-11-18 20:37:50 -08:00
cfg = config.marleyos.xorg.i3;
isGenericLinux = config.targets.genericLinux.enable;
2025-01-06 20:29:08 -08:00
in {
2024-11-18 20:37:50 -08:00
options.marleyos.xorg.i3.enable = mkEnableOption "i3";
config = mkIf cfg.enable {
marleyos = {
programs.rofi = enabled;
2024-11-22 22:40:54 -08:00
services = {
2024-11-23 13:09:53 -08:00
dunst = enabled;
2024-11-22 22:40:54 -08:00
picom = enabled;
polybar = enabled;
# broken on non-nixOS
2025-01-06 20:29:08 -08:00
screen-locker =
if isGenericLinux
then disabled
else enabled;
2024-11-22 22:40:54 -08:00
};
2024-11-18 20:37:50 -08:00
};
2024-11-23 13:09:53 -08:00
home.packages = with pkgs; [
networkmanagerapplet
feh
];
xsession.windowManager.i3 = {
enable = true;
2025-01-06 20:29:08 -08:00
package = mkIf config.marleyos.nixGL.enable (config.lib.nixGL.wrap pkgs.i3);
2024-11-23 13:09:53 -08:00
extraConfig = "tiling_drag modifier titlebar";
2025-01-06 20:29:08 -08:00
config = let
directions = {
left = "h";
down = "j";
up = "k";
right = "l";
};
in {
focus.followMouse = false;
window.border = 0;
floating.border = 0;
window.titlebar = false;
floating.titlebar = false;
gaps = {
smartBorders = "no_gaps";
inner = 10;
top = 50;
};
2024-11-23 13:09:53 -08:00
2025-01-06 20:29:08 -08:00
bars = [];
2024-11-23 13:09:53 -08:00
2025-01-06 20:29:08 -08:00
# Startup - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2024-11-23 13:09:53 -08:00
2025-01-06 20:29:08 -08:00
startup = with pkgs; [
{command = "${getExe feh} --no-fehbg --bg-fill ${./bg.jpg}";}
{command = "${getExe networkmanagerapplet}";}
];
2024-11-23 13:09:53 -08:00
2025-01-06 20:29:08 -08:00
# Keybindings - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2024-11-23 13:09:53 -08:00
2025-01-06 20:29:08 -08:00
modifier = "Mod4";
2024-11-23 13:09:53 -08:00
2025-01-06 20:29:08 -08:00
keybindings = let
mod = config.xsession.windowManager.i3.config.modifier;
workspaces = range 1 10;
getI = i:
if i == 10
then "0"
else toString i;
inherit (config.xdg) configHome;
isGenericLinux = config.targets.genericLinux.enable;
in
{
"${mod}+Shift+c" = "reload";
"${mod}+Shift+r" = "restart";
"${mod}+Shift+e" = "exec i3-nagbar -t warning -m 'Do you want to exit i3?' -b 'Yes' 'i3-msg exit'";
"${mod}+e" = "layout toggle split";
"${mod}+Control+h" = "split -";
"${mod}+Control+v" = "split |";
"${mod}+f" = "fullscreen toggle";
"${mod}+Shift+space" = "floating toggle";
"${mod}+Control+r" = "mode resize";
"${mod}+q" = "kill";
"${mod}+r" = "exec ${configHome}/rofi/launchers/type-1/launcher.sh";
"${mod}+Return" = "exec ${
if isGenericLinux
then "wezterm"
else "${pkgs.wezterm}/bin/wezterm"
}";
}
# PulseAudio Volume - - - - - - - - - - - - - - - - - - - - - - - -
// (
concatMapAttrs
(key: cmd: {
"${key}" = "exec --no-startup-id pactl ${cmd} && killall -SIGUSR1 i3status";
})
2024-11-23 13:09:53 -08:00
{
2025-01-06 20:29:08 -08:00
XF86AudioRaiseVolume = "set-sink-volume @DEFAULT_SINK@ +10%";
XF86AudioLowerVolume = "set-sink-volume @DEFAULT_SINK@ -10%";
XF86AudioMute = "set-sink-mute @DEFAULT_SINK@ toggle";
XF86AudioMicMute = "set-source-mute @DEFAULT_SOURCE@ toggle";
2024-11-23 13:09:53 -08:00
}
2025-01-06 20:29:08 -08:00
)
# Focus & Movement - - - - - - - - - - - - - - - - - - - - - - - - -
// (concatMapAttrs (direction: key: {
2024-11-23 13:09:53 -08:00
"${mod}+${key}" = "focus ${direction}";
"${mod}+Shift+${key}" = "move ${direction}";
2025-01-06 20:29:08 -08:00
})
directions)
# Switch Workspaces - - - - - - - - - - - - - - - - - - - - - - - - -
// (listToAttrs (
(map (i: {
name = "${mod}+${getI i}";
value = "workspace number ${toString i}";
}))
workspaces
))
# Move Windows Between Workspaces - - - - - - - - - - - - - - - - - -
// (listToAttrs (
(map (i: {
name = "${mod}+Shift+${getI i}";
value = "move container to workspace number ${toString i}";
}))
workspaces
));
# Resize Windows - - - - - - - - - - - - - - - - - - - - - - - - - - -
modes.resize = let
mod = config.xsession.windowManager.i3.config.modifier;
in
{
Return = "mode default";
Escape = "mode default";
"${mod}+Control+r" = "mode default";
}
// (
concatMapAttrs
(key: action: {
"${key}" = "resize ${action} 10 px or 10 ppt";
})
rec {
Left = "shrink width";
Down = "shrink height";
Up = "grow height";
Right = "grow width";
"${directions.left}" = Left;
"${directions.down}" = Down;
"${directions.up}" = Up;
"${directions.right}" = Right;
2024-11-23 13:09:53 -08:00
}
2025-01-06 20:29:08 -08:00
);
};
2024-11-23 13:09:53 -08:00
};
2024-11-18 20:37:50 -08:00
};
}