285 lines
14 KiB
Nix
285 lines
14 KiB
Nix
{ pkgs, lib, config, ... }:
|
|
let
|
|
# FOCUS
|
|
focus = "exec ${ pkgs.writeShellScript "i3-focus-window" ''
|
|
WINDOW=`${pkgs.xdotool}/bin/xdotool getwindowfocus`
|
|
eval `${pkgs.xdotool}/bin/xdotool getwindowgeometry --shell $WINDOW` # this brings in variables WIDTH and HEIGHT
|
|
TX=`${pkgs.coreutils}/bin/expr $WIDTH / 2`
|
|
TY=`${pkgs.coreutils}/bin/expr $HEIGHT / 2`
|
|
${pkgs.xdotool}/bin/xdotool mousemove -window $WINDOW $TX $TY
|
|
''
|
|
}";
|
|
|
|
# MISC
|
|
mod = config.xsession.windowManager.i3.config.modifier;
|
|
fonts = config.stylix.fonts;
|
|
rofi = "exec --no-startup-id ${config.programs.rofi.package}/bin/rofi";
|
|
modes = config.frogeye.desktop.i3.bindmodes;
|
|
in
|
|
{
|
|
config = lib.mkIf config.xsession.windowManager.i3.enable {
|
|
stylix.targets.i3.enable = false;
|
|
xsession.windowManager.i3.config = {
|
|
modifier = "Mod4";
|
|
fonts = {
|
|
names = [ fonts.sansSerif.name ];
|
|
};
|
|
terminal = "alacritty";
|
|
colors = let ignore = "#ff00ff"; in
|
|
with config.lib.stylix.colors.withHashtag; lib.mkForce {
|
|
focused = { border = base0B; background = base0B; text = base00; indicator = base00; childBorder = base0B; };
|
|
focusedInactive = { border = base02; background = base02; text = base05; indicator = base02; childBorder = base02; };
|
|
unfocused = { border = base05; background = base04; text = base00; indicator = base04; childBorder = base00; };
|
|
urgent = { border = base0F; background = base08; text = base00; indicator = base08; childBorder = base0F; };
|
|
placeholder = { border = ignore; background = base00; text = base05; indicator = ignore; childBorder = base00; };
|
|
background = base07;
|
|
# I set the color of the active tab as the the background color of the terminal so they merge together.
|
|
};
|
|
focus.followMouse = false;
|
|
keybindings =
|
|
{
|
|
# Compatibility layer for people coming from other backgrounds
|
|
"Mod1+Tab" = "${rofi} -modi window -show window";
|
|
"Mod1+F2" = "${rofi} -modi drun -show drun";
|
|
"Mod1+F4" = "kill";
|
|
# kill focused window
|
|
"${mod}+z" = "kill";
|
|
button2 = "kill";
|
|
# Rofi
|
|
"${mod}+i" = "exec --no-startup-id ${pkgs.rofimoji}/bin/rofimoji";
|
|
"${mod}+plus" = "${rofi} -modi ssh -show ssh";
|
|
"${mod}+ù" = "${rofi} -modi ssh -show ssh -ssh-command '{terminal} -e {ssh-client} {host} -t \"sudo -s -E\"'";
|
|
# TODO In which keyboard layout?
|
|
"${mod}+Tab" = "${rofi} -modi window -show window";
|
|
# start program launcher
|
|
"${mod}+d" = "${rofi} -modi run -show run";
|
|
"${mod}+Shift+d" = "${rofi} -modi drun -show drun";
|
|
# Start Applications
|
|
"${mod}+Return" = "exec ${
|
|
pkgs.writeShellScript "terminal" "${config.programs.alacritty.package}/bin/alacritty msg create-window -e zsh || exec ${config.programs.alacritty.package}/bin/alacritty -e zsh"
|
|
# -e zsh is for systems where I can't configure my user's shell
|
|
# TODO Is a shell script even required?
|
|
}";
|
|
"${mod}+Shift+Return" = "exec ${config.programs.urxvt.package}/bin/urxvt";
|
|
"${mod}+p" = "exec ${pkgs.xfce.thunar}/bin/thunar";
|
|
# Backlight
|
|
"XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%";
|
|
"XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-";
|
|
# Misc
|
|
"${mod}+F10" = "exec ${ pkgs.writeShellScript "show-keyboard-layout"
|
|
''
|
|
layout=`${pkgs.xorg.setxkbmap}/bin/setxkbmap -query | ${pkgs.gnugrep}/bin/grep ^layout: | ${pkgs.gawk}/bin/awk '{ print $2 }'`
|
|
${pkgs.libgnomekbd}/bin/gkbd-keyboard-display -l $layout
|
|
''
|
|
}";
|
|
# change focus
|
|
"${mod}+h" = "focus left; ${focus}";
|
|
"${mod}+j" = "focus down; ${focus}";
|
|
"${mod}+k" = "focus up; ${focus}";
|
|
"${mod}+l" = "focus right; ${focus}";
|
|
# move focused window
|
|
"${mod}+Shift+h" = "move left; ${focus}";
|
|
"${mod}+Shift+j" = "move down; ${focus}";
|
|
"${mod}+Shift+k" = "move up; ${focus}";
|
|
"${mod}+Shift+l" = "move right; ${focus}";
|
|
# workspace back and forth (with/without active container)
|
|
"${mod}+b" = "workspace back_and_forth; ${focus}";
|
|
"${mod}+Shift+b" = "move container to workspace back_and_forth; workspace back_and_forth; ${focus}";
|
|
# Change container layout
|
|
"${mod}+g" = "split h; ${focus}";
|
|
"${mod}+v" = "split v; ${focus}";
|
|
"${mod}+f" = "fullscreen toggle; ${focus}";
|
|
"${mod}+s" = "layout stacking; ${focus}";
|
|
"${mod}+w" = "layout tabbed; ${focus}";
|
|
"${mod}+e" = "layout toggle split; ${focus}";
|
|
"${mod}+Shift+space" = "floating toggle; ${focus}";
|
|
# Focus container
|
|
"${mod}+space" = "focus mode_toggle; ${focus}";
|
|
"${mod}+a" = "focus parent; ${focus}";
|
|
"${mod}+q" = "focus child; ${focus}";
|
|
# Switch to workspace
|
|
"${mod}+1" = "workspace 1; ${focus}";
|
|
"${mod}+2" = "workspace 2; ${focus}";
|
|
"${mod}+3" = "workspace 3; ${focus}";
|
|
"${mod}+4" = "workspace 4; ${focus}";
|
|
"${mod}+5" = "workspace 5; ${focus}";
|
|
"${mod}+6" = "workspace 6; ${focus}";
|
|
"${mod}+7" = "workspace 7; ${focus}";
|
|
"${mod}+8" = "workspace 8; ${focus}";
|
|
"${mod}+9" = "workspace 9; ${focus}";
|
|
"${mod}+0" = "workspace 10; ${focus}";
|
|
# TODO Prevent repetitions, see workspace assignation for example
|
|
#navigate workspaces next / previous
|
|
"${mod}+Ctrl+h" = "workspace prev_on_output; ${focus}";
|
|
"${mod}+Ctrl+l" = "workspace next_on_output; ${focus}";
|
|
"${mod}+Ctrl+j" = "workspace prev; ${focus}";
|
|
"${mod}+Ctrl+k" = "workspace next; ${focus}";
|
|
# Move to workspace next / previous with focused container
|
|
"${mod}+Ctrl+Shift+h" = "move container to workspace prev_on_output; workspace prev_on_output; ${focus}";
|
|
"${mod}+Ctrl+Shift+l" = "move container to workspace next_on_output; workspace next_on_output; ${focus}";
|
|
"${mod}+Ctrl+Shift+j" = "move container to workspace prev; workspace prev; ${focus}";
|
|
"${mod}+Ctrl+Shift+k" = "move container to workspace next; workspace next; ${focus}";
|
|
# move focused container to workspace
|
|
"${mod}+ctrl+1" = "move container to workspace 1; ${focus}";
|
|
"${mod}+ctrl+2" = "move container to workspace 2; ${focus}";
|
|
"${mod}+ctrl+3" = "move container to workspace 3; ${focus}";
|
|
"${mod}+ctrl+4" = "move container to workspace 4; ${focus}";
|
|
"${mod}+ctrl+5" = "move container to workspace 5; ${focus}";
|
|
"${mod}+ctrl+6" = "move container to workspace 6; ${focus}";
|
|
"${mod}+ctrl+7" = "move container to workspace 7; ${focus}";
|
|
"${mod}+ctrl+8" = "move container to workspace 8; ${focus}";
|
|
"${mod}+ctrl+9" = "move container to workspace 9; ${focus}";
|
|
"${mod}+ctrl+0" = "move container to workspace 10; ${focus}";
|
|
# move to workspace with focused container
|
|
"${mod}+shift+1" = "move container to workspace 1; workspace 1; ${focus}";
|
|
"${mod}+shift+2" = "move container to workspace 2; workspace 2; ${focus}";
|
|
"${mod}+shift+3" = "move container to workspace 3; workspace 3; ${focus}";
|
|
"${mod}+shift+4" = "move container to workspace 4; workspace 4; ${focus}";
|
|
"${mod}+shift+5" = "move container to workspace 5; workspace 5; ${focus}";
|
|
"${mod}+shift+6" = "move container to workspace 6; workspace 6; ${focus}";
|
|
"${mod}+shift+7" = "move container to workspace 7; workspace 7; ${focus}";
|
|
"${mod}+shift+8" = "move container to workspace 8; workspace 8; ${focus}";
|
|
"${mod}+shift+9" = "move container to workspace 9; workspace 9; ${focus}";
|
|
"${mod}+shift+0" = "move container to workspace 10; workspace 10; ${focus}";
|
|
# move workspaces to screen (arrow keys)
|
|
"${mod}+ctrl+shift+Right" = "move workspace to output right; ${focus}";
|
|
"${mod}+ctrl+shift+Left" = "move workspace to output left; ${focus}";
|
|
"${mod}+Ctrl+Shift+Up" = "move workspace to output above; ${focus}";
|
|
"${mod}+Ctrl+Shift+Down" = "move workspace to output below; ${focus}";
|
|
# i3 control
|
|
"${mod}+Shift+c" = "reload";
|
|
"${mod}+Shift+r" = "restart";
|
|
"${mod}+Shift+e" = "exit";
|
|
} // lib.mapAttrs' (k: v: lib.nameValuePair v.enter "mode ${v.name}") modes;
|
|
modes = lib.mapAttrs'
|
|
(k: v: lib.nameValuePair v.name (v.bindings // lib.optionalAttrs v.return_bindings {
|
|
"Return" = "mode default";
|
|
"Escape" = "mode default";
|
|
}))
|
|
modes;
|
|
window = {
|
|
hideEdgeBorders = "both";
|
|
titlebar = false; # So that single-container screens are basically almost fullscreen
|
|
commands = [
|
|
# Open specific applications in floating mode
|
|
{ criteria = { title = "^pdfpc.*"; window_role = "presenter"; }; command = "move to output left, fullscreen"; }
|
|
{ criteria = { title = "^pdfpc.*"; window_role = "presentation"; }; command = "move to output right, fullscreen"; }
|
|
# switch to workspace with urgent window automatically
|
|
{ criteria = { urgent = "latest"; }; command = "focus"; }
|
|
];
|
|
};
|
|
floating = {
|
|
criteria = [
|
|
{ window_role = "pop-up"; }
|
|
{ window_role = "task_dialog"; }
|
|
];
|
|
};
|
|
startup = [
|
|
{
|
|
notification = false;
|
|
command = "${pkgs.writeShellApplication {
|
|
name = "batteryNotify";
|
|
runtimeInputs = with pkgs; [coreutils libnotify];
|
|
text = builtins.readFile ./batteryNotify.sh;
|
|
# TODO Use batsignal instead?
|
|
# TODO Only on computers with battery
|
|
}}/bin/batteryNotify";
|
|
}
|
|
];
|
|
workspaceLayout = "tabbed";
|
|
focus.mouseWarping = true; # i3 only supports warping to workspace, hence ${focus}
|
|
workspaceOutputAssign =
|
|
let
|
|
x11_screens = config.frogeye.desktop.x11_screens;
|
|
workspaces = map (i: { name = toString i; key = toString (lib.mod i 10); }) (lib.lists.range 1 10);
|
|
forEachWorkspace = f: map (w: f { w = w; workspace = ((builtins.elemAt workspaces w)); }) (lib.lists.range 0 ((builtins.length workspaces) - 1));
|
|
in
|
|
forEachWorkspace ({ w, workspace }: { output = builtins.elemAt x11_screens (lib.mod w (builtins.length x11_screens)); workspace = workspace.name; });
|
|
};
|
|
frogeye.desktop.i3.bindmodes =
|
|
let
|
|
mode_pres_main = "Presentation (main display)";
|
|
mode_pres_sec = "Presentation (secondary display)";
|
|
in
|
|
{
|
|
"Resize" = {
|
|
bindings = {
|
|
"h" = "resize shrink width 10 px or 10 ppt; ${focus}";
|
|
"j" = "resize grow height 10 px or 10 ppt; ${focus}";
|
|
"k" = "resize shrink height 10 px or 10 ppt; ${focus}";
|
|
"l" = "resize grow width 10 px or 10 ppt; ${focus}";
|
|
};
|
|
mod_enter = "r";
|
|
};
|
|
"[L] Vérouillage [E] Déconnexion [S] Veille [H] Hibernation [R] Redémarrage [P] Extinction" = {
|
|
bindings = {
|
|
"l" = "exec --no-startup-id exec xlock, mode default";
|
|
"e" = "exit, mode default";
|
|
"s" = "exec --no-startup-id exec xlock & ${pkgs.systemd}/bin/systemctl suspend --check-inhibitors=no, mode default";
|
|
"h" = "exec --no-startup-id exec xlock & ${pkgs.systemd}/bin/systemctl hibernate, mode default";
|
|
"r" = "exec --no-startup-id ${pkgs.systemd}/bin/systemctl reboot, mode default";
|
|
"p" = "exec --no-startup-id ${pkgs.systemd}/bin/systemctl poweroff -i, mode default";
|
|
};
|
|
mod_enter = "Escape";
|
|
};
|
|
"${mode_pres_main}" = {
|
|
mod_enter = "Shift+p";
|
|
bindings = {
|
|
"b" = "workspace 3, workspace 4, mode ${mode_pres_sec}";
|
|
"q" = "mode default";
|
|
"Return" = "mode default";
|
|
};
|
|
return_bindings = false;
|
|
};
|
|
"${mode_pres_sec}" = {
|
|
mod_enter = "Shift+p+2"; # Bogus, just so I don't have to implement no binding
|
|
bindings = {
|
|
"b" = "workspace 1, workspace 2, mode ${mode_pres_main}";
|
|
"q" = "mode default";
|
|
"Return" = "mode default";
|
|
};
|
|
return_bindings = false;
|
|
};
|
|
"Temperature [R] Red [D] Dust storm [C] Campfire [O] Normal [A] All nighter [B] Blue" = {
|
|
bindings = {
|
|
"r" = "exec ${pkgs.sct}/bin/sct 1000";
|
|
"d" = "exec ${pkgs.sct}/bin/sct 2000";
|
|
"c" = "exec ${pkgs.sct}/bin/sct 4500";
|
|
"o" = "exec ${pkgs.sct}/bin/sct";
|
|
"a" = "exec ${pkgs.sct}/bin/sct 8000";
|
|
"b" = "exec ${pkgs.sct}/bin/sct 10000";
|
|
};
|
|
mod_enter = "y";
|
|
};
|
|
};
|
|
};
|
|
options = {
|
|
frogeye.desktop.i3.bindmodes = lib.mkOption {
|
|
default = { };
|
|
type = lib.types.attrsOf (lib.types.submodule ({ config, name, ... }: {
|
|
options = {
|
|
name = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = name;
|
|
};
|
|
bindings = lib.mkOption {
|
|
type = lib.types.attrsOf lib.types.str;
|
|
default = { };
|
|
};
|
|
enter = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "${mod}+${config.mod_enter}";
|
|
};
|
|
mod_enter = lib.mkOption {
|
|
type = lib.types.str;
|
|
};
|
|
return_bindings = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
};
|
|
};
|
|
}));
|
|
};
|
|
};
|
|
}
|