Extend shared xorg-twm configurations to i3

This commit is contained in:
Protesilaos Stavrou 2023-10-05 13:25:12 +03:00
parent e80e3d67dc
commit 6cd475d84a
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA
9 changed files with 255 additions and 24 deletions

View file

@ -58,35 +58,52 @@ run stow again with the `-R` flag:
## Window managers
I used to have configurations for bspwm, herbstluftwm, and swaywm.
Since 2023-02-24 I have removed sway: Wayland is not ready for my
purposes and I have had no issues whatsoever with Xorg. I also tried
GNOME for a while to get a feel for Wayaland and see how Emacs
compiled `--with-pgtk` performs. In short: Emacs is the same and
Wayland is not as featureful as Xorg.
My two tiling window managers are bspwm and herbstluftwm. They are
both configured to be almost the same: they share settings for the
wallpaper, system panel, theme, keyboard layout, and display
compositor. All settings are in the `xorg-twm` directory ("twm"
stands for "tiling window manager"). What differentiates the two
window managers is their individual features.
My tiling window managers are bspwm, herbstluftwm, and i3 (in no
particular order). They are all configured to be almost the same:
they share settings for the wallpaper, system panel, theme, keyboard
layout, and display compositor. All settings are in the `xorg-twm`
directory ("twm" stands for "tiling window manager"). What
differentiates the window managers is their individual features.
+ **bspwm:** I have been using it for years and consider it top-notch.
It is stable and scriptable. Use this if you prefer automatic
tiling.
It is minimal, stable, and scriptable. Use this if you prefer
automatic tiling. It does not have layout features out-of-the-box,
such as a tabbed layout: it can place windows in tiles or float
them.
+ **herbstluftwm (hlwm):** Shares many concepts with bspwm, though
herbstluftwm prioritises manual tiling methods and can treat
arbitrary rectangles of a monitor as virtual monitors. The virtual
monitors feature is perfect for anyone with a widescreen display.
The one I have (which is not mine, but anyway) is 2560x1080, so I
split it by default into a regular 1920x1080 area and another
"sidebar" of 640x1080.
+ **herbstluftwm (hlwm):** herbstluftwm prioritises manual tiling
methods and can treat arbitrary rectangles of a monitor as virtual
monitors. The virtual monitors feature is perfect for anyone with a
widescreen display. The one I have (which is not mine, but anyway)
is 2560x1080, so I split it by default into a regular 1920x1080 area
and another "sidebar" of 640x1080. herbstluftwm has the concept of
"frame", which is a container of regular windows. Each frame can
have its own layout, including a vertical/horizontal stack, grid,
and tabbed.
+ **i3 (or i3wm):** The first tiling window manager I ever used (circa
2017). The reason I abandoned it back in the day in favour of bspwm
is because its default tiling method requires manual intervention to
change the split direction. On a small laptop monitor, I prefer
this to be done automatically, hence bspwm. Though on a wide
monitor, I typically keep the split direction constant. i3 has the
concept of the "container" (same as herbstluftwm "frame"), which can
be set to stacked, tabbed, or tiled layouts. As such, i3 is
somewhere between bspwm and herbstluftwm. Choose according to your
needs.
Check the `xtwm-key-binding-cheatsheet.md` file for an overview of
their key bindings.
When I have a video call or record a video of my desktop session, I
always use herbstluftwm because of its ability to support virtual
monitors. Otherwise I oscillate between bspwm and i3, depending on
the machine I am using.
What about Wayland? It is not ready yet: I am missing something like
sxhkd and certain applications do not work properly on it. I may
check again in a few years.
## Copying
Unless otherwise noted, all code herein is distributed under the terms

View file

@ -221,6 +221,54 @@ _bspwm_or_hlwm ()
fi
}
# TODO 2023-10-05: Merge with `_bspwm_or_hlwm'?
_i3 ()
{
_gnome_theme
wm_theme_file="$HOME"/.config/prot-xtwm-active-theme
# focus_mode_status="$HOME"/.config/prot-xtwm-focus-mode
echo "$style" > "$wm_theme_file"
wm_theme="$style"
_emacs "$style" &
_xsettingsd "$style" &
_xterm &
# # NOTE 2021-09-25: I tried alacritty for a while, but the way it
# reads the fonts on Xorg makes the point size larger than expected.
# Also, it seems to miss some smaller sizes, so I cannot use it
# exactly how I want to. Everything is fine on Wayland with Sway...
#
# _alacritty &
_feh &
_rofi &
# TODO 2023-10-05: focus mode for i3
# if [ -f $focus_mode_status ] && [ "$(sed 1q "$focus_mode_status")" = off ]
# then
# _polybar launch
# else
# # Just update the colours, but do not launch the process.
# _polybar
# fi
_polybar launch
active_theme="$HOME"/.config/i3/i3-theme
[ -f "$active_theme" ] || { echo "No active theme"; exit 1; }
case $wm_theme
in
light) _sed "s,vivendi,operandi," "$active_theme" ;;
dark) _sed "s,operandi,vivendi," "$active_theme" ;;
esac
i3-msg -t command reload
}
#### Gsettings
_gsettings ()
@ -334,6 +382,7 @@ in
_bspwm_or_hlwm
;;
i3) _i3 ;;
gnome) _gnome ;;
mate) _mate ;;
xfce) _xfce ;;

View file

