Xorg setup
# xbps-install xorg
This also installs:
- xinit: start X and execute ~/.xinitrc
- xsetroot: set parameters of X root window
- xrandr: display and set parameters of your screens
Keyboard
Create /etc/X11/xorg.conf.d/10-keyboard.conf to set keyboard layout:
Section "InputClass"
Identifier "Keyboard Defaults"
MatchIsKeyboard "yes"
Option "XkbLayout" "cz"
EndSection
Xinitrc
~/.xinitrc starts all that makes up my graphical environment:
# source global executable scripts
if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
unset f
fi
# load settings from ~/.Xresources
xrdb -merge ~/.Xresources
# disable xorg bell
xset -b &
# set default cursor
xsetroot -cursor_name left_ptr &
# start dbus and export its variables
eval "$(dbus-launch --sh-syntax)"
# propagate environment variables to dbus
dbus-update-activation-environment --all
# variables for later use in scripts
export PRIMARY_SCREEN=$(xrandr --query | awk '/ primary/{print $1}')
export PANEL_HEIGHT=16
# automount usb drives and notify about it using herbe
devmon --exec-on-drive "herbe \"Mount %l %f to %d\"" &
# clipboard manager
clipmenud &
# make screen warmer in the evening
redshift-gtk &
# script launching pscircle with custom settings to use as background
pscirclebg.sh &
# hotkeys mainly to control window manager
sxhkd -m 1 &
# window manager
exec bspwm
More about things launched here:
Graphics drivers
What is your gpu:
$ lspci | grep -i vga
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
Void handbook will help you find what to install.
# xbps-install vulkan-loader mesa-vulkan-intel Vulkan-Tools intel-video-accel xf86-video-intel libva-intel-driver
Use xf86-video-intel for old cards, new cards should work better with the modesetting driver. Use libva-intel-driver for old cards and intel-media-driver for newer cards.
Make /etc/X11/xorg.conf.d/20-intel.conf:
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "TearFree" "true"
EndSection
test vulkan by running:
$ vkcube
MESA-INTEL: warning: Ivy Bridge Vulkan support is incomplete
Selected GPU 0: Intel(R) HD Graphics 4000 (IVB GT2), type: IntegratedGpu
After reboot, check whether X is using the correct driver:
# grep -i intel /var/log/Xorg.0.log
You should not see an error:
[ 25.416] (==) Matched intel as autoconfigured driver 0
[ 25.416] (II) LoadModule: "intel"
[ 25.417] (WW) Warning, couldn't open module intel
[ 25.417] (EE) Failed to load module "intel" (module does not exist, 0)
You should see something like this:
[ 39.630] (II) LoadModule: "intel"
[ 39.631] (II) Loading /usr/lib64/xorg/modules/drivers/intel_drv.so
[ 39.635] (II) Module intel: vendor="X.Org Foundation"
[ 39.635] (II) intel: Driver for Intel(R) Integrated Graphics Chipsets:
[ 39.635] (II) intel: Driver for Intel(R) HD Graphics
[ 39.635] (II) intel: Driver for Intel(R) Iris(TM) Graphics
[ 39.635] (II) intel: Driver for Intel(R) Iris(TM) Pro Graphics
[ 39.636] (II) intel(0): Using Kernel Mode Setting driver: i915, version 1.6.0 0
Fonts
xbps-install terminus-font font-fira font-firacode
To browse your fonts you can use font-manager.
Font configurations
Find out your subpixel layout: http://www.lagom.nl/lcd-test/subpixel.php
Put consistent settings into some of these configuration files; you must figure out what settings look best on your system by looking at the applications that you use.\
All modern applications should respect ~/.config/fontconfig/fonts.conf:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<edit name="antialias" mode="assign">
<bool>true</bool>
</edit>
<edit name="hinting" mode="assign">
<bool>true</bool>
</edit>
<edit name="hintstyle" mode="assign">
<const>hintslight</const>
</edit>
<edit name="rgba" mode="assign">
<const>rgb</const>
</edit>
<edit name="autohint" mode="assign">
<bool>true</bool>
</edit>
<edit name="lcdfilter" mode="assign">
<const>lcddefault</const>
</edit>
<edit name="dpi" mode="assign">
<double>96</double>
</edit>
</match>
</fontconfig>
Xft settings mostly affect old-school X11 applications - ~/.Xresources:
Xft.dpi: 96
Xft.antialias: 1
Xft.hinting: 1
Xft.rgba: rgb
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintslight
Xft.autohint: 1
For GTH applications you may try ~/.config/gtk-3.0/settings.ini
[Settings]
gtk-font-name=Fira Sans 11
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle=hintslight
gtk-xft-rgba=rgb
For Qt applications you can use qt5ct
to generate ~/.config/qt5ct/qt5ct.conf
[Fonts]
fixed="Firacode,12,-1,5,50,0,0,0,0,0"
general="Fira sans,11,-1,5,50,0,0,0,0,0"
If there seems to be doubt about dpi, try putting it in ~/.profile
export QT_FONT_DPI=96
Setting prefered fonts
I want to use Fira Code as my default monospace font. I also don’t like Courier.
In ~/.config/fontconfig/fonts.conf:
<fontconfig>
<alias>
<family>monospace</family>
<prefer><family>Firacode</family></prefer>
</alias>
<match target="pattern">
<test name="family"><string>Courier</string></test>
<edit name="family" mode="assign" binding="strong">
<string>Firacode</string>
</edit>
</match>
</fontconfig>
Regenerate cache after editing configuration:
$ fc-cache -fv
You can test it by seeing which font will be used when Courier is requested:
$ fc-match Courier
FiraCode-Regular.ttf: "Fira Code" "Regular"
Fonts in browser are sometimes ugly
Package xorg-fonts includes bitmap font called Helvetica. This font is used on websites that include Helvetica in font-family (which is often) and does not look great.
There is a github issue Helvetica shouldn’t be a bitmap font provided by xorg-fonts-75dpi,
which looks like this:
\
Switch it for a more suitable font in ~/.config/fontconfig/fonts.conf:
<fontconfig>
<match target="pattern">
<test name="family"><string>Helvetica</string></test>
<edit name="family" mode="assign" binding="strong">
<string>Fira sans</string>
</edit>
</match>
</fontconfig>
Test it:
$ fc-cache -f
$ fc-match Helvetica
FiraSans-Regular.ttf: "Fira Sans" "Regular"
or by looking at now beautiful websites.
Clipboard
There are two main selections:
PRIMARY - text is copied when selected and pasted by clicking mouse middle button
CLIPBOARD - text or other data are copied and pasted by keyboard shortcuts or menu items
Manager
- clipmenu - a simple clipboard manager using dmenu and xclip
# xbps-install clipmenu
It has two components:
- clipmenud: while it runs, it collects what was copied
- clipmenu: opens dmenu and lets you select what has been previously copied
Launch the daemon in ~/.xinitrc:
clipmenud &
Bind clipmenu to keyboard shortcut in .config/sxhkd/sxhkdrc:
super + x
clipmenu -nb '#000000' -sb '#333' -fn 'Terminus-12'
You do not want text copied from password manager to be stored in history. To ignore your password manager’s window, clipmenu needs xdotool:
# xbps-install xdotool
You can use it too, to find name of your password manager’s window:
~ > xdotool search --name keepass getwindowname
Passwords - KeePassXC
Settings in /etc/profile:
export CM_IGNORE_WINDOW=\.\*KeePassXC\$
- CM_IGNORE_WINDOW: ignore what is copied from windows that match the regex
Second monitor
A script that toggles using second monitor: xrandrToggleScreens.sh:
#!/bin/sh
SECONDARY=$(xrandr | awk '/ connected/ && $1 != "'"$PRIMARY_SCREEN"'" {print $1; exit}')
DISCONNECTED=$(xrandr | awk '/ disconnected/ && /[0-9]+x[0-9]+/ {print $1; exit}')
# on connecting secondary monitor
if [ "$SECONDARY" ]; then
# place it above primary
xrandr --output "$SECONDARY" --auto --above "$PRIMARY_SCREEN"
sleep 0.5
# map external tablet to secondary
xsetwacom set "Wacom Intuos5 M Pen stylus" MapToOutput $SECONDARY
xsetwacom set "Wacom Intuos5 M Pen eraser" MapToOutput $SECONDARY
# map built in tablet to primary (otherwise it is stretched over both)
xsetwacom set "Wacom ISDv4 90 Pen stylus" MapToOutput $PRIMARY_SCREEN
xsetwacom set "Wacom ISDv4 90 Pen eraser" MapToOutput $PRIMARY_SCREEN
# set bspwm tags for secondary
bspc monitor $SECONDARY -d + ě š č
fi
# on disconnecting secondary monitor
if [ "$DISCONNECTED" ]; then
# stop the output
xrandr --output "$DISCONNECTED" --off
sleep 0.5
# map external tablet to primary
xsetwacom set "Wacom Intuos5 M Pen stylus" MapToOutput $PRIMARY_SCREEN
xsetwacom set "Wacom Intuos5 M Pen eraser" MapToOutput $PRIMARY_SCREEN
fi
The variable $PRIMARY_SCREEN is set in ~/.xinitrc:
export PRIMARY_SCREEN=$(xrandr --query | awk '/ primary/{print $1}')
I bind it to a keyboard shortcut using sxhkd:
super + shift + p
xrandrToggleScreens.sh & bspc wm -r
The script disconnects the output, that is listed as disconnected, but still has resolution, which happens when you physically disconnect the cable to a screen, that you are using:
$ xrandr
Screen 0: minimum 8 x 8, current 1920 x 1848, maximum 32767 x 32767
LVDS1 connected primary 1366x768+0+1080 (normal left inverted right x axis y axis) 280mm x 160mm
1366x768 60.02*+
1280x720 59.86 60.00 59.74
1024x768 60.00
1024x576 60.00 59.90 59.82
960x540 60.00 59.63 59.82
800x600 60.32 56.25
864x486 60.00 59.92 59.57
640x480 59.94
720x405 59.51 60.00 58.99
680x384 60.00
640x360 59.84 59.32 60.00
DP1 disconnected 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
DP2 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
1920x1080 (0x23e) 148.500MHz +HSync +VSync
h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.50KHz
v: height 1080 start 1084 end 1089 total 1125 clock 60.00Hz
Wacom tablet
Wacom tablets work out of the box, the only thing I do is map them to correct monitor - I want my tablet mapped to external monitor when it is connected. I do this in my monitor toggling script xrandr-toggle-screens.sh.
xsetwacom set "Wacom Intuos5 M Pen stylus" MapToOutput $SECONDARY_SCREEN
xsetwacom set "Wacom Intuos5 M Pen eraser" MapToOutput $SECONDARY_SCREEN
You must run this with the tablet already connected.
If the laptop has touch screen or tablet capability, it may uppon connecting another screen be extended on that screen too, let’s ensure it is mapped only on the laptop screen.
For ThinkPad X230 tablet:
xsetwacom set "Wacom ISDv4 90 Pen stylus" MapToOutput $PRIMARY_SCREEN
xsetwacom set "Wacom ISDv4 90 Pen eraser" MapToOutput $PRIMARY_SCREEN
For ThinkPad X1 Yoga:
xsetwacom set "Wacom Pen and multitouch sensor Finger touch" MapToOutput $PRIMARY_SCREEN
xsetwacom set "Wacom Pen and multitouch sensor Pen stylus" MapToOutput $PRIMARY_SCREEN
xsetwacom set "Wacom Pen and multitouch sensor Pen eraser" MapToOutput $PRIMARY_SCREEN
I also edited the pressure curve on the Yoga:
xsetwacom set "Wacom Pen and multitouch sensor Pen stylus" PressureCurve 0 0 30 100
To find out the names of your devices, run:
$ xsetwacom --list dev
Wacom ISDv4 90 Pen stylus id: 9 type: STYLUS
Wacom ISDv4 90 Pen eraser id: 13 type: ERASER
Wacom Intuos5 M Pad pad id: 15 type: PAD
Wacom Intuos5 M Pen stylus id: 16 type: STYLUS
Wacom Intuos5 M Pen eraser id: 17 type: ERASER
Wacom Intuos5 M Pen cursor id: 18 type: CURSOR
Screen rotation
Useful for tablets, you can bind this to a keypress or event. It rotates screen and inputs, so the cursor is where you for example point your pen.
rotateXdisplayAndPointers.sh:
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: $0 [normal|inverted|left|right]"
exit 1
fi
OUTPUT=$(xrandr | awk '/ connected/ {print $1; exit}')
xrandr --output "$OUTPUT" --rotate "$1"
TRANSFORM="Coordinate Transformation Matrix"
xinput list --name-only | while read name; do
id=$(xinput list --id-only "$name" 2>/dev/null)
[ -z "$id" ] && continue
case "$1" in
normal)
xinput set-prop "$id" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
;;
inverted)
xinput set-prop "$id" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
;;
left)
xinput set-prop "$id" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
;;
right)
xinput set-prop "$id" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
;;
esac
done
Usage: rotateXdisplayAndPointers.sh [normal|inverted|left|right]
Gtk and Qt themes
Solarized icon packs
Themix GUI designer
Themes go to ~/.themes, icon packs to ~/.icons.
These tools let you preview and select themes:
- qt5ct Qt5 Configuration Tool
- lxappearance desktop-independent theme switcher for GTK+
# xbps-install qt5ct lxappearance
You can also:
$ gsettings set org.gnome.desktop.interface gtk-theme theme-test
Here are my config files: ~/.profile
export QT_QPA_PLATFORMTHEME=qt5ct
You can add export GTK_THEME=theme-test
to force a theme.
~/.config/gtk-3.0/settings.ini
[Settings]
gtk-application-prefer-dark-theme=true
gtk-theme-name=theme-test
gtk-icon-theme-name=Solarized-Material-Cyan
gtk-font-name=Fira Sans 11
gtk-cursor-theme-size=24
gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ
gtk-toolbar-icon-size=GTK_ICON_SIZE_SMALL_TOOLBAR
gtk-button-images=0
gtk-menu-images=0
gtk-enable-event-sounds=1
gtk-enable-input-feedback-sounds=0
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle=hintslight
gtk-xft-rgba=rgb
gtk-cursor-theme-name=Adwaita
gtk-enable-animations=false
gtk-enable-primary-paste=true
gtk-recent-files-enabled=true
gtk-recent-files-max-age=60
~/.config/gtk-3.0/gtk.css
.window-frame, .window-frame:backdrop {
box-shadow: 0 0 0 black;
border-style: none;
margin: 0;
border-radius: 0;
}
.titlebar {
border-radius: 0;
}
~/.config/qt5ct.conf (generated by qt5ct)
[Appearance]
color_scheme_path=/home/user/.config/qt5ct/colors/theme-test.conf
custom_palette=true
icon_theme=Solarized-Material-Cyan
standard_dialogs=gtk3
style=Fusion
[Fonts]
fixed="Firacode,12,-1,5,50,0,0,0,0,0"
general="Fira sans,11,-1,5,50,0,0,0,0,0"
[Interface]
activate_item_on_single_click=1
buttonbox_layout=2
cursor_flash_time=1200
dialog_buttons_have_icons=0
double_click_interval=400
gui_effects=@Invalid()
keyboard_scheme=2
menus_have_icons=true
todo?