2024-08-01 21:22:47 +02:00
|
|
|
{ lib, pkgs, config, ...}: let
|
2024-08-08 00:34:02 +02:00
|
|
|
inherit (lib) mkIf mkEnableOption mkOption types optionals mergeAttrs mergeAttrsList optionalAttrs;
|
2024-08-01 21:22:47 +02:00
|
|
|
cfg = config.chuj.stuff.i3;
|
|
|
|
user = config.chuj.system.user;
|
|
|
|
in {
|
|
|
|
options.chuj.stuff.i3 = {
|
|
|
|
enable = mkEnableOption "i3";
|
|
|
|
workspaceOutput = mkOption {
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
communicators = mkOption {
|
|
|
|
type = types.submodule {
|
|
|
|
options = {
|
|
|
|
autostart = mkOption {
|
|
|
|
type = types.bool;
|
2024-08-02 00:10:45 +02:00
|
|
|
default = false;
|
2024-08-01 21:22:47 +02:00
|
|
|
};
|
|
|
|
workspace = mkOption {
|
|
|
|
type = types.str;
|
2024-08-02 00:10:45 +02:00
|
|
|
default = "";
|
2024-08-01 21:22:47 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
default = {};
|
|
|
|
};
|
2024-08-04 00:38:28 +02:00
|
|
|
battery = mkEnableOption "battery";
|
2024-08-01 21:22:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = let
|
|
|
|
HOME = config.home-manager.users.${user}.home.homeDirectory;
|
|
|
|
in mkIf cfg.enable {
|
|
|
|
services.xserver.windowManager.i3.enable = true;
|
|
|
|
home-manager.users.${user} = {
|
|
|
|
xsession.windowManager.i3 = {
|
|
|
|
enable = true;
|
|
|
|
config = rec {
|
2024-08-02 00:10:45 +02:00
|
|
|
assigns = mkIf (cfg.communicators.workspace != "") {
|
2024-08-01 21:22:47 +02:00
|
|
|
${cfg.communicators.workspace} = [
|
|
|
|
{ class = "discord"; }
|
|
|
|
{ class = "SchildiChat"; }
|
|
|
|
{ class = "element"; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
window = {
|
|
|
|
border = 1;
|
|
|
|
titlebar = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
floating = {
|
|
|
|
border = 1;
|
|
|
|
titlebar = true;
|
|
|
|
criteria = [
|
|
|
|
{ class = "zenity"; }
|
|
|
|
{ class = "fceux"; }
|
|
|
|
{ title = "Friends List"; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
gaps = {
|
|
|
|
inner = 0;
|
|
|
|
outer = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
fonts = {
|
|
|
|
names = [ "JetBrains Mono NL" ];
|
|
|
|
size = 10.0;
|
|
|
|
};
|
|
|
|
|
|
|
|
defaultWorkspace = "workspace number 1";
|
|
|
|
|
|
|
|
workspaceOutputAssign = lib.mapAttrsToList
|
|
|
|
(workspace: output: { inherit workspace output; })
|
|
|
|
cfg.workspaceOutput;
|
|
|
|
|
|
|
|
focus = {
|
|
|
|
followMouse = true;
|
|
|
|
mouseWarping = true;
|
|
|
|
newWindow = "urgent";
|
|
|
|
};
|
|
|
|
|
|
|
|
startup = [
|
|
|
|
{ command = "autotiling &"; notification = false; }
|
|
|
|
]
|
2024-08-01 21:29:07 +02:00
|
|
|
++ optionals config.chuj.stuff.dunst.enable [{ command = "dunst &"; notification = false; }]
|
|
|
|
++ optionals config.chuj.stuff.flameshot.enable [{ command = "flameshot &"; notification = false; }]
|
2024-08-01 21:22:47 +02:00
|
|
|
++ optionals cfg.communicators.autostart [
|
2024-08-21 20:19:03 +02:00
|
|
|
# { command = "i3-msg \"workspace ${cfg.communicators.workspace}; append_layout ${../../files/i3_communicators_layout.json}\""; notification = false; }
|
|
|
|
# { command = "discord &"; notification = false; }
|
2024-08-29 23:42:46 +02:00
|
|
|
{ command = "schildichat-desktop &"; notification = false; }
|
2024-08-06 13:41:05 +02:00
|
|
|
]
|
|
|
|
++ optionals config.chuj.stuff.mpd.enable [
|
|
|
|
{ command = "${pkgs.writeShellScriptBin "mpdstatus" ''
|
|
|
|
while true; do
|
|
|
|
status=$(mpc status | sed -n 2p | cut -d' ' -f1)
|
|
|
|
title=$(basename "$(mpc current -f '%file%')" .mp3)
|
|
|
|
echo "$status $title" > /tmp/i3-mpd-status-stuff
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
''}/bin/mpdstatus &"; notification = false; }
|
2024-08-01 21:22:47 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
modes = let
|
|
|
|
cmd_and_center = cmd: "exec --no-startup-id i3-msg '${cmd}' && i3-center-mouse-on-focus";
|
|
|
|
in {
|
|
|
|
resize = {
|
|
|
|
"Left" = cmd_and_center "resize shrink width 10 px or 10 ppt";
|
|
|
|
"Right" = cmd_and_center "resize grow width 10 px or 10 ppt";
|
|
|
|
"Up" = cmd_and_center "resize shrink height 10 px or 10 ppt";
|
|
|
|
"Down" = cmd_and_center "resize grow height 10 px or 10 ppt";
|
|
|
|
"Escape" = "mode default";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
modifier = "Mod4";
|
|
|
|
floating.modifier = "Mod4";
|
|
|
|
|
|
|
|
keybindings = let
|
|
|
|
mod = modifier;
|
|
|
|
execns = "exec --no-startup-id";
|
|
|
|
cmd_and_center = cmd: "${execns} i3-msg '${cmd}' && i3custom-center-mouse-on-focus";
|
2024-08-06 13:41:05 +02:00
|
|
|
in mergeAttrs {
|
2024-08-01 21:22:47 +02:00
|
|
|
# Program keybinds
|
|
|
|
"${mod}+Return" = ''${execns} ${if config.chuj.stuff.alacritty.enable then "alacritty" else "i3-sensible-terminal"}'';
|
|
|
|
"${mod}+Shift+s" = mkIf config.chuj.stuff.flameshot.enable "${execns} flameshot gui";
|
|
|
|
"${mod}+b" = mkIf config.chuj.stuff.firefox.enable "${execns} firefox";
|
|
|
|
"${mod}+d" = "${execns} dmenu_run";
|
|
|
|
"--release ${mod}+k" = "${execns} xkill";
|
|
|
|
|
|
|
|
# Volume control
|
|
|
|
"Ctrl+F9" = "${execns} pamixer --toggle-mute";
|
|
|
|
"Ctrl+F10" = "${execns} pamixer --decrease 5";
|
|
|
|
"Ctrl+F11" = "${execns} pamixer --increase 5";
|
|
|
|
|
|
|
|
# General i3 keybindings
|
|
|
|
"${mod}+f" = cmd_and_center "fullscreen toggle";
|
|
|
|
"${mod}+r" = "mode resize";
|
|
|
|
"${mod}+Shift+q" = cmd_and_center "kill";
|
|
|
|
"${mod}+Shift+r" = "restart";
|
|
|
|
"${mod}+Shift+e" = "${execns} i3-nagbar -t warning -m 'exit?' -b 'yes' 'i3-msg exit'";
|
|
|
|
# Mouse bindings
|
|
|
|
"--border button3" = "${execns} i3custom-window-actions";
|
|
|
|
|
|
|
|
"${mod}+Left" = cmd_and_center "focus left";
|
|
|
|
"${mod}+Right" = cmd_and_center "focus right";
|
|
|
|
"${mod}+Up" = cmd_and_center "focus up";
|
|
|
|
"${mod}+Down" = cmd_and_center "focus down";
|
|
|
|
"${mod}+Shift+Left" = cmd_and_center "move left";
|
|
|
|
"${mod}+Shift+Right" = cmd_and_center "move right";
|
|
|
|
"${mod}+Shift+Up" = cmd_and_center "move up";
|
|
|
|
"${mod}+Shift+Down" = cmd_and_center "move down";
|
|
|
|
|
|
|
|
"${mod}+q" = cmd_and_center "layout stacking";
|
|
|
|
"${mod}+w" = cmd_and_center "layout tabbed";
|
|
|
|
"${mod}+e" = cmd_and_center "layout toggle split";
|
|
|
|
|
|
|
|
"${mod}+Shift+space" = "floating toggle; ${execns} i3custom-center-mouse-on-focus";
|
|
|
|
"${mod}+space" = cmd_and_center "focus mode_toggle";
|
|
|
|
|
|
|
|
"${mod}+1" = cmd_and_center "workspace number 1";
|
|
|
|
"${mod}+2" = cmd_and_center "workspace number 2";
|
|
|
|
"${mod}+3" = cmd_and_center "workspace number 3";
|
|
|
|
"${mod}+4" = cmd_and_center "workspace number 4";
|
|
|
|
"${mod}+5" = cmd_and_center "workspace number 5";
|
|
|
|
"${mod}+6" = cmd_and_center "workspace number 6";
|
|
|
|
"${mod}+7" = cmd_and_center "workspace number 7";
|
|
|
|
"${mod}+8" = cmd_and_center "workspace number 8";
|
|
|
|
"${mod}+9" = cmd_and_center "workspace number 9";
|
|
|
|
"${mod}+0" = cmd_and_center "workspace number 10";
|
|
|
|
|
|
|
|
"${mod}+Shift+1" = cmd_and_center "move container to workspace number 1";
|
|
|
|
"${mod}+Shift+2" = cmd_and_center "move container to workspace number 2";
|
|
|
|
"${mod}+Shift+3" = cmd_and_center "move container to workspace number 3";
|
|
|
|
"${mod}+Shift+4" = cmd_and_center "move container to workspace number 4";
|
|
|
|
"${mod}+Shift+5" = cmd_and_center "move container to workspace number 5";
|
|
|
|
"${mod}+Shift+6" = cmd_and_center "move container to workspace number 6";
|
|
|
|
"${mod}+Shift+7" = cmd_and_center "move container to workspace number 7";
|
|
|
|
"${mod}+Shift+8" = cmd_and_center "move container to workspace number 8";
|
|
|
|
"${mod}+Shift+9" = cmd_and_center "move container to workspace number 9";
|
|
|
|
"${mod}+Shift+0" = cmd_and_center "move container to workspace number 10";
|
2024-08-06 13:41:05 +02:00
|
|
|
} (optionalAttrs config.chuj.stuff.mpd.enable {
|
|
|
|
# MPD controls
|
|
|
|
"Ctrl+F5" = "exec mpdfdial.sh";
|
|
|
|
"Ctrl+F6" = "exec mpc prev";
|
|
|
|
"Ctrl+F7" = "exec mpc toggle";
|
|
|
|
"Ctrl+F8" = "exec mpc next";
|
|
|
|
"Ctrl+Shift+F6" = "exec mpc seek -3";
|
|
|
|
"Ctrl+Shift+F7" = "exec mpc clear";
|
|
|
|
"Ctrl+Shift+F8" = "exec mpc seek +3";
|
|
|
|
"Ctrl+Shift+F10" = ''exec mpc volume -5 && dunstify "mpc $(mpc volume)" -r 420'';
|
|
|
|
"Ctrl+Shift+F11" = ''exec mpc volume +5 && dunstify "mpc $(mpc volume)" -r 420'';
|
|
|
|
});
|
|
|
|
|
|
|
|
bars = [
|
|
|
|
{
|
|
|
|
inherit fonts;
|
|
|
|
trayOutput = "primary";
|
|
|
|
statusCommand = "${pkgs.i3status}/bin/i3status";
|
|
|
|
}
|
|
|
|
];
|
2024-08-01 21:22:47 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
programs.i3status = {
|
|
|
|
enable = true;
|
|
|
|
enableDefault = false;
|
|
|
|
|
|
|
|
general = {
|
|
|
|
interval = 1;
|
|
|
|
colors = true;
|
|
|
|
color_good = "#91d956";
|
|
|
|
color_bad = "#f43841";
|
|
|
|
color_degraded = "#ffdd33";
|
|
|
|
output_format = "i3bar";
|
|
|
|
};
|
|
|
|
|
2024-08-08 00:34:02 +02:00
|
|
|
modules = mergeAttrsList [
|
|
|
|
{
|
|
|
|
"cpu_usage" = {
|
|
|
|
position = 0;
|
|
|
|
settings = {
|
|
|
|
format = "cpu: %usage";
|
|
|
|
};
|
2024-08-06 13:41:05 +02:00
|
|
|
};
|
|
|
|
|
2024-08-08 00:34:02 +02:00
|
|
|
"memory" = {
|
|
|
|
position = 1;
|
|
|
|
settings = {
|
|
|
|
format = "mem: %used";
|
|
|
|
threshold_degraded = "1G";
|
|
|
|
format_degraded = "MEMORY < %available";
|
|
|
|
};
|
2024-08-01 21:22:47 +02:00
|
|
|
};
|
|
|
|
|
2024-08-08 00:34:02 +02:00
|
|
|
"volume master" = {
|
|
|
|
position = 2;
|
|
|
|
settings = {
|
|
|
|
color_degraded = "#333333";
|
|
|
|
format = "vol: %volume";
|
|
|
|
format_muted = "vol: ---";
|
|
|
|
};
|
2024-08-01 21:22:47 +02:00
|
|
|
};
|
|
|
|
|
2024-08-08 00:34:02 +02:00
|
|
|
"tztime local" = {
|
|
|
|
position = 4;
|
|
|
|
settings = {
|
|
|
|
format = "%Y-%m-%d %H:%M:%S (%A)";
|
|
|
|
};
|
2024-08-01 21:22:47 +02:00
|
|
|
};
|
2024-08-08 00:34:02 +02:00
|
|
|
}
|
|
|
|
(optionalAttrs cfg.battery {
|
|
|
|
"battery 0" = {
|
|
|
|
position = 3;
|
|
|
|
settings = {
|
|
|
|
format = "bat%status: %percentage";
|
|
|
|
status_chr = "(+)";
|
|
|
|
status_bat = "";
|
|
|
|
status_unk = "(?)";
|
|
|
|
status_full = "(+)";
|
|
|
|
low_threshold = 30;
|
|
|
|
};
|
2024-08-01 21:22:47 +02:00
|
|
|
};
|
2024-08-08 00:34:02 +02:00
|
|
|
})
|
|
|
|
(optionalAttrs config.chuj.stuff.mpd.enable {
|
|
|
|
"read_file mpd" = {
|
|
|
|
position = -1;
|
|
|
|
settings = {
|
|
|
|
format = "%content";
|
|
|
|
format_bad = "mpdstatus file not found, restart i3";
|
|
|
|
path = "/tmp/i3-mpd-status-stuff";
|
|
|
|
color_good = "#ffffff";
|
|
|
|
};
|
2024-08-04 00:38:28 +02:00
|
|
|
};
|
2024-08-08 00:34:02 +02:00
|
|
|
})
|
|
|
|
];
|
2024-08-01 21:22:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
home.packages = with pkgs; [
|
|
|
|
autotiling
|
|
|
|
|
|
|
|
(pkgs.writeShellScriptBin "i3custom-center-mouse-on-focus" ''
|
|
|
|
eval $(xdotool getwindowfocus getwindowgeometry --shell)
|
|
|
|
MX=$(($X + $WIDTH / 2))
|
|
|
|
MY=$(($Y + $HEIGHT / 2))
|
|
|
|
xdotool mousemove $MX $MY
|
|
|
|
'')
|
|
|
|
|
|
|
|
(pkgs.writeShellScriptBin "i3custom-window-actions" ''
|
|
|
|
${pkgs.yad}/bin/yad --splash --mouse \
|
|
|
|
--title="i3 window actions" \
|
|
|
|
--gtkrc="${HOME}/.config/i3/i3gtk.css" \
|
|
|
|
--text="i3 window actions" \
|
|
|
|
--button float:0 --button kill:1
|
|
|
|
|
|
|
|
case $? in
|
|
|
|
0) i3-msg "floating toggle";;
|
|
|
|
1) i3-msg "kill";;
|
|
|
|
-1) ;;
|
|
|
|
esac
|
|
|
|
'')
|
|
|
|
|
|
|
|
(pkgs.writeShellScriptBin "i3custom-floating-toggle" ''
|
|
|
|
i3-msg "mark --add _; [con_mark=f] floating disable, border pixel 1, mark --add --toggle _; [con_mark=_] floating enable, border normal; mark --add --toggle f;"
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
|
|
|
home.file = {
|
|
|
|
".config/i3/i3gtk.css".source = ../../files/i3gtk.css;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|