diff options
Diffstat (limited to 'modules/workstation/graphics/i3')
-rw-r--r-- | modules/workstation/graphics/i3/compton.conf | 20 | ||||
-rw-r--r-- | modules/workstation/graphics/i3/config.nix | 166 | ||||
-rw-r--r-- | modules/workstation/graphics/i3/default.nix | 22 | ||||
-rwxr-xr-x | modules/workstation/graphics/i3/dynamic-tags/move.sh | 13 | ||||
-rwxr-xr-x | modules/workstation/graphics/i3/dynamic-tags/switch.sh | 9 | ||||
-rw-r--r-- | modules/workstation/graphics/i3/i3status.conf | 47 | ||||
-rw-r--r-- | modules/workstation/graphics/i3/locker | 25 |
7 files changed, 302 insertions, 0 deletions
diff --git a/modules/workstation/graphics/i3/compton.conf b/modules/workstation/graphics/i3/compton.conf new file mode 100644 index 00000000000..a632c022593 --- /dev/null +++ b/modules/workstation/graphics/i3/compton.conf @@ -0,0 +1,20 @@ +unredir-if-possible = false; +vsync = "opengl"; + +### Opacity +menu-opacity = 0.90; +frame-opacity = 0.90; # i.e. titlebars, borders +inactive-opacity-override = false; +alpha-step = 0.06; + +### Blur options +blur-background = true; +blur-background-frame = true; +# blur-kern = "3x3box" +# blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1" +# blur-background-fixed = true; +blur-background-exclude = [ "window_type = 'dock'", "window_type = 'desktop'" ]; + +# # Detect rounded corners and treat them as rectangular when --shadow-ignore-shaped is on. +detect-rounded-corners = true; +detect-client-opacity = true diff --git a/modules/workstation/graphics/i3/config.nix b/modules/workstation/graphics/i3/config.nix new file mode 100644 index 00000000000..746c2a47698 --- /dev/null +++ b/modules/workstation/graphics/i3/config.nix @@ -0,0 +1,166 @@ +{ pkgs, wallpaper }: + +{ + enable = true; + package = pkgs.i3; + config = rec { + modifier = "Mod4"; + + # Use iosevka as default font + fonts = [ "iosevka-term-ss09 10" ]; + + keybindings = { + + # Start a terminal + "${modifier}+Return" = "exec kitty"; + + # Close individual windows + "${modifier}+Shift+q" = "kill"; + + # Full-screen window + "${modifier}+f" = "fullscreen"; + + # Start software on <this> or <other> workspace + "${modifier}+d" = "exec dmenu_run"; + "${modifier}+Shift+d" = "exec ~/.config/i3/dynamic-tags/move.sh"; + + # Move focus around - vim style + "${modifier}+h" = "focus left"; + "${modifier}+j" = "focus down"; + "${modifier}+k" = "focus up"; + "${modifier}+l" = "focus right"; + + # Move focus around - boring style + "${modifier}+Up" = "focus up"; + "${modifier}+Down" = "focus down"; + "${modifier}+Left" = "focus left"; + "${modifier}+Right" = "focus right"; + + # Move windows - vim style + "${modifier}+Shift+k" = "move up"; + "${modifier}+Shift+j" = "move down"; + "${modifier}+Shift+h" = "move left"; + "${modifier}+Shift+l" = "move right"; + + # Move windows - boring style + "${modifier}+Shift+Up" = "move up"; + "${modifier}+Shift+Down" = "move down"; + "${modifier}+Shift+Left" = "move left"; + "${modifier}+Shift+Right" = "move right"; + + # Move workspaces between multi-monitor setups + "${modifier}+Ctrl+Shift+Up" = "move workspace to output up"; + "${modifier}+Ctrl+Shift+Down" = "move workspace to output down"; + "${modifier}+Ctrl+Shift+Left" = " move workspace to output left"; + "${modifier}+Ctrl+Shift+Right" = "move workspace to output right"; + + # Define split behaviours + "${modifier}+2" = "split h"; + "${modifier}+1" = "split v"; + + # A very fortunate lockscreen + "${modifier}+Ctrl+l" = "exec --no-startup-id i3lock -c 333333"; + "${modifier}+Ctrl+Shift+l" = "exec --no-startup-id systemctl hibernate"; + + # Rename workspaces + "${modifier}+Ctrl+r" = "exec i3-input -F 'rename workspace to \"%s\"' -P 'New name: '"; + + # Switch to workspace (optionally dragging windows with) + "${modifier}+s" = "exec ~/.config/i3/dynamic-tags/switch.sh -fn '$dfont'"; + "${modifier}+Shift+s" = "exec ~/.config/i3/dynamic-tags/move.sh -fn '$dfont'"; + + # Some layout modifiers + "${modifier}+e" = "layout default"; + "${modifier}+w" = "layout tabbed"; + "${modifier}+q" = "layout stacked"; + + # Do I even use this?! + "${modifier}+Shift+space" = "floating toggle"; + "${modifier}+space" = "focus mode_toggle"; + + # Focus the parent containers + "${modifier}+a" = "focus parent"; + + # Audio is good actually + "XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume 0 +5%"; + "XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume 0 -5%"; + "XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute 0 toggle"; + + # Reload, restart and quit i3 + "${modifier}+Shift+c" = "reload"; + "${modifier}+Shift+r" = "restart"; + "${modifier}+Shift+e" = '' + exec i3-nagbar -t warning -m "Workspaces are sentient, you know. \ + We just have a lot of them" "i3-msg exit" + ''; + + # Switch to resize mode (defined below) + "${modifier}+r" = "mode \"resize\""; + + # FIXME: What was this again?! + "button4" = "nop"; + "button5" = "nop"; + }; + + 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 = []; + }; + + extraConfig = with pkgs; '' + # Compton + exec_always --no-startup-id "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. Actually 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 ${wallpaper} + + bar { + status_command i3status -c ~/.config/i3/i3status.conf + position bottom + bindsym button4 nop + bindsym button5 nop + colors { + background #0F0F0F + statusline #D5D5D5 + }k + } + + 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 + ''; +} diff --git a/modules/workstation/graphics/i3/default.nix b/modules/workstation/graphics/i3/default.nix new file mode 100644 index 00000000000..251b04ec202 --- /dev/null +++ b/modules/workstation/graphics/i3/default.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: + +let + wallpaper = "~/pictures/wallpaper/my-cyber-city-4k-28-2560x1440.jpg"; +in +{ + xsession.windowManager.i3 = import ./config.nix { inherit pkgs wallpaper; }; + + xdg.configFile."i3/dynamic-tags/" = { + recursive = true; + executable = true; + source = ./dynamic-tags; + }; + + xdg.configFile."i3/compton.conf" = { + source = ./compton.conf; + }; + + xdg.configFile."i3/i3status.conf" = { + source = ./i3status.conf; + }; +} diff --git a/modules/workstation/graphics/i3/dynamic-tags/move.sh b/modules/workstation/graphics/i3/dynamic-tags/move.sh new file mode 100755 index 00000000000..84f39fdc3ac --- /dev/null +++ b/modules/workstation/graphics/i3/dynamic-tags/move.sh @@ -0,0 +1,13 @@ +#!/bin/sh +### Move a window to a given workspace. If it doesn't exist it creates it. + +I3MSG=$(command -v i3-msg) || exit 1 +JQ=$(command -v jq) || exit 2 + +WORKSPACE=$($I3MSG -t get_workspaces | $JQ -M '.[] | .name' | tr -d '"' | sort -u | dmenu -b -i "$@") + +# Move the window first +$I3MSG -t command move workspace $WORKSPACE + +# Then move the user +$I3MSG workspace $WORKSPACE diff --git a/modules/workstation/graphics/i3/dynamic-tags/switch.sh b/modules/workstation/graphics/i3/dynamic-tags/switch.sh new file mode 100755 index 00000000000..9c50eb48083 --- /dev/null +++ b/modules/workstation/graphics/i3/dynamic-tags/switch.sh @@ -0,0 +1,9 @@ +#!/bin/sh +### Move the focus to a particular workspace using dmenu. + +set -u + +I3MSG=$(command -v i3-msg) || exit 1 +JQ=$(command -v jq) || exit 2 + +$I3MSG workspace $($I3MSG -t get_workspaces | $JQ -M '.[] | .name' | tr -d '"' | sort -u | dmenu -b -i "$@") diff --git a/modules/workstation/graphics/i3/i3status.conf b/modules/workstation/graphics/i3/i3status.conf new file mode 100644 index 00000000000..fb36d20e7a0 --- /dev/null +++ b/modules/workstation/graphics/i3/i3status.conf @@ -0,0 +1,47 @@ +# i3status configuration file. +# see "man i3status" for documentation. + +# It is important that this file is edited as UTF-8. +# The following line should contain a sharp s: +# ß +# If the above line is not correctly displayed, fix your editor first! + +general { + colors = true + interval = 5 +} + +order += "ipv6" +order += "disk /" +order += "wireless _first_" +order += "ethernet _first_" +order += "battery all" +order += "load" +order += "tztime local" + +wireless _first_ { + format_up = "W: (%quality at %essid) %ip" + format_down = "W: <down>" +} + +ethernet _first_ { + # if you use %speed, i3status requires root privileges + format_up = "E: %ip (%speed)" + format_down = "E: <down>" +} + +battery all { + format = "%status %percentage" +} + +tztime local { + format = "%Y-%m-%d %H:%M:%S" +} + +load { + format = "%1min" +} + +disk "/" { + format = "%avail" +} diff --git a/modules/workstation/graphics/i3/locker b/modules/workstation/graphics/i3/locker new file mode 100644 index 00000000000..af64e74eb6b --- /dev/null +++ b/modules/workstation/graphics/i3/locker @@ -0,0 +1,25 @@ +#!/bin/sh + +BASEDIR="/tmp/i3lock" +ICON="/usr/share/i3lock-fancy/icons/lock.png" +IMAGE="$BASEDIR/lock.png" +FORTUNE=$(fortune | sed -e 's/\t/ /g') +TMP_RES=$(xrandr | grep \* | cut -d' ' -f4 | sed ':a;N;$!ba;s/\n/ /g') +RESOLUTION=(`echo $TMP_RES | sed 's/ /\n/g'`) + +mkdir -p "$BASEDIR" +convert -size 0x0 canvas:black "$IMAGE" + +for monitor in "${RESOLUTION[@]}" +do + echo "Running for monitor $monitor" + TMPLOCK="/tmp/i3lock/tmplock.png" + convert -size "$monitor" canvas:black -font Inconsolata -pointsize 18 \ + -fill white -gravity center -annotate +0+250 "$FORTUNE" \ + "$ICON" -gravity center -composite "$TMPLOCK" + convert "$IMAGE" "$TMPLOCK" +append "$IMAGE" + rm "$TMPLOCK" +done + +i3lock -i "$IMAGE" + |