aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/modules
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-12-22 20:38:50 +0100
committerMx Kookie <kookie@spacekookie.de>2020-12-22 20:43:44 +0100
commitdceec84b009fb7cf9f62d0131497a6db53d38825 (patch)
tree6d70cf3dbe7b8249cdd664fc65ac3bcb466ef484 /infra/libkookie/modules
parent76f3d25f0c193a4e837632bd3d341ef7386c4193 (diff)
libkookie: i3: adding compton and various improvements
Diffstat (limited to 'infra/libkookie/modules')
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/compton.conf7
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/compton.nix9
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/config.nix27
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/i3status.nix5
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/keys.nix6
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/setup.nix36
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/default.nix1
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/core/tools/i3-locker.nix47
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/default.nix3
-rw-r--r--infra/libkookie/modules/workstation/ui/i3/hm.nix5
10 files changed, 139 insertions, 7 deletions
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 000000000000..254846b9bf6f
--- /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 000000000000..3d20aabc122a
--- /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 e0fd5938ef2f..6cb379165406 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 6efcd281e1dc..a5280fd9d499 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 05497926cc5c..13bb7ee6ed2d 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 17a77f6f5549..1bd03abf367f 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 40ce022c6144..1196dc28c46c 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 000000000000..749d41e4eb39
--- /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 e4fa23b28784..a079fa0fb3fb 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 23aef4337a67..2453975f5292 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 <M-RET>";
+ };
+
i3Status = mkOption {
type = with types; submodule {
options = {