diff --git a/infra/libkookie/configuration/workstation/i3/tempest.nix b/infra/libkookie/configuration/workstation/i3/tempest.nix index cc8bd84eebe..556281862d9 100644 --- a/infra/libkookie/configuration/workstation/i3/tempest.nix +++ b/infra/libkookie/configuration/workstation/i3/tempest.nix @@ -7,13 +7,15 @@ # Then configure it libkookie.ui.i3 = { compton = true; + # TODO: include these files via git LFS wallpaper = /home/Pictures/Wallpapers/small-memory.webp; + + # TODO: hook into the "fonts" module? fonts = [ "Iosevka:13" ]; - i3Status = { - segments = ["ipv6" "disk" "ethernet _first_" "load" "tztime local"]; - }; + term = pkgs.kitty; + i3Status.segments = ["ipv6" "disk" "ethernet _first_" "load" "tztime local"]; }; home.packages = with pkgs; [ iosevka ]; diff --git a/infra/libkookie/modules/workstation/ui/i3/core/compton.conf b/infra/libkookie/modules/workstation/ui/i3/core/compton.conf new file mode 100644 index 00000000000..254846b9bf6 --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/compton.conf @@ -0,0 +1,7 @@ +unredir-if-possible = false; +vsync = "opengl"; + +### Opacity +menu-opacity = 0.90; +frame-opacity = 0.90; # i.e. titlebars, borders +inactive-opacity-override = false; diff --git a/infra/libkookie/modules/workstation/ui/i3/core/compton.nix b/infra/libkookie/modules/workstation/ui/i3/core/compton.nix new file mode 100644 index 00000000000..3d20aabc122 --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/compton.nix @@ -0,0 +1,9 @@ +{ config, lib, ... }: + +let cfg = config.libkookie.ui.i3; +in +lib.mkIf cfg.compton { + text = '' + ${builtins.readFile ./compton.conf} + ''; +} diff --git a/infra/libkookie/modules/workstation/ui/i3/core/config.nix b/infra/libkookie/modules/workstation/ui/i3/core/config.nix index e0fd5938ef2..6cb37916540 100644 --- a/infra/libkookie/modules/workstation/ui/i3/core/config.nix +++ b/infra/libkookie/modules/workstation/ui/i3/core/config.nix @@ -16,6 +16,31 @@ rec { inherit (cfg) fonts; - keybindings = (import ./keys.nix { inherit modifier; + keybindings = (import ./keys.nix { inherit cfg modifier; pkgs = xtraPkgs; }); + + modes = { + + # Explicitly handle the resize mode + resize = { + "h" = "resize shrink width 5 px or 5 ppt"; + "j" = "resize grow height 5 px or 5 ppt"; + "k" = "resize shrink height 5 px or 5 ppt"; + "l" = "resize grow width 5 px or 5 ppt"; + + # same bindings, but for the arrow keys + "Left" = "resize shrink width 5 px or 5 ppt"; + "Down" = "resize grow height 5 px or 5 ppt"; + "Up" = "resize shrink height 5 px or 5 ppt"; + "Right" = "resize grow width 5 px or 5 ppt"; + + # back to normal: Enter or Escape or $mod+r + "Return" = "mode \"default\""; + "Escape" = "mode \"default\""; + "${modifier}+r" = "mode \"default\""; + } ; + }; + + # The `bars` module does weird stuff so we init it ourselves + bars = []; } diff --git a/infra/libkookie/modules/workstation/ui/i3/core/i3status.nix b/infra/libkookie/modules/workstation/ui/i3/core/i3status.nix index 6efcd281e1d..a5280fd9d49 100644 --- a/infra/libkookie/modules/workstation/ui/i3/core/i3status.nix +++ b/infra/libkookie/modules/workstation/ui/i3/core/i3status.nix @@ -4,11 +4,11 @@ let # Grab settings from the submodule cfg = config.libkookie.ui.i3.i3Status; - colors = (builtins.toString cfg.colors); + colors = if cfg.colors then "true" else "false"; interval = (builtins.toString cfg.interval); # Utility functions to build the config - append = (seg: "order += ${seg}"); + append = (seg: "order += \"${seg}\""); in with lib.mkIf; { @@ -16,7 +16,6 @@ with lib.mkIf; general { colors = ${colors} interval = ${interval} - format = ${cfg.format} } ${lib.concatMapStringsSep "\n" (l: append l) cfg.segments} diff --git a/infra/libkookie/modules/workstation/ui/i3/core/keys.nix b/infra/libkookie/modules/workstation/ui/i3/core/keys.nix index 05497926cc5..13bb7ee6ed2 100644 --- a/infra/libkookie/modules/workstation/ui/i3/core/keys.nix +++ b/infra/libkookie/modules/workstation/ui/i3/core/keys.nix @@ -1,8 +1,9 @@ -{ pkgs, modifier }: +{ cfg, pkgs, modifier }: { # Start a terminal - "${modifier}+Return" = "exec ${pkgs.kitty}/bin/kitty"; + # TODO: this might fail + "${modifier}+Return" = "exec ${cfg.term}/bin/${cfg.term.pname}"; # Area screenshot support "${modifier}+9" = "exec ${pkgs.libkookie-i3-scrcap}"; @@ -22,6 +23,7 @@ # Rename workspaces "${modifier}+Ctrl+r" = "exec ${pkgs.libkookie-i3-rename}"; + # Move focus around - vim style "${modifier}+h" = "focus left"; "${modifier}+t" = "focus up"; diff --git a/infra/libkookie/modules/workstation/ui/i3/core/setup.nix b/infra/libkookie/modules/workstation/ui/i3/core/setup.nix index 17a77f6f554..1bd03abf367 100644 --- a/infra/libkookie/modules/workstation/ui/i3/core/setup.nix +++ b/infra/libkookie/modules/workstation/ui/i3/core/setup.nix @@ -16,6 +16,42 @@ enable = true; package = pkgs.i3; inherit config; + + # TODO: move this into the config module? + + extraConfig = with pkgs; '' + # Setup compton compositor + exec_always --no-startup-id "${coreutils}/bin/pkill compton; ${compton}/bin/compton --config ~/.config/i3/compton.conf" + + # Make CAPSLOCK into ESC because it's 2018 + # + # Okay actually this is slightly more complicated than that. I'm binding + # CAPSLOCK to HYPER, so that I can use it as a modifier in emacs, but then + # using xcape(1) to also make short CAPSLOCK presses into ESCAPE. + + exec_always --no-startup-id "${xorg.xmodmap}/bin/setxkbmap -layout us -variant altgr-intl -option caps:hyper" + exec ${xcape}/bin/xcape -e "#66=Escape" -t 150 + + # Always set a wallpaper + # exec_always --no-startup-id ${feh}/bin/feh --bg-fill config.libkookie.ui.i3.wallpaper ????? + + bar { + status_command ${i3status}/bin/i3status -c ~/.config/i3/i3status.conf + position bottom + bindsym button4 nop + bindsym button5 nop + colors { + background #0F0F0F + statusline #D5D5D5 + } + } + + focus_follows_mouse no + + # Layout and design settings that should _really_ be in the module + default_border pixel 3 + client.focused #4c7899 #285577 #ffffff #F73E5F #666666 + ''; }; xdg.configFile."i3/compton.conf" = (import ./compton.nix args); diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix index 40ce022c614..1196dc28c46 100644 --- a/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix +++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix @@ -5,4 +5,5 @@ libkookie-i3-switch = (import ./i3-switch.nix args); libkookie-i3-rename = (import ./i3-rename.nix args); libkookie-i3-scrcap = (import ./i3-scrcap.nix args); + libkookie-i3-locker = (import ./i3-locker.nix args); } diff --git a/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-locker.nix b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-locker.nix new file mode 100644 index 00000000000..749d41e4eb3 --- /dev/null +++ b/infra/libkookie/modules/workstation/ui/i3/core/tools/i3-locker.nix @@ -0,0 +1,47 @@ +/** A utility script to lock the screen + * + * This tool relies on i3lock, ./lock.png, fortune, and imagemagic to + * create a picture to fill all available screens + */ + +{ pkgs, ... }: +with pkgs; +let + lockIcon = "${i3lock-fancy}/share/i3lock-fancy/icons/lock.png"; + i3lock = "${i3lock}/bin/i3lock"; + mktemp = "${coreutils}/bin/mktemp"; + rm = "${coreutils}/bin/rm"; + fortune = "${fortune}/bin/fortune"; + xrandr = "${xrandr}/bin/xrandr"; + convert = "${imagemagick}/bin/convert"; +in +writeShellScript "libkookie-i3locker" '' + + # Create a temp directory to work in + TMPDIR=$(${mktemp} -d) + BGIMAGE=$TMPDIR/lockbg.png + FORTUNE=$(${fortune} | sed -e 's/\t/ /g') + TMPRES=$(${xrandr} | grep \* | cut -d' ' -f4 | sed ':a;N;$!ba;s/\n/ /g') + RESOLUTION=$(`echo $TMP_RES | sed 's/ /\n/g'`) + + # Create a base image + ${convert} -size 0x0 canvas:black $BGIMAGE + + for mon in "${RESOLUTION[@]}" + do + echo "Running for monitor $mon" + TMPLOCK="$TMPDIR/tmplock.png" + ${convert} -size "$mon" canvas:black -font Inconsolata -pointsize 18 \ + -fill white -gravity center -annotate +0+250 "$FORTUNE" \ + "${lockIcon}" -gravity center -composite "$TMPLOCK" + + ${convert} "$IMAGE" "$TMPLOCK" +append "$IMAGE" + ${rm} "TMPLOCK" + done + + # Lock the screen + ${i3lock} -i "$IMAGE" + + # Remove all the temp images + ${rm} -rf $TMPDIR +'' diff --git a/infra/libkookie/modules/workstation/ui/i3/default.nix b/infra/libkookie/modules/workstation/ui/i3/default.nix index e4fa23b2878..a079fa0fb3f 100644 --- a/infra/libkookie/modules/workstation/ui/i3/default.nix +++ b/infra/libkookie/modules/workstation/ui/i3/default.nix @@ -20,7 +20,8 @@ with lib; type = with types; listOf str; default = []; description = '' - The set of video drivers to instantiate on a given system + The set of video drivers to instantiate on a given system. + This setting is passed through to the X11 configuration. ''; }; }; diff --git a/infra/libkookie/modules/workstation/ui/i3/hm.nix b/infra/libkookie/modules/workstation/ui/i3/hm.nix index 23aef4337a6..2453975f529 100644 --- a/infra/libkookie/modules/workstation/ui/i3/hm.nix +++ b/infra/libkookie/modules/workstation/ui/i3/hm.nix @@ -27,6 +27,11 @@ in ''; }; + term = mkOption { + type = types.package; + description = "Terminal emulator to bind to "; + }; + i3Status = mkOption { type = with types; submodule { options = {