@ -0,0 +1,46 @@
# i3 config file (v4)
# NOTE 2023-10-05: The above line is required.
#
# Since i3 4.0, a new configuration format is used. i3 will try to
# automatically detect the format version of a config file based on a
# few different keywords, but if you want to make sure that your config
# is read with the new format, include the following line in your config
# file: [...]
#
# <https://i3wm.org/docs/userguide.html>
gaps inner 15px
gaps outer 0
smart_gaps inverse_outer
default_border pixel 3
default_floating_border pixel 1
hide_edge_borders both
smart_borders on
focus_follows_mouse yes
workspace_auto_back_and_forth yes
focus_on_window_activation smart
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block.
font pango:monospace 8
title_align center
# Start XDG autostart .desktop files using dex. See also
# https://wiki.archlinux.org/index.php/XDG_Autostart
exec --no-startup-id dex --autostart --environment i3
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier mod4
# move tiling windows via drag & drop by left-clicking into the title bar,
# or left-clicking anywhere into the window while holding the floating modifier.
tiling_drag modifier titlebar
include i3-theme
# Common settings used by all my Xorg tiling window managers, which
# include i3WM, BSPWM, and Herbstluftwm. I configure them to be
# similar. This means, among others, that I define key bindings using
# SXHKD instead of the native configuration method (where applicable).
exec command -v xtwm_common > /dev/null && xtwm_common

View file

@ -0,0 +1,10 @@
# Colours based on my 'modus-themes' for Emacs.
# <colorclass> <border> <bg> <text> <indicator> <child_border>
client.focused #3548cf #bbc3ff #000000 #bb6700 #3548cf
client.focused_inactive #8f0075 #fbc3ff #000000 #bb6700 #8f0075
client.focused_tab_title #bbc3ff #bbc3ff #000000 #bb6700 #bbc3ff
client.unfocused #d7d7d7 #d7d7d7 #000000 #bb6700 #d7d7d7
client.urgent #a60000 #a60000 #000000 #bb6700 #a60000
# client.placeholder
client.background #ffffff

View file

@ -0,0 +1,10 @@
# Colours based on my 'modus-themes' for Emacs.
# <colorclass> <border> <bg> <text> <indicator> <child_border>
client.focused #79a8ff #2f337f #ffffff #ffa200 #79a8ff
client.focused_inactive #f78fe7 #7f337f #ffffff #ffa200 #f78fe7
client.focused_tab_title #2f337f #2f337f #ffffff #ffa200 #2f337f
client.unfocused #575757 #575757 #ffffff #ffa200 #575757
client.urgent #a60000 #a60000 #ffffff #ffa200 #a60000
# client.placeholder
client.background #000000

View file

@ -0,0 +1 @@
include i3-modus-operandi

View file

@ -5,6 +5,35 @@ margin-bottom = 0
[colors]
include-file = ~/.config/polybar/config_colors
[bar/i3]
width = 100%
height = 18
bottom = true
radius = 0
fixed-center = false
background = ${colors.bg-main}
foreground = ${colors.fg-main}
padding-left = 0
padding-right = 1
module-margin-left = 0
module-margin-right = 2
font-0 = Monospace:size=8:hintstyle=hintslight;2
font-1 = Monospace:weight=bold:size=8:hintstyle=hintslight;2
tray-position = right
tray-padding = 5
format-margin = 0
modules-left = i3 title
modules-center =
modules-right = xkeyboard alsa date
override-redirect = false
[bar/bspwm]
width = 100%
height = 18
@ -63,8 +92,26 @@ tray-padding = 5
format-margin = 0
; wm-restack = bspwm
; override-redirect = false
[module/i3]
type = internal/i3
label-focused = "[%name%]"
label-focused-font = 2
label-unfocused = " %name%^ "
label-unfocused-foreground = ${colors.fg-dim}
label-visible = " %name%^ "
label-visible-foreground = ${colors.fg-dim}
label-urgent = " %name%! "
label-urgent-font = 2
label-urgent-foreground = ${colors.red}
label-empty = ""
label-empty-foreground = ${colors.fg-dim}
format = <label-state> <label-mode>
[module/ewmh]
type = internal/xworkspaces

View file

@ -0,0 +1,50 @@
#
# SXHKD module with i3-specific commands
#
# Part of my dotfiles: https://git.sr.ht/~protesilaos/dotfiles
#
### Description
#
# Partial configuration file for the Simple X Hotkey Daemon. Meant to
# work with `i3`. This is part of my dotfiles, which are managed with
# GNU Stow. See https://git.sr.ht/~protesilaos/dotfiles
### Code
# Reload the i3 config, restart the session in place, or exit
mod4 + e ; {c,r,q}
i3-msg -t command {reload,restart,exit}
mod4 + {t,s}
i3-msg -t command {layout,split} toggle
# Close currently focused window.
mod4 + q
i3-msg -t command kill
#### Focus/swap windows/desktops
# Focus the window in the given direction.
mod4 + {h,j,k,l,a}
i3-msg -t command focus {left,down,up,right,parent}
# Same as above, with arrow keys.
mod4 + {Left,Down,Up,Right}
i3-msg -t command focus {left,down,up,right}
# Move focused window in the given direction.
mod4 + shift + {h,j,k,l}
i3-msg -t command move {left,down,up,right}
# Same as above, with arrow keys.
mod4 + shift + {Left,Down,Up,Right}
i3-msg -t command move {left,down,up,right}
mod4 + {_,shift + }{0-9}
i3-msg -t command {workspace number,move container to workspace number} {0-9}
# Toggle floating, tiled, fullscreen view. Tiled is what is used by
# default. Floating windows have their own dimensions and can be stacked
# on top of each other.
mod4 + {shift + space,f}
i3-msg -t command {floating toggle,fullscreen}

View file

@ -73,6 +73,7 @@ _quit()
case "$DESKTOP_SESSION"
in
bspwm) bspc quit ;;
i3) i3-msg -t command exit ;;
herbstluftwm) herbstclient quit ;;
esac
}