My Linux Desktop Configuration
One of the perks of using Linux is the freedom I get to tweak around and customize the user interface to my liking. Initially, I started with Unity then shifted to KDE, which is very customizable when I finally took up a tiling window manager without looking back. This article describes the setup I use and how you can replicate it. I am working on Arch Linux, but the same applies on any other distro with just minor changes.
Tiling Window Manager: BSPWM
Though I took a look at multiple tiling window managers like Awesome, I3 I settled with BSPWM for three reasons. First, the ease of customizability. The configuration files of BSPWM are very easy to write or understand, since they are written in BASH. Taking Awesome for example, the configuration file is huge and it took a long time for me to set it to my liking.
Second, is the ease of integration into a desktop environment. I foung BSPWM to be the easiest to work with as it does not need rules to properly manage menus and floating windows like I3. The only setting needed is to set aside a few pixels for the navigation bar, and the rest is taken care of.
The last reason being simplicity. The Awesome WM is very powerful, based on Python and has a ton of modules to work with. But, that very number of modules makes it extremely complex to work with. BSPWM, on the other hand is very simple to use and integrate with the rest of the modules on your computer. Thus, I sticked with BSPWM since a couple of years now.
BSPWM has two main configuration files. One is bspwmrc, which defines the window area and autostart commands among other settings. My configuration files is given below. Do tweak around with the settings to see which suites you the best.
#!/bin/sh
#LAUNCHERS
$HOME/.config/bspwm/autostart.sh
#external script for window rules
bspc config external_rules_command ~/.config/bspwm/scripts/external_rules_command
_check() {
[[ ! $(pidof -x $1) ]]
}
# startup applications and scripts
#_check fusuma && fusuma
#BSPWM configuration
#bspc config border_radius 8
bspc config border_width 2
bspc config window_gap 2
bspc config top_padding 30
bspc config bottom_padding 0
bspc config left_padding 0
bspc config right_padding 0
bspc config single_monocle false
#bspc config click_to_focus true
bspc config split_ratio 0.50
bspc config borderless_monocle true
bspc config gapless_monocle true
#bspc config focus_by_distance true
bspc config focus_follows_pointer false
#bspc config history_aware_focus true
bspc config pointer_modifier mod4
bspc config pointer_action1 move
bspc config pointer_action2 resize_side
bspc config pointer_action3 resize_corner
bspc config remove_disabled_monitors true
bspc config merge_overlapping_monitors true
#BSPWM coloring
bspc config normal_border_color "#4c566a"
bspc config active_border_color "#1e1e1e"
bspc config focused_border_color "#5e81ac"
bspc config presel_feedback_color "#5e81ac"
#bspc config urgent_border_color "#dd2727"
#Single monitor
bspc monitor -d 1 2 3 4 5 6 7 8 9 10
#Dual monitor
#find out names with arandr or xrandr
#bspc monitor DP-2 -d 1 2 3 4 5 6 7 8 9
#bspc monitor LVDS1 -d 1 2 3 4
#bspc monitor DP3 -d 5 6 7 8 9
#bspc monitor HDMI-0 -d 1 2 3 4 5 6 7 8 9 10
#bspc monitor HDMI-1 -d 1 2 3 4 5 6 7 8 9 10
#bspc monitor HDMI1 -d 1 2 3 4 5
#bspc monitor HDMI2 -d 6 7 8 9 10
#Fullscreen applications
bspc rule -a inkscape state=fullscreen
bspc rule -a Spotify state=fullscreen
#bspc rule -a Vlc state=fullscreen
bspc rule -a VirtualBox Manager state=fullscreen
bspc rule -a VirtualBox Machine state=fullscreen
#bspc rule -a Gimp state=fullscreen
#Floating applications
bspc rule -a Arandr state=floating
#bspc rule -a feh state=floating
#bspc rule -a mpv state=floating sticky=on
#bspc rule -a Font-manager state=floating
bspc rule -a Galculator state=floating
#bspc rule -a Gpick state=floating sticky=on
#bspc rule -a Nitrogen state=floating
bspc rule -a Oblogout state=floating
bspc rule -a Pavucontrol state=floating rectangle=789x512+264+130
#bspc rule -a Peek state=floating
#bspc rule -a rofi state=floating sticky=on
#bspc rule -a Skype state=floating
#bspc rule -a Stacer state=floating
bspc rule -a Xfce4-appfinder state=floating
bspc rule -a Xfce4-terminal state=floating
#Tiled applications
bspc rule -a Gnome-disks state=tiled
bspc rule -a Xfce4-settings-manager state=tiled
#open applications on specific workspaces
#bspc rule -a Firefox desktop='^1' follow=on
#bspc rule -a Google-chrome desktop='^1' follow=on
#bspc rule -a Chromium desktop='^1' follow=on
#bspc rule -a Subl3 desktop='^2' follow=on
#bspc rule -a Atom desktop='^2' follow=on
#bspc rule -a Steam desktop='^5'
#bspc rule -a vlc desktop='^6' follow=on
#bspc rule -a discord desktop='^9' follow=on
#bspc rule -a Spotify desktop='^10' follow=on
bspc rule -a Zoom desktop='^1' follow=on
#Spotify fix --move desktop 10
#sleep 1
#wmctrl -r Spotify -t 10
#exit
#polybar hidden when fullscreen for vlc, youtube, mpv ...
#find out the name of your monitor with xrandr
#xdo below -t $(xdo id -n root) $(xdo id -a polybar-main_DP-1)
#xdo below -t $(xdo id -n root) $(xdo id -a polybar-main_HDMI1)
#xdo below -t $(xdo id -n root) $(xdo id -a polybar-main_HDMI2)
# External Rules
#_check bspwm_external_rules && bspc config external_rules_command ~/.bin/bspwm_external_rules
###External rules
##Pseudo automatic mode: always splits focused window when opening new window
#bspc config external_rules_command ~/.config/bspwm/scripts/pseudo_automatic_mode
##Adjust new window: splits biggest windows to keep windows about the same size
#bspc config external_rules_command ~/.config/bspwm/scripts/adjust-new-window
In the above config file, the external_rules_command script is used. This is a bash script which runs each time a new window is opened and assigns the rules accordingly.
# external_rules_command
#!/bin/bash
window_id="$1"
window_class="$2"
window_instance="$3"
window_title="$(xwininfo -id "$window_id" | sed ' /^xwininfo/!d ; s,.*"\(.*\)".*,\1,')"
#window_title=$(xtitle $window_id)
#echo $window_title >> ~/test
case "$window_title" in
"ranger")
echo "state=floating"
echo "center=on"
echo "rectangle=789x512+264+130"
;;
"terminal-small")
echo "state=floating"
echo "rectangle=649x432+323+180"
;;
"Calculator")
echo "state=floating"
echo "rectangle=549x332+323+180"
;;
"zoom")
echo "state=floating"
echo "rectangle=549x332+323+180"
;;
esac
The other is the config file for sxhkd daemon which handles the keyboard shortcuts. This is my favourite way to manage shortcuts, as it is the easiest. It assignes a bash command to the key stroke mentioned in the next line.
#################################################################
# SUPER + FUNCTION KEYS
#################################################################
#Rofi
super + z
~/.bin/rofi_run
#################################################################
# SUPER + ... KEYS
#################################################################
#Htop
super + h
alacritty -t 'htop task manager' -e htop
#rofi exit menu
super + x
~/.bin/rofi_run -l
#################################################################
# SUPER + SHIFT KEYS
##############################################################
#File-Manager
super + shift + f
nautilus
#Email client - astroid
super + shift + i
~/.bin/astroid_script email-1
super + shift + n
~/.bin/astroid_script email-2
super + shift + p
~/.bin/astroid_script email-3
#################################################################
# CONTROL + ALT KEYS
#################################################################
#Xfce4-appfinder
super + a
xfce4-appfinder
#################################################################
# ALT + ... KEYS
#################################################################
#Gmrun
alt + F2
gmrun
#################################################################
# CONTROL + SHIFT KEYS
#################################################################
#Xcfe4-TaskManager
ctrl + shift + Escape
gnome-system-monitor
#################################################################
# SCREENSHOTS
#################################################################
#Deepin screenshot tool
#select a rectangular area
ctrl + Print
deepin-screenshot
#full screen picture
shift + Print
deepin-screenshot -f
#top window
super + Print
deepin-screenshot -w
#################################################################
# MULTIMEDIA KEYS
#################################################################
#PLAY
XF86AudioPlay
playerctl play-pause
#Next
XF86AudioNext
playerctl next
#previous
XF86AudioPrev
playerctl previous
#Stop
XF86AudioStop
playerctl stop
Do note that this is a long file and the above is just an excerpt. I have included the lengthy version here. Once the above config files are set, we need a navigation bar.
Navigation Bar: Polybar
Polybar is a neat tool to configure and also make new widgets you might need for a special case. There are many other bars available like Lemon bar, and its practically up to you on which you choose. The config file for Polybar is fitted with modules which makes it easy to maintain and edit. I borrowed many snippets of code from Arcolinux iso for many of my configs, as it made my life easier. Special customizations like the powerline background can be done in Polybar as given in Derek Taylor’s video. The config file is too long, So I will only include the important parts which are useful for BSPWM.
;=====================================================
;
; To learn more about how to configure Polybar
; go to https://github.com/jaagr/polybar
;
; The README contains alot of information
; Themes : https://github.com/jaagr/dots/tree/master/.local/etc/themer/themes
; https://github.com/jaagr/polybar/wiki/
; https://github.com/jaagr/polybar/wiki/Configuration
; https://github.com/jaagr/polybar/wiki/Formatting
;
;=====================================================
[global/wm]
;https://github.com/jaagr/polybar/wiki/Configuration#global-wm-settings
margin-top = 0
margin-bottom = 0
[settings]
;https://github.com/jaagr/polybar/wiki/Configuration#application-settings
throttle-output = 5
throttle-output-for = 10
throttle-input-for = 30
screenchange-reload = true
compositing-background = over
compositing-foreground = over
compositing-overline = over
compositing-underline = over
compositing-border = over
; Define fallback values used by all module formats
format-foreground = #FF0000
format-background = #00FF00
format-underline =
format-overline =
format-spacing =
format-padding =
format-margin =
format-offset =
[colors]
; Nord theme ============
background = #2F343F
foreground = #f3f4f5
alert = #d08770
volume-min = #a3be8c
volume-med = #ebcb8b
volume-max = #bf616a
; =======================
; Gotham theme ==========
; background = #0a0f14
; foreground = #99d1ce
; alert = #d26937
; volume-min = #2aa889
; volume-med = #edb443
; volume-max = #c23127
; =======================
; INTRCPTR theme ============
;background = ${xrdb:color0:#222}
;background = #aa000000
;background-alt = #444
;foreground = ${xrdb:color7:#222}
;foreground = #fff
;foreground-alt = #555
;primary = #ffb52a
;secondary = #e60053
;alert = #bd2c40
################################################################################
################################################################################
############ MAINBAR-BSPWM ############
################################################################################
################################################################################
[bar/mainbar-bspwm]
monitor = ${env:MONITOR}
;monitor-fallback = HDMI1
width = 100%
height = 30
;offset-x = 1%
;offset-y = 1%
radius = 0.0
fixed-center = true
bottom = false
separator = |
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 4
line-color = #f00
wm-restack = bspwm
override-redirect = true
; Enable support for inter-process messaging
; See the Messaging wiki page for more details.
enable-ipc = true
border-size = 0
;border-left-size = 0
;border-right-size = 25
;border-top-size = 0
;border-bottom-size = 25
border-color = #00000000
padding-left = 0
padding-right = 2
module-margin-left = 3
module-margin-right = 3
;https://github.com/jaagr/polybar/wiki/Fonts
;font-0 = "Noto Sans:size=10;0"
font-1 = "FontAwesome:size=13;0"
;font-2 = "Font Awesome 5 Free:style=Regular:pixelsize=8;1"
;font-3 = "Font Awesome 5 Free:style=Solid:pixelsize=8;1"
;font-4 = "Font Awesome 5 Brands:pixelsize=8;1"
font-0 = "Roboto Font:size=10;1"
font-5 = "DejaVu Sans:size=9;0"
;font-1 = "UbuntuMono Nerd Font:size=16;3"
font-2 = "Font Awesome 5 Free:style=Regular:pixelsize=8;1"
font-3 = "Font Awesome 5 Free:style=Solid:pixelsize=8;1"
font-4 = "Font Awesome 5 Brands:pixelsize=8;1"
modules-left = bspwm xwindow
#modules-center = kernel
modules-right = memory2 cpu1 date battery
tray-detached = false
tray-offset-x = 0
tray-offset-y = 0
tray-padding = 2
tray-maxsize = 20
tray-scale = 1.0
tray-position = right
tray-background = ${colors.background}
#scroll-up = bspwm-desknext
#scroll-down = bspwm-deskprev
################################################################################
################################################################################
############ MAINBAR-BSPWM-EXTRA ############
################################################################################
################################################################################
[bar/mainbar-bspwm-extra]
monitor = ${env:MONITOR}
;monitor-fallback = HDMI1
width = 100%
height = 30
;offset-x = 1%
;offset-y = 1%
radius = 0.0
fixed-center = true
bottom = true
separator = |
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 2
line-color = #f00
wm-restack = bspwm
override-redirect = true
; Enable support for inter-process messaging
; See the Messaging wiki page for more details.
enable-ipc = true
border-size = 0
;border-left-size = 0
;border-right-size = 25
;border-top-size = 0
;border-bottom-size = 25
border-color = #00000000
padding-left = 0
padding-right = 1
module-margin-left = 3
module-margin-right = 3
;https://github.com/jaagr/polybar/wiki/Fonts
font-0 = "Noto Sans:size=10;0"
font-1 = "FontAwesome:size=13;0"
font-2 = "Noto Sans:size=10;0"
font-3 = "Noto Sans Mono:size=10;0"
modules-left = load-average
modules-center = networkspeeddown networkspeedup
modules-right = filesystem
;tray-detached = false
;tray-offset-x = 0
;tray-offset-y = 0
;tray-padding = 2
;tray-maxsize = 20
;tray-scale = 1.0
;tray-position = right
;tray-background = ${colors.background}
scroll-up = bspwm-desknext
scroll-down = bspwm-deskprev
There are two bars defined in this config file, though you can only use one of them. Once, this config file is setup, it can be launched from this launch.sh script file.
#!/usr/bin/env sh
# More info : https://github.com/jaagr/polybar/wiki
# Install the following applications for polybar and icons in polybar if you are on ArcoLinuxD
# awesome-terminal-fonts
# Tip : There are other interesting fonts that provide icons like nerd-fonts-complete
# Terminate already running bar instances
killall -q polybar
# Wait until the processes have been shut down
while pgrep -u $UID -x polybar > /dev/null; do sleep 1; done
if type "xrandr" > /dev/null; then
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
MONITOR=$m polybar --reload mainbar-bspwm -c ~/.config/polybar/config &
done
else
polybar --reload mainbar-bspwm -c ~/.config/polybar/config &
fi
# second polybar at bottom
# if type "xrandr" > /dev/null; then
# for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
# MONITOR=$m polybar --reload mainbar-bspwm-extra -c ~/.config/polybar/config &
# done
# else
# polybar --reload mainbar-bspwm-extra -c ~/.config/polybar/config &
# fi
Integration with a Desktop Environment
The tiling window managers can be used as a standalone with just the important utilities. But, I prefer having some utilities like power-management, bluetooth and network connectivity and a notification daemon. These are even more importatant when it is a laptop, as in my case. I tried to integrate with some DE’s, but it is not always possible. For example, it is not possible to do it in a simple way with Gnome, Deepin or Budgie. The ones which worked for me are KDE Plasma and Xfce. After a while, I switched to Xfce as each and every module in Xfce is modular and there is not need for a host of background processes for a module to run, like in Plasma.
I used an autostart.sh script to launch the modules and applications I need to run in the background and it works like a charm.
#!/bin/bash
function run {
if ! pgrep $1 ;
then
$@&
fi
}
#Find out your monitor name with xrandr or arandr (save and you get this line)
#xrandr --output VGA-1 --primary --mode 1360x768 --pos 0x0 --rotate normal
#xrandr --output DP2 --primary --mode 1920x1080 --rate 60.00 --output LVDS1 --off &
#xrandr --output LVDS1 --mode 1366x768 --output DP3 --mode 1920x1080 --right-of LVDS1
#xrandr --output HDMI2 --mode 1920x1080 --pos 1920x0 --rotate normal --output HDMI1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output VIRTUAL1 --off
#change your keyboard if you need it
#setxkbmap -layout be
#Some ways to set your wallpaper besides variety or nitrogen
xsetroot -cursor_name left_ptr &
run sxhkd -c ~/.config/bspwm/sxhkd/sxhkdrc &
# setting the synaptic configuration
synclient TapButton1=1
synclient TapButton2=3
synclient VertScrollDelta=-111
synclient HorizScrollDelta=-111
synclient HorizTwoFingerScroll=1
synclient VertEdgeScroll=0
## System applets and applications
#conky -c $HOME/.config/bspwm/system-overview &
run nm-applet &
run xfce4-power-manager &
#run kdeconnect-indicator &
numlockx on &
blueman-applet &
picom --config $HOME/.config/bspwm/picom.conf &
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &
/usr/lib/xfce4/notifyd/xfce4-notifyd &
run pa-applet &
run gnome-screensaver &
nitrogen --restore &
$HOME/.config/polybar/launch.sh &
run fusuma &
run pulseeffects --gapplication-service &
run syndaemon -i 0.5 -t -K -R & #To disable touchpad while typing
#run caffeine &
#run firefox &
#run thunar &
#run dropbox &
#run insync start &
#run discord &
#run spotify &
#run atom &
# setting ofono to enable HFP in bluetooth pulseaudio
~/.bin/ofono_script &
# applications
sleep 5 && dropbox start &
As shown above, I started the notification daemon, Dropbox, and the xfce-power-manager at startup. For the effects like transparency, I used Picom a fork of Compton which is maintained actively.
The above config files have the following tree structure.
├──.config
├── autostart.sh
├── bspwmrc
├── picom.conf
├── scripts
│ └── external_rules_command
├── sxhkd
│ └── sxhkdrc
└── polybar
├── scripts
│ ├── check-all-updates.sh
│ ├── compton-toggle.sh
│ ├── pavolume.sh
│ ├── tempcores.sh
│ └── weather.py
├── config
└── launch.sh
The final setup looks like this.
Applications I use:
- Ranger (CLI file manager)
- Nautilus (GUI Filefile manager)
- Astroid and gmailieer (multiple accounts) (Email Client)
- Sublime text and neovim (Text editor)
- Brave-Nightly (Browser)
If any symbols are not visible in the navbar, make sure to install some UTF fonts on your mahcine which have the symbols used in the config files.
All the dot files for the above setup are in my github repository.
comments powered by Disqus