Tag Archives: desktop

FreeBSD Desktop – Part 14 – Configuration – Tint2

In today’s article in the FreeBSD Desktop series we will focus on the task bar configuration. I will describe how to setup the Tint2.

You may also check earlier articles of the FreeBSD Desktop series:

Features

The task bar role served by the Tint2 will be providing the following features.

  • Launcher for the most used applications.
  • Show opened/minimized windows on each of four virtual desktops.
  • Indicate current used virtual desktop.
  • Provide system tray area for applications that depend on it.
  • Maximize selected window with [Right Mouse Button].
  • Close selected window with [Middle Mouse Button].
  • Focus selected window along with switching to the virtual desktop with that window using [Left Mouse Button].
  • Pass [Left/Middle/Right Mouse Button] events to Openbox window manager when not clicked on objects.
  • Provide buttons – cpu_L cpu_M cpu_H – to set various CPU frequencies (from left Low/Medium/High).
  • Provide button – wallpaper – to set new random wallpaper.

Here is how such Tint2 task bar would look like in action, along with previously configured Dzen2 status bar.

vermaden-tint2.jpg

Tint

The Tint2 is very light solution, one of the lightest that I know while being very nice looking and effective. A rare fusion of features 🙂

To achieve described earlier features we will use following Tint2 configuration ~/.tint2rc file.

% cat ~/.tint2rc
# GENERAL
# -------
  rounded          = 0
  border_width     = 0
  background_color = #222222 100
  border_color     = #000000 0

# AUTOHIDE
# --------
  autohide     = 0
  strut_policy = minimum

# TOOLTIP
# -------
  tooltip = 0

# MOUSE
# -----
  mouse_middle = close
  mouse_right  = maximize_restore

# PANEL
# -----
  wm_menu             = 1
  panel_items         = LTS
  panel_monitor       = 1
  panel_position      = top center
  panel_size          = 0 16
  panel_margin        = 0 12
  panel_padding       = 0 0 16
  panel_layer         = bottom
  panel_background_id = 1
  font_shadow         = 0

# LAUNCHER
# --------
  launcher_padding       = 0 0 1
  launcher_background_id = 1
  launcher_icon_size     = 14
  launcher_item_app      = /home/vermaden/.apps/caja.desktop
  launcher_item_app      = /home/vermaden/.apps/thunar.desktop
  launcher_item_app      = /home/vermaden/.apps/nfs.desktop
  launcher_item_app      = /home/vermaden/.apps/terminal.desktop
  launcher_item_app      = /home/vermaden/.apps/geany.desktop
  launcher_item_app      = /home/vermaden/.apps/leafpad.desktop
  launcher_item_app      = /home/vermaden/.apps/pidgin.desktop
  launcher_item_app      = /home/vermaden/.apps/thunderbird.desktop
  launcher_item_app      = /home/vermaden/.apps/firefox.desktop
  launcher_item_app      = /home/vermaden/.apps/chromium.desktop
  launcher_item_app      = /home/vermaden/.apps/gimp.desktop
  launcher_item_app      = /home/vermaden/.apps/galculator.desktop
  launcher_item_app      = /home/vermaden/.apps/deadbeef.desktop
  launcher_item_app      = /home/vermaden/.apps/transmission.desktop
  launcher_item_app      = /home/vermaden/.apps/cpu_L.desktop
  launcher_item_app      = /home/vermaden/.apps/cpu_M.desktop
  launcher_item_app      = /home/vermaden/.apps/cpu_H.desktop
  launcher_item_app      = /home/vermaden/.apps/wallpaper.desktop

# TASKBAR
# -------
  taskbar_mode                   = multi_desktop
  taskbar_padding                = 0 0 1
  taskbar_background_id          = 1
  taskbar_active_background_id   = 1
  taskbar_distribute_size        = 0
  taskbar_name                   = 1
  taskbar_name_font              = Ubuntu Mono 8
  taskbar_name_font_color        = #aaaaaa 100
  taskbar_name_active_font_color = #dd0000 100

# TASKS
# -----
  task_icon                 = 1
  task_text                 = 0
  task_width                = 14
  task_centered             = 1
  task_padding              = 0 0 1
  task_background_id        = 0
  task_active_background_id = 0
  task_iconified_icon_asb   = 40 0 0

# SYSTRAY
# -------
  systray           = 1
  systray_padding   = 0 0 1
  systray_icon_size = 14

Because the *.desktop files does not support relative directories for Icon parameter such as ‘~‘ so they need to be replaced before start at the ~/.xinitrc file (or ~/.xsession file), similarly like with the Openbox files.

We already had following Openbox ‘find/replace’ in the ~/.xinitrc file (or ~/.xsession file).

# ICONS WM
  sed -i '' -E "s%\/home\/[a-zA-Z0-9_-]+\/%\/home\/${USER}\/%g" ~/.config/openbox/menu.xml
  sed -i '' -E "s%\/home\/[a-zA-Z0-9_-]+\/%\/home\/${USER}\/%g" ~/.config/openbox/rc.xml

We will now add the ‘rules’ needed for Tint2 and the *.desktop files from the ~/.apps directory.

# ICONS TINT2
  sed -i '' -E "s%\/home\/[a-zA-Z0-9_-]+\/%\/home\/${USER}\/%g" ~/.tint2rc

# ICONS APPS
  for I in ~/.apps/*.desktop
  do
    sed -i '' -E "s%\/home\/[a-zA-Z0-9_-]+\/%\/home\/${USER}\/%g" "${I}"
  done

Here is how the Tint2 startup is configured in the ~/.xinitrc (or ~/.xsession file).

% grep tint ~/.xinitrc                      
  ~/scripts/__openbox_restart_tint2.sh &

Remember to put ‘&‘ at the end of the line.

Doas

To make most scripts work Your user (vuk in the series) needs to be in the wheel, operator and network groups and doas(1) (sudo(8) equivalent) needs to be installed and configured in the following way.

# pkg install doas

# pw groupmod wheel    -m vuk
# pw groupmod operator -m vuk
# pw groupmod network  -m vuk

# cat /usr/local/etc/doas.conf
permit nopass :wheel as root

permit nopass :network as root cmd ifconfig
permit nopass :network as root cmd dhclient
permit nopass :network as root cmd umount
permit nopass :network as root cmd wpa_supplicant
permit nopass :network as root cmd ppp
permit nopass :network as root cmd killall args -9 dhclient
permit nopass :network as root cmd killall args -9 wpa_supplicant
permit nopass :network as root cmd killall args -9 ppp
permit nopass :network as root cmd cat args /etc/ppp/ppp.conf
permit nopass :network as root cmd /etc/rc.d/netif args onerestart
permit nopass :network as root cmd tee args /etc/resolv.conf
permit nopass :network as root cmd tee args -a /etc/resolv.conf

Scripts

There is only one new script added – ~/scripts/nfs.sh – all others are already published in previous *.tar.gz files. Its also optional because you may not have NAS resource which you would want to mount … or maybe you prefer SSHFS or CIFS share …

I also uploaded all the scripts as individual files to the GitHub page.

Make sure they remain executable.

% chmod +x ~/scripts/*

To make them work properly add ~/scripts into the ${PATH} variable at the beginning of the ~/.xinitrc file.

# PATH TO SCRIPTS
  export PATH=${PATH}:~/scripts

All of my scripts have this ‘mysterious’ line at the end. Its for statistics to check which scripts are run when (or it at all to which ones to delete).

echo '1' >> ~/scripts/stats/$( basename ${0} )

Thus it is needed to create the ‘stats’ directory.

% mkdir -p ~/scripts/stats

I have implemented that about two months ago and here are the results.

% wc -l ~/scripts/stats/* | sort -n
       1 /home/vermaden/scripts/stats/__openbox_edit_wallpaper_gimp.sh
       1 /home/vermaden/scripts/stats/__openbox_restart_lxpanel.sh
       1 /home/vermaden/scripts/stats/__openbox_show_screenshot.sh
       1 /home/vermaden/scripts/stats/__openbox_stats_top_cpu_KILL.sh
       1 /home/vermaden/scripts/stats/__openbox_stats_top_mem_RENICE.sh
       2 /home/vermaden/scripts/stats/__openbox_fullscreen.sh
       2 /home/vermaden/scripts/stats/__openbox_stats_top_cpu_RENICE.sh
       3 /home/vermaden/scripts/stats/__openbox_current_wallpaper.sh
       5 /home/vermaden/scripts/stats/__openbox_cpufreq.sh
       5 /home/vermaden/scripts/stats/__openbox_dmenu.sh
       9 /home/vermaden/scripts/stats/__openbox_virtualbox.sh
      10 /home/vermaden/scripts/stats/__openbox_delete_wallpaper.sh
      13 /home/vermaden/scripts/stats/__openbox_restart_conky.sh
      13 /home/vermaden/scripts/stats/__openbox_restart_plank.sh
      17 /home/vermaden/scripts/stats/__openbox_lock.sh
      20 /home/vermaden/scripts/stats/nfs.sh
      21 /home/vermaden/scripts/stats/__openbox_freebsd_sound.sh
      22 /home/vermaden/scripts/stats/__openbox_lock_zzz.sh
      24 /home/vermaden/scripts/stats/__openbox_edit_screenshot.sh
      24 /home/vermaden/scripts/stats/__openbox_restart_dzen2.sh
      24 /home/vermaden/scripts/stats/dzen2-fifo.sh
      28 /home/vermaden/scripts/stats/__openbox_restart_tint2.sh
      32 /home/vermaden/scripts/stats/aero-snap.sh
      48 /home/vermaden/scripts/stats/shot.sh
      56 /home/vermaden/scripts/stats/network.sh
     447 /home/vermaden/scripts/stats/xdotool.sh
     599 /home/vermaden/scripts/stats/xterm.sh
    1862 /home/vermaden/scripts/stats/random_wallpaper.sh
    5923 /home/vermaden/scripts/stats/__conky_if_ip.sh
    5942 /home/vermaden/scripts/stats/dzen2-update.sh
    5956 /home/vermaden/scripts/stats/__conky_if_dns.sh
    5956 /home/vermaden/scripts/stats/__conky_if_gw.sh
    5959 /home/vermaden/scripts/stats/__conky_battery.sh
    5966 /home/vermaden/scripts/stats/__conky_if_ping.sh
   28359 /home/vermaden/scripts/stats/desktop-kill-shit.sh
   67352 total

Of course I limited the output only to scripts that are available in this article, but be patient, more to come later 🙂

Dependencies

To make these scripts work and generally to make all this setup work we will need these dependencies.

  • tint2
  • caja
  • chromium
  • deadbeef
  • firefox
  • galculator
  • geany
  • gimp
  • leafpad
  • midori
  • pidgin
  • xterm
  • thunar
  • thunderbird
  • transmission-gtk
  • feh
  • xkill

To install them all with pkg(8) just type this line below.

# pkg install \
    tint2 caja chromium deadbeef firefox galculator midori \
    geany gimp leafpad xterm thunar xkill transmission-gtk \
    thunderbird feh pidgin
   

We have finished making the ‘top’ bars. You now have all needed information in the status bar server by Dzen2 and all applications/windows covered by the Tint2 task bar.

EOF.

.
.
.
.
.

Advertisements

FreeBSD Desktop – Part 13 – Configuration – Dzen2

Time for real configuration of the status bar. In today’s article of the FreeBSD Desktop series I will describe how to configure the Dzen2.

You may also check earlier articles of the FreeBSD Desktop series:

Features

The provided status bar backed by Dzen2 will be providing the following information.

  • date: Date in ISO 8601 format along with current time.
  • sys: CPU frequency, CPU temperature, system load and free RAM.
  • ip: List of current IP addresses and its interfaces.
  • gw: System default network gateway.
  • dns: System default DNS.
  • ping: Current Internet access state.
  • vol/pcm: Volume level for vol and pcm backends.
  • fs: ZFS pools free space.
  • bat: Battery and AC status.
  • top: Top 3 processes with highest CPU usage along with their RAM usage.

Here is how such Dzen2 looks like in action.

vermaden-dzen2.jpg

Dzen2

The Dzen2 offers feature that Conky or other status bar applications does not offer. I would call it refresh on demand. If you would like to implement refresh interval of 60 seconds for example (not so often) and also refresh that information everytime you ‘click’ on the status bar (or by other action) its possible to implement in Dzen2 using mkfifo(1) command.

Why anyone would want to implement such ‘strange’ refresh policy? To get more battery life mostly as You do not need this information to be refreshed every second and if You need up to date information then you will refresh it manually with a click on the status bar and have the needed information. The other reason is ‘focus’. If this status bar refreshes every second, then it ‘caches’ your attention, this may prevent you from focusing deep enough on the task you are currently doing. If you do something important that requires focus then You do not want status bar (or anything else) to distract you with useless at the moment information.

To achieve such configuration we would need three things. The dzen2-fifo.sh script that will start initial fifo on the ~/.dzen2-fifo file. The dzen2-update.sh to update the fifo and would be run from the crontab(1) every 60 seconds. A dzen2(1) action configured with left mouse button click to invoke dzen2-update.sh to update the fifo. All these scripts and scripts used directly by Dzen2 to gather needed information are available in the scripts-status-bar.tar.gz file.

To start Dzen2 at the X11 startup we will use script from the earlier ‘bulk’ already available – __openbox_restart_dzen2.sh – which kills all instances of Dzen2 and then starts the fifo backed Dzen2 with dzen2-fifo.sh script available in the scripts.tar.gz file.

Here is how its configured in the ~/.xinitrc (or ~/.xsession) file.

% grep dzen ~/.xinitrc                      
  ~/scripts/__openbox_restart_dzen2.sh &

Remember to put ‘&‘ at the end of the line.

Lets have a look how the ‘update’ is configured in the crontab(1) as shown below.

% crontab -l
# DZEN2
  0 * * * * ~/scripts/dzen2-update.sh 1> ~/.dzen2-fifo                                        2> /dev/null

The scripts that Dzen2 uses to gather information are:

~/scripts/__conky_if_ip.sh
~/scripts/__conky_if_gw.sh
~/scripts/__conky_if_dns.sh
~/scripts/__conky_if_ping.sh
~/scripts/__conky_battery.sh

… and this one to ’emulate’ clicks to implement Openbox virtual desktops switching with [Scroll Up] and [Scroll Down] mouse events.

~/scripts/xdotool.sh

The dzen2-update.sh is kinda like Conky on terminal, it just puts all that information in text format with Dzen2 colors syntax as shown below.

% dzen2-update.sh
 ^fg(#aaaaaa)date: ^fg(#eeeeee)2018/07/05/Thu/10:11 ^fg(#dd0000)| ^fg(#aaaaaa)sys: ^fg(#eeeeee)800MHz/46.1C/0.83/4.5GB ^fg(#dd0000)| ^fg(#aaaaaa)ip: ^fg(#eeeeee)wlan0/wirelesssid/192.168.0.3 ^fg(#dd0000)| ^fg(#aaaaaa)gw: ^fg(#eeeeee)192.168.0.1 ^fg(#dd0000)| ^fg(#aaaaaa)dns: ^fg(#eeeeee)192.168.0.1 ^fg(#dd0000)| ^fg(#aaaaaa)ping: ^fg(#eeeeee)^fg(#dd2200)NOPE ^fg(#dd0000)| ^fg(#aaaaaa)vol/pcm: ^fg(#eeeeee)100/100 ^fg(#dd0000)| ^fg(#aaaaaa)fs: ^fg(#eeeeee)local/69.2G sys/3.27G ^fg(#dd0000)| ^fg(#aaaaaa)bat: ^fg(#eeeeee)AC/^fg(#ffffff)90% ^fg(#dd0000)| ^fg(#aaaaaa)top: ^fg(#eeeeee)firefox/15%/0.6GB firefox/13%/0.3GB firefox/11%/0.4GB 

Doas

To make most scripts work Your user (vuk in the series) needs to be in the wheel, operator and network groups and doas(1) (sudo(8) equivalent) needs to be installed and configured in the following way.

# pkg install doas

# pw groupmod wheel    -m vuk
# pw groupmod operator -m vuk
# pw groupmod network  -m vuk

# cat /usr/local/etc/doas.conf
permit nopass :wheel as root

permit nopass :network as root cmd ifconfig
permit nopass :network as root cmd dhclient
permit nopass :network as root cmd umount
permit nopass :network as root cmd wpa_supplicant
permit nopass :network as root cmd ppp
permit nopass :network as root cmd killall args -9 dhclient
permit nopass :network as root cmd killall args -9 wpa_supplicant
permit nopass :network as root cmd killall args -9 ppp
permit nopass :network as root cmd cat args /etc/ppp/ppp.conf
permit nopass :network as root cmd /etc/rc.d/netif args onerestart
permit nopass :network as root cmd tee args /etc/resolv.conf
permit nopass :network as root cmd tee args -a /etc/resolv.conf

Scripts

In this post I attach scripts related to Dzen2. Download them all in the scripts-status-bar.tar.gz file and unpack them into the ~/scripts directory.

Here are these scripts.

% tar -tf scripts-status-bar.tar.gz
~/scripts/dzen2-fifo.sh
~/scripts/dzen2-update.sh
~/scripts/xdotool.sh
~/scripts/__conky_if_ip.sh
~/scripts/__conky_if_gw.sh
~/scripts/__conky_if_dns.sh
~/scripts/__conky_if_ping.sh
~/scripts/__conky_battery.sh

Make sure they remain executable.

% chmod +x ~/scripts/*

To make them work properly add ~/scripts into the ${PATH} variable at the beginning of the ~/.xinitrc file.

# PATH TO SCRIPTS
  export PATH=${PATH}:~/scripts

All of my scripts have this ‘mysterious’ line at the end. Its for statistics to check which scripts are run when (or it at all to which ones to delete).

echo '1' >> ~/scripts/stats/$( basename ${0} )

Thus it is needed to create the ‘stats’ directory.

% mkdir -p ~/scripts/stats

I have implemented that about two months ago and here are the results.

% wc -l ~/scripts/stats/* | sort -n
       1 /home/vermaden/scripts/stats/__openbox_show_screenshot.sh
       2 /home/vermaden/scripts/stats/__openbox_cpufreq.sh
       2 /home/vermaden/scripts/stats/__openbox_current_wallpaper.sh
       2 /home/vermaden/scripts/stats/__openbox_fullscreen.sh
       4 /home/vermaden/scripts/stats/__openbox_restart_dzen2.sh
       4 /home/vermaden/scripts/stats/dzen2-fifo.sh
       5 /home/vermaden/scripts/stats/__openbox_dmenu.sh
       5 /home/vermaden/scripts/stats/__openbox_restart_conky.sh
       5 /home/vermaden/scripts/stats/__openbox_restart_tint2.sh
       6 /home/vermaden/scripts/stats/__openbox_delete_wallpaper.sh
       7 /home/vermaden/scripts/stats/__openbox_freebsd_sound.sh
       8 /home/vermaden/scripts/stats/aero-snap.sh
      12 /home/vermaden/scripts/stats/__openbox_edit_screenshot.sh
      16 /home/vermaden/scripts/stats/__openbox_lock_zzz.sh
      16 /home/vermaden/scripts/stats/__openbox_lock.sh
      22 /home/vermaden/scripts/stats/shot.sh
      24 /home/vermaden/scripts/stats/network.sh
     214 /home/vermaden/scripts/stats/xterm.sh
     960 /home/vermaden/scripts/stats/random_wallpaper.sh
    2767 /home/vermaden/scripts/stats/desktop-battery-warning.sh
   13834 /home/vermaden/scripts/stats/desktop-kill-shit.sh
   17916 total

Of course I limited the output only to scripts that are available in this article, but be patient, more to come later 🙂

Dependencies

To make these scripts work and generally to make all this setup work we will need these dependencies.

  • dzen2
  • xdotool
  • wmctrl

To install them all with pkg(8) just type this line below.

# pkg install dzen2 xdotool wmctrl
   

Crontab

After adding Dzen2 to crontab(1) and keeping the earlier entries the complete crontab(1) would look like that.

% crontab -l
# DESKTOP
  *     *     * * * ~/scripts/desktop-kill-shit.sh                                       1> /dev/null 2> /dev/null
  */5   *     * * * ~/scripts/desktop-battery-warning.sh
  */20  *     * * * ~/scripts/random_wallpaper.sh ~/gfx/wallpapers                       1> /dev/null 2> /dev/null
  12,0  *     * * * /usr/bin/find ~/.cache -mtime +10 -delete                            1> /dev/null 2> /dev/null
  0     */3   * * * /usr/bin/find ~/.local/share/Trash/files -mtime +1 -delete           1> /dev/null 2> /dev/null

# DZEN2
  0     *     * * * ~/scripts/dzen2-update.sh 1> ~/.dzen2-fifo                                        2> /dev/null

Shortcuts

This Dzen2 configuration implements five ‘mouse actions’ or shortcuts available on the status bar.

  • [Scroll Up] – switch next virtual desktop.
  • [Scroll Down] – switch previous virtual desktop.
  • [Right Click] – show Openbox root menu.
  • [Middle Click] – show Openbox window menu.
  • [Left Click] – update Dzen2 Status Bar with dzen2-update.sh invoke.

Hope I haven’t forgot anything, feel free to ask or remind me 😉

EOF.

.
.
.
.
.

FreeBSD Desktop – Part 12 – Configuration – Openbox

Time to cut the bullshit and actually make some real configuration. In today’s article of the FreeBSD Desktop series I will describe how to configure the Openbox window manager.

You may also check earlier articles of the FreeBSD Desktop series:

Features

Comparing to earlier articles in the series it will be HUGE, sorry for that. I could cut it into smaller parts but that would require editing of the Openbox configuration, its shortcuts and menus over and over again, so for the sake of simplicity its better to put it all at once. As it is as that big there will be mistakes, but I will fix them ASAP.

Here is the list of all features that will be available in this Openbox configuration.

  • Nice looking Openbox theme.
  • Openbox Menu (static) with nice looking icons.
  • Openbox Menu for FreeBSD top(1)/ps(1) commands and config files/logs.
  • Openbox Menu for FreeBSD default sound output.
  • Openbox Menu and shortcuts for FreeBSD sound volume increase/decrease.
  • Openbox Menu for FreeBSD for CPU frequency scaling.
  • Openbox Menu for FreeBSD network management with network.sh script.
  • Openbox Menu for screenshots/wallpapers management.
  • Openbox Menu for Recent files.
  • Random wallpaper handling.
  • Random xterm(1) theme at every terminal start with lost of great themes.
  • Openbox shortcuts and script for Aero Snap like behavior.
  • Openbox Dmenu shortcuts and integration.
  • Openbox configured with nice fonts.
  • Openbox shortcuts for most important tasks.
  • Warning for low battery on laptop.
  • I probably forgot about dozen other features – let me know in comments 🙂

Here is how the Openbox menus and window borders and window switching would look like.

openbox-alt-tab

openbox-menu

Here are all the files with needed configuration.

Doas

To make most scripts work Your user (vuk in the series) needs to be in the wheel, operator and network groups and doas(1) (sudo(8) equivalent) needs to be installed and configured in the following way.

# pkg install doas

# pw groupmod wheel    -m vuk
# pw groupmod operator -m vuk
# pw groupmod network  -m vuk

# cat /usr/local/etc/doas.conf
permit nopass :wheel as root

permit nopass :network as root cmd ifconfig
permit nopass :network as root cmd dhclient
permit nopass :network as root cmd umount
permit nopass :network as root cmd wpa_supplicant
permit nopass :network as root cmd ppp
permit nopass :network as root cmd killall args -9 dhclient
permit nopass :network as root cmd killall args -9 wpa_supplicant
permit nopass :network as root cmd killall args -9 ppp
permit nopass :network as root cmd cat args /etc/ppp/ppp.conf
permit nopass :network as root cmd /etc/rc.d/netif args onerestart
permit nopass :network as root cmd tee args /etc/resolv.conf
permit nopass :network as root cmd tee args -a /etc/resolv.conf

Scripts

In this post I attach scripts I have made and used for about 13 years since I started to use FreeBSD on the desktop. Download them all in the scripts.tar.gz file and unpack them into the ~/scripts to make it look like that.

% find scripts | sort
scripts/__openbox_cpufreq.sh
scripts/__openbox_current_wallpaper.sh
scripts/__openbox_delete_wallpaper.sh
scripts/__openbox_dmenu.sh
scripts/__openbox_edit_screenshot.sh
scripts/__openbox_edit_wallpaper_gimp.sh
scripts/__openbox_freebsd_sound.sh
scripts/__openbox_lock_zzz.sh
scripts/__openbox_lock.sh
scripts/__openbox_recent.sh
scripts/__openbox_reload_wallpaper.sh
scripts/__openbox_restart_conky.sh
scripts/__openbox_restart_dzen2.sh
scripts/__openbox_restart_plank.sh
scripts/__openbox_restart_tint2.sh
scripts/__openbox_show_screenshot.sh
scripts/__openbox_stats_ps_KILLALL.sh
scripts/__openbox_stats_top_cpu_KILL.sh
scripts/__openbox_stats_top_cpu_RENICE.sh
scripts/__openbox_stats_top_mem_KILL.sh
scripts/__openbox_stats_top_mem_RENICE.sh
scripts/aero-snap.sh
scripts/fc-cache.sh
scripts/firefox-clean.sh
scripts/network.sh
scripts/random_wallpaper.sh
scripts/shot.sh
scripts/xterm.sh
scripts/desktop-kill-shit.sh
scripts/desktop-battery-warning.sh

Make sure they remain executable.

% chmod +x ~/scripts/*

To make them work properly add ~/scripts into the ${PATH} variable at the beginning of the ~/.xinitrc file.

# PATH TO SCRIPTS
  export PATH=${PATH}:~/scripts


All of my scripts have this ‘mysterious’ line at the end. Its for statistics to check which scripts are run when (or it at all to which ones to delete).

echo '1' >> ~/scripts/stats/$( basename ${0} )

Thus it is needed to create the ‘stats’ directory.

% mkdir -p ~/scripts/stats

I have implemented that about two months ago and here are the results.

% wc -l ~/scripts/stats/* | sort -n
       1 /home/vermaden/scripts/stats/__openbox_show_screenshot.sh
       2 /home/vermaden/scripts/stats/__openbox_cpufreq.sh
       2 /home/vermaden/scripts/stats/__openbox_current_wallpaper.sh
       2 /home/vermaden/scripts/stats/__openbox_fullscreen.sh
       4 /home/vermaden/scripts/stats/__openbox_restart_dzen2.sh
       4 /home/vermaden/scripts/stats/dzen2-fifo.sh
       5 /home/vermaden/scripts/stats/__openbox_dmenu.sh
       5 /home/vermaden/scripts/stats/__openbox_restart_conky.sh
       5 /home/vermaden/scripts/stats/__openbox_restart_tint2.sh
       6 /home/vermaden/scripts/stats/__openbox_delete_wallpaper.sh
       7 /home/vermaden/scripts/stats/__openbox_freebsd_sound.sh
       8 /home/vermaden/scripts/stats/aero-snap.sh
      12 /home/vermaden/scripts/stats/__openbox_edit_screenshot.sh
      16 /home/vermaden/scripts/stats/__openbox_lock_zzz.sh
      16 /home/vermaden/scripts/stats/__openbox_lock.sh
      22 /home/vermaden/scripts/stats/shot.sh
      24 /home/vermaden/scripts/stats/network.sh
     214 /home/vermaden/scripts/stats/xterm.sh
     960 /home/vermaden/scripts/stats/random_wallpaper.sh
    2767 /home/vermaden/scripts/stats/desktop-battery-warning.sh
   13834 /home/vermaden/scripts/stats/desktop-kill-shit.sh
   17916 total

Of course I limited the output only to scripts that are available in this article, but be patient, more to come later 🙂

Dependencies

To make these scripts work and generally to make all this setup work we will need these dependencies.

  • arandr
  • gfontview
  • qtconfig
  • qt5ct
  • qtconfig-qt4
  • sakura
  • leafpad
  • geany
  • caja
  • thunar
  • libreoffice
  • galculator
  • pidgin
  • firefox
  • chrome
  • deadbeef
  • transmission-gtk
  • gnumeric
  • abiword
  • audacity
  • filezilla
  • midori
  • gimp
  • lupe
  • recorder
  • xvidcap
  • zenity
  • xterm
  • xrdb
  • scrot
  • feh
  • wmctrl
  • xdotool
  • viewnior
  • tint2
  • plank
  • dzen2
  • conky
  • mate-screensaver
  • xlockmore
  • gimp
  • dmenu
  • powerdxx
  • htop
  • galculator

To install them all with pkg(8) just type this line below.

# pkg install \
    geany caja thunar libreoffice galculator pidgin firefox chrome midori \
    abiword deadbeef transmission-gtk gnumeric  audacity filezilla zenity \
    gimp lupe recorder xvidcap  xterm xrdb scrot feh wmctrl xdotool tint2 \
    viewnior plank dzen2 conky mate-screensaver xlockmore powerdxx arandr \
    qt5ct gfontview galculator qtconfig qtconfig-qt4 sakura leafpad dmenu \
    htop 
   

I also assume that wallpapers will be kept under ~/gfx/wallpapers dir and screenshots made under ~/gfx/screenshots directory, so lets create them now.

% mkdir -p ~/gfx/wallpapers
% mkdir -p ~/gfx/screenshots

Crontab

Some of these scripts needs to be put into crontab(1) to work, here are their entries.

% crontab -l
# DESKTOP
  *     *     * * * ~/scripts/desktop-kill-shit.sh                                       1> /dev/null 2> /dev/null
  */5   *     * * * ~/scripts/desktop-battery-warning.sh
  */20  *     * * * ~/scripts/random_wallpaper.sh ~/gfx/wallpapers                       1> /dev/null 2> /dev/null
  12,0  *     * * * /usr/bin/find ~/.cache -mtime +10 -delete                            1> /dev/null 2> /dev/null
  0     */3   * * * /usr/bin/find ~/.local/share/Trash/files -mtime +1 -delete  1> /dev/null 2> /dev/null

Fonts

I use Ubuntu Mono font for the Openbox menus and Fira Sans font for the Openbox window bar titles, thus you will download them in the fonts.tar.gz file and extract them like that into the ~/.fonts directory, if if does not exists, create it.

% find .fonts
.fonts/fira-sans-bold-italic.otf
.fonts/fira-sans-bold.otf
.fonts/fira-sans-italic.otf
.fonts/fira-sans-regular.otf
.fonts/ubuntu-mono-bold-italic.ttf
.fonts/ubuntu-mono-bold.ttf
.fonts/ubuntu-mono-italic.ttf
.fonts/ubuntu-mono-regular.ttf

To make sure that Openbox will ‘see’ them you can verify it using the fc-match(1) command like below.

% fc-match 'Fira Sans'
fira-sans-regular.otf: "Fira Sans" "Regular"

% fc-match 'Ubuntu Mono'
ubuntu-mono-regular.ttf: "Ubuntu Mono" "Regular"

Openbox

Openbox consists mostly of two files.

  • ~/.config/openbox/menu.xml
  • ~/.config/openbox/rc.xml

There are also these two, but its pointless to use them as we set our environment and start our apps/daemons in the ~/.xinitrc file (with ~/.xsession symlink to it), but anyway.

  • ~/.config/openbox/autostart
  • ~/.config/openbox/environment

The icons for the Openbox menu are kept under ~/.config/openbox/icons directory.

Download whole Openbox configuration in the openbox.tar.gz file and unpack it into the ~/.config/openbox to make it look like that.

% find .config/openbox -maxdepth 1
.config/openbox
.config/openbox/rc.xml
.config/openbox/menu.xml
.config/openbox/icons
.config/openbox/environment
.config/openbox/autostart

Openbox Theme

The theme we will use at start is the Openbox Flat made by myself, I do not remember if I put it online on the https://www.box-look.org/ site but that does not matter. Grab it in the openbox-flat-theme.tar.gz file and unpack it like that into the ~/.themes directory, create it if it does not exists.

% find .themes/openbox_flat
.themes/openbox_flat
.themes/openbox_flat/openbox-3
.themes/openbox_flat/openbox-3/iconify.xbm
.themes/openbox_flat/openbox-3/XPM
.themes/openbox_flat/openbox-3/XPM/over.xpm
.themes/openbox_flat/openbox-3/XPM/close.xpm
.themes/openbox_flat/openbox-3/XPM/max.xpm
.themes/openbox_flat/openbox-3/XPM/stick.0.xpm
.themes/openbox_flat/openbox-3/XPM/min.xpm
.themes/openbox_flat/openbox-3/XPM/shade.xpm
.themes/openbox_flat/openbox-3/XPM/stick.1.xpm
.themes/openbox_flat/openbox-3/max.xbm
.themes/openbox_flat/openbox-3/close.xbm
.themes/openbox_flat/openbox-3/bullet.xbm
.themes/openbox_flat/openbox-3/shade.xbm
.themes/openbox_flat/openbox-3/themerc
.themes/openbox_flat/openbox-3/desk.xbm
.themes/openbox_flat/openbox-3/desk_toggled.xbm

Openbox FreeBSD Submenus

The ‘systemOpenbox submenu is for FreeBSD top(1)/ps(1) commands and config files/logs.

openbox-system.jpg

The ‘soundOpenbox submenu is for FreeBSD default sound output selection.

openbox-sound.jpg

The ‘recentOpenbox submenu is for Recent files.

openbox-recent.jpg

Check ‘screenshot:‘ and ‘wallpaper:‘ in the ‘x11Openbox submenu for screenshots/wallpapers management.

Check ‘cpu:‘ in the ‘utilitiesOpenbox submenu for FreeBSD for CPU frequency scaling.

Check ‘NETWORK:‘ in the ‘daemonsOpenbox submenu for FreeBSD network management with network.sh script.

Shortcuts

Lets start with the most basic ones. [SUPER] is the so called Windows key.

Shortcuts – Virtual Desktops

  • [ALT] + [F1] – switch to 1st virtual desktop.
  • [ALT] + [F2] – switch to 2nd virtual desktop.
  • [ALT] + [F3] – switch to 3rd virtual desktop.
  • [ALT] + [F4] – switch to 4th virtual desktop.
  • [SHIFT] + [ALT] + [F1] – move current window to 1st virtual desktop.
  • [SHIFT] + [ALT] + [F2] – move current window to 2nd virtual desktop.
  • [SHIFT] + [ALT] + [F3] – move current window to 3rd virtual desktop.
  • [SHIFT] + [ALT] + [F4] – move current window to 4th virtual desktop.

Shortcuts – Menus

  • [SUPER] + [SPACE] – show Openbox root menu.
  • [SUPER] + [ALT] + [SPACE] – show Openbox window list menu.
  • [ALT] + [SPACE] – show current window options menu (client menu).

Shortcuts – Window Management

  • [ALT] + [TAB] – cycle windows focus forward.
  • [SHIFT] + [ALT] + [TAB] – cycle windows focus backward.
  • [CTRL] + [ALT] + [Q] – close current window.
  • [CTRL] + [ALT] + [F] – put current window info fullscreen.
  • [ALT] + [Up] – shade current window.
  • [ALT] + [Down] – minimize current window.
  • [ALT] + [ESC] – send current window below all other windows.

Shortcuts – Advanced Aero Snap

  • [SUPER] + [Up] – move window to half of the screen from top.
  • [SUPER] + [Down] – move window to half of the screen from bottom.
  • [SUPER] + [Left] – move window to half of the screen from left.
  • [SUPER] + [Right] – move window to half of the screen from right.
  • [SUPER] + [CTRL] + [Up] – move window to top-left part of the screen.
  • [SUPER] + [CTRL] + [Down] – move window to bottom-left part of the screen.
  • [SUPER] + [ALT] + [Up] – move window to top-right part of the screen.
  • [SUPER] + [ALT] + [Down] – move window to bottom-right part of the screen.
  • [SUPER] + [ESC] – move window to center – but without fullscreen.

Shortcuts – Mouse

  • [Scroll Up] on Desktop – previous virtual desktop.
  • [Scroll Down] on Desktop – next virtual desktop.
  • [Scroll Up] on (unshaded) Window Titlebar – shade current window.
  • [Scroll Up] on (shaded) Window Titlebar – unshade current window.
  • [Middle Click] on Window Titlebar – send window to background.
  • [Right Click] on Window Titlebar – show window options menu (client menu).
  • [Left Click] on Window Titlebar Icon – show window options menu (client menu).
  • [Middle Click] on Window Titlebar Icon – close window.

Shortcuts – Various

  • [CTRL] + [SHIFT] + [ESC] – launch xterm(1) with htop(1) started with doas(1) for root provilages.
  • [SUPER] + [E] – start Explorer Caja primary file manager.
  • [SUPER] + [E] – start Thunar secondary file manager.
  • [SUPER] + [D] – show desktop – minimize all windows.
  • [SUPER] + [R] – launch dmenu(1) starter.
  • [SUPER] + [L] – lock the screen.
  • [ALT] + [SHIFT] + [SUPER] + [L] – lock the screen and go to sleep.
  • [CTRL] + [PrintScreen] – make screenshot of the whole screen.
  • [SHIFT] + [CTRL] + [PrintScreen] – make screenshot of current window (click without moving the mouse) or selection (select part of the screen).

Shortcuts – Volume

These two work from keyboard.

  • [SUPER] + [ALT] + [PageUp] – increase volume.
  • [SUPER] + [ALT] + [PageDown] – decrease volume.

These below with mouse.

For those who do not have mouse with buttons on the wheel like the Lenovo ThinkPad Precision Wireless Mouse (0B47163) for example, use [ALT] key with mouse scroll up/scroll down on the desktop to increase/decrease volume.

If you do have such mouse, then left on the wheel to decrease and right on the wheel to increase volume.

Random Wallpaper

The random wallpaper handling is done with the ~/scripts/random_wallpaper.sh script. Be sure to put some images into the ~/gfx/wallpapers directory to make it work and to configure crontab(1) properly as shown earlier.

Random xterm(1) Theme

To have random xterm(1) theme on every startup you need three things, the ~/.Xdefaults default config file which is used by xterm(1), the ~/scripts/xterm.sh script and the ~/.config/Xdefaults directory with xterm(1) themes. I gathered all these themes all over the Internet, only the VERMADEN and VERMADEN-OLD themes are created by me.

Little preview of some of the included xterm(1) themes.

openbox-xterm.jpg

To make xterm(1) icon look better you will also need icons.tar.gz file download and extract with the end result looking as follows.

% find .icons
.icons/vermaden/xterm.xpm

Download and extract the xterm.tar.gz file to make its contents look like that.

% find .Xdefaults .config/Xdefaults 
.config/Xdefaults
.config/Xdefaults/Xdefaults.theme.3024NIGHT
.config/Xdefaults/Xdefaults.theme.ALIENBLOOD
.config/Xdefaults/Xdefaults.theme.ARTHUR
.config/Xdefaults/Xdefaults.theme.EARTHSONG
.config/Xdefaults/Xdefaults.theme.ELEMENTAL
.config/Xdefaults/Xdefaults.theme.ELEMENTARY
.config/Xdefaults/Xdefaults.theme.ELIC
.config/Xdefaults/Xdefaults.theme.FLATUI
.config/Xdefaults/Xdefaults.theme.FREYA
.config/Xdefaults/Xdefaults.theme.FRONTEND-DELIGHT
.config/Xdefaults/Xdefaults.theme.GITHUB
.config/Xdefaults/Xdefaults.theme.GREY
.config/Xdefaults/Xdefaults.theme.GRUVBOX-DARK
.config/Xdefaults/Xdefaults.theme.GRUVBOX-LIGHT
.config/Xdefaults/Xdefaults.theme.GRUVBOX-TILIX
.config/Xdefaults/Xdefaults.theme.HARPER
.config/Xdefaults/Xdefaults.theme.HEMISU-LIGHT
.config/Xdefaults/Xdefaults.theme.HIGHWAY
.config/Xdefaults/Xdefaults.theme.IC-GREEN-PPL
.config/Xdefaults/Xdefaults.theme.MOLOKAI
.config/Xdefaults/Xdefaults.theme.MONOKAI-SODA
.config/Xdefaults/Xdefaults.theme.N0TCH2K
.config/Xdefaults/Xdefaults.theme.NEOPOLITAN
.config/Xdefaults/Xdefaults.theme.PALI
.config/Xdefaults/Xdefaults.theme.PAPERCOLOUR
.config/Xdefaults/Xdefaults.theme.SOLARIZED
.config/Xdefaults/Xdefaults.theme.SOLARIZED-LIGHT
.config/Xdefaults/Xdefaults.theme.SPACEDUST
.config/Xdefaults/Xdefaults.theme.TOMORROW
.config/Xdefaults/Xdefaults.theme.TWILIGHT
.config/Xdefaults/Xdefaults.theme.VERMADEN
.config/Xdefaults/Xdefaults.theme.VERMADEN-OLD

Thats a lot of information for one article, feel free to ask me for anything related or about things that I might forgot to put here.

EOF.

.
.
.
.
.

FreeBSD Desktop – Part 11 – Key Components – Blue Light Spectrum Suppress

In the Part 11 of the FreeBSD Desktop series I would like to describe key components of self made custom desktop environment such as:

  • Window Manager
  • Status Bar
  • Task Bar
  • Wallpaper Handling
  • Application Launcher
  • Keyboard/Mouse Shortcuts
  • Locking Solution
  • Blue Light Spectrum Suppress

Today we will focus on the Blue Light Spectrum Suppress component. In the next series each of these components configuration would also be described along with eventual needed scripts.

You may also check earlier articles of the FreeBSD Desktop series:

Latest versions of popular operating systems like Mac OS X (macOS) and Windows (or up-to-date Android based devices) already provide a feature to automatically adjusts color temperature of the screen according to your current time in your location. In short when then Sun is up the color temperature should be closer to about 5500K and when the Sun is down (evening/night) it should be around 3700K.

If You have never heard about Circadian Rhythm then check Wikipedia page for details. Basically its kind of 24 hour internal clock that is runs in the background of your brain and switches between sleepiness and alertness at regular intervals, also known as sleep/awake cycle.

Light, and especially temperature of this light, directly affects this cycle, if You use blue spectrum light when the Sun is down, then You are disrupting the Circadian Rhythm, to cite Wikipedia“Studies have also shown that light has a direct effect on human health because of the way it influences the circadian rhythms.” and also – “Blue LED lighting suppresses melatonin production five times more than the orange-yellow high-pressure sodium (HPS) light.” If your body produces melatonin, then you become more sleepy, if something it preventing that production – like blue light spectrum – then you are not getting sleepy and Circadian Rhythm gets broken.

When You put two images side by side, one with about 3700K color temperature and one with about 5500K color temperature you will be able to spot the difference between them, but the tools that manage these temperatures make transition smooth and unwatchable, only if you kill the application in the night/evening you will be able to spot the difference.

Daily temperature.

temp-cold.jpg

Nightly temperature.

temp-warm.jpg

I know two tools that resolve that problem on X11 environment:

F.lux

Why would you want to run closed source software while You can use open source and it does the same thing? Personally I use Redshift but I want to mention F.lux here as Redshift project itself admits that their program is inspired by F.lux.

To cite the F.lux page it “makes the color of your computer’s display adapt to the time of day, warm at night and like sunlight during the day.”

While F.lux does not provide a native binary for FreeBSD it does offer such binary for Linux and as FreeBSD provides Linux Binary Compatibility its possible to use it on FreeBSD. That Linux binary of F.lux is available to download as tar archive xflux.tgz from the https://justgetflux.com/linux.html page.

Here is how it looks under FreeBSD.

% uname -mro
FreeBSD 11.2-RELEASE amd64

% file ~/scripts/bin/xflux
/home/vermaden/xflux: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.15, BuildID[sha1]=0b2094d4f1fd64100ceba2f61a7ff606f6f1cc8c, not stripped

To use F.lux just start it in the ~/.xinitrc or ~/.xsession file like that.

~/path/to/bin/xflux -l 33.54321 -g 11.12345 &

Of course 33.54321 is latitude and 11.12345 is longitude of your localization.

Redshift

This is the solution that I propose to use as open source blue light spectrum suppressor. To cite the project site “Redshift adjusts the color temperature of your screen according to your surroundings.”

Similarly like with the F.lux to start Redshift just put it in the ~/.xinitrc or ~/.xsession file like that.

redshift -l 33.54321:11.12345 -g 0.9 &

Like earlier 33.54321 is latitude and 11.12345 is longitude of your localization.

Difference

How one can tell the difference with or without using application that suppress blue light spectrum when the Sun is down? You will not be able to tell the difference instantly, but leave it enabled and think about that a month later.

When I did not used such app I was able to choose to stay up and do something till very late, like go to sleep at 3:00 AM for example or I could choose to ‘make good sleep’ and go to bed at about 0:00. After I started to use such application (first F.lux and lately Redshift) I become sleepy/tired at about 23:30 and its harder to stay up late. I think that my sleep become better and overall ‘attitude/awareness/energy/…’ are better now, but your millage may vary, check it for yourself.

EOF.

.
.
.
.
.

FreeBSD Desktop – Part 10 – Key Components – Locking Solution

In the Part 10 of the FreeBSD Desktop series I would like to describe key components of self made custom desktop environment such as:

  • Window Manager
  • Status Bar
  • Task Bar
  • Wallpaper Handling
  • Application Launcher
  • Keyboard/Mouse Shortcuts
  • Locking Solution
  • Blue Light Spectrum Suppress

Today we will focus on the sixth part – the Locking Solution. In the next series each of these components configuration would also be described along with eventual needed scripts.

You may also check earlier articles of the FreeBSD Desktop series:

While screen locking feature is obvious for popular operating systems like Mac OS X (macOS) and Windows (or complete desktop environments such as KDE Plasma) its not when you build your desktop environment from the ground up. Similarly like in Part 9 about Keyboard/Mouse Shortcuts I will describe what light solutions will work here instead of focusing on all available solutions and choosing the best ones from them.

The tools we will embrace in this process are:

  • mate-screensaver
  • xlock
  • xautolock

The roles of mate-screensaver and xlock are redundant but we will keep xlock as fallback when mate-screensaver will fail for some reason. For example after upgrade some library may not be available (or will be present but in different version or filename) so mate-screensaver will fail and then xlock will take the role to securely lock the screen.

The xautolock will be used to automatically lock the screen (invoke mate-screensaver or xlock command) after defined period of inactivity time, for example when You would forgot to lock the screen and left the laptop ‘open’ to the World. 🙂

mate-screensaver

From all the nice looking solutions providing screen lock on the X11 I found mate-screensaver the best choice for this task. By default it does not display any fancy screensaver, just plain old blank screen, which is good for laptops, saves battery time.

locker-mate-screensaver.png

The mate-screensaver has to be started and run in the background with, well mate-screensaver command – placed somewhere in the ~/.xinitrc or ~/.xsession file. Then we would be able to invoke mate-screensaver-command --lock command to make the actual screen lock.

xlock

When mate-screensaver will not be available or functional we will use xlock as failover solution.

Its not very pretty and does not support FreeType fonts, but with clean or fixed font face its not that bad either, as they are quite nice and usable bitmap fonts.

The xlock tool appearance can be configured by specifying arguments. Below you will find example configuration with gray background and clean bitmap font.

% xlock \
    -mode blank \
    -planfontset '-*-clean-*-*-*-*-*-*-*-*-*-*-iso8859-2' \
    -fontset     '-*-clean-*-*-*-*-*-*-*-*-*-*-iso8859-2' \
    -username 'USERNAME: ' \
    -password 'PASSWORD: ' \
    -background gray30 \
    -dpmsoff 1 \
    -message ' ' \
    -info ' '

Here is how it looks after configuration.

locker-xlock

xautolock

We have addressed the on demand screen locking case but now we also need to make sure, that our screen will automatically lock after some period of time while we are away from the computer. Small utility called xautolock does exactly that and does it very efficiently.

Example invocation is presented below.

% xautolock \
    -time 1 \
    -locker \
    ~/bin/example-lock-handler.sh \
    -resetsaver

The xautolock also has to be started and run in the background using the ~/.xinitrc or ~/.xsession file.

EOF.

.
.
.
.
.

FreeBSD Desktop – Part 9 – Key Components – Keyboard/Mouse Shortcuts

In the Part 9 of the FreeBSD Desktop series I would like to describe key components of self made custom desktop environment such as:

  • Window Manager
  • Status Bar
  • Task Bar
  • Wallpaper Handling
  • Application Launcher
  • Keyboard/Mouse Shortcuts
  • Locking Solution
  • Blue Light Spectrum Suppress

Today we will focus on the sixth part – the Keyboard/Mouse Shortcuts. In the next series each of these components configuration would also be described along with eventual needed scripts.

You may also check earlier articles of the FreeBSD Desktop series:

Keyboard/Mouse Shortcuts

While most window managers and desktop environments offer some kind of shortcuts or tools to define your own ones its often quite complicated to force them to do exactly what you want. For example – while Openbox supports creating keyboard and mouse shortcuts it always require modifier key like [ALT], [CTRL] or [SUPER] for example. It will also not allow you to create mouse shortcuts like using only the left button of the mouse wheel (not to confuse with regular left mouse button). Or to add some function or script to keys like [Scroll Lock] or [Pause Break] without any other modifiers.

Fortunately there are tools that can and work well together to achieve almost anything you can imagine. While earlier in the series I made knockouts of solutions – or choosing the best one from several potential candidates in this part its different. I use ALL of these tools and there will be no knockout, they all provide some ‘missing bits’ to the Openbox or probably most of other window managers.

These tools are:

  • xev
  • xmodmap
  • xbindkeys
  • xdotool

 

Xev

The xev is used to ‘read’ what has keyboard key has been pressed or which mouse button was used. While it may sound stupid for most of the keys it does not for ‘special’ ones like Volume Up and Volume Down ‘dedicated’ buttons on many laptops or [Page Up] and [Page Down] keys which are named Prior and Next respectively.

keyboard-xev.jpg

Xmodmap

This tool is used to assign or rename keys to make something different, for example Lenovo ThinkPad laptops have two special keys – lets call them Forward and Backward – near the Arrows keys. They work a lot better as [Page Up] and [Page Down] keys so with xmodmap its possible to map them that way.

Other popular use case are laptop Volume Up and Volume Down buttons, or Volume Mute button. While checked with xev they often has only some keycode attached while you may map them into XF86AudioLowerVolume, XF86AudioRaiseVolume and XF86AudioMute respectively so that X11 will take care of the rest, they will ‘start work’ in most applications thanks to that mapping. Additional scripting is not needed here.

Example modifier map shown by xmodmap tool.

% xmodmap -pm  
xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x6d)
mod1        Alt_L (0x40),  Meta_L (0x9c)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0x73),  Super_R (0x74),  Super_L (0x7f),  Hyper_L (0x80)
mod5        Mode_switch (0x8),  ISO_Level3_Shift (0x7c)

The xmodmap will load and map our keys and then will exit, files like ~/.xinitrc or ~/.xsession are good places for such startup keyboard setup.

Xbindkeys

While most window managers – including Openbox – support configuring keyboard shortcuts it is not perfect and has some limitations, like requiring modifier key like [ALT], [CTRL] or [SUPER] to be used in every shortcut for example.

This is where xbindkeys steps in. While xev will do for most cases it will fail you in more advanced scenarios. For example when You would like to attach Volume Up and Volume Down actions to your mouse Left Wheel Button and Right Wheel Button keys. I will probably not be able to express how useful mapping it is. Even when you laptop screen is locked you will be able to turn the volume down or up.

Similarly like xev the xbindkeys comes with its own window to catch events.

keyboard-xbindkeys.jpg

Here are these bindings.

% xbindkeys -s 
"mixer pcm 100; mixer vol +5"
    m:0x0 + b:9   (mouse)
"mixer pcm 100; mixer vol -5"
    m:0x0 + b:8   (mouse)
(...)

The xbindkeys will run as a daemon in the background, files like ~/.xinitrc or ~/.xsession are usual places to start it when our X11 environment starts.

The xbindkeys tool also comes with its own ‘key identifier’ as xev does. Use it with -k/--key argument to identify one key pressed or -mk/--multikey argument to identify multi key pressed respectively.

% xbindkeys -k
Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
"(Scheme function)"
    m:0x0 + c:99
    Prior
% 

Xdotool

Sometimes you want to ‘fake’ that some keys were pressed – but without pressing them – without touching the keyboard. While some applications offer some settings to be changed by an argument to their main binary name – like for example DeaDBeeF media player allows you to type deadbeef --next to skip to next song – many applications don’t provide such ‘API’. This is where xdotool comes handy – it can generate any keyboard shortcut and send it to and application in X11 environment. Great tool for scripting and automating ‘work’ on the desktop and also for situations where nothing else works.

An example of such ‘useful’ shortcut may be emulating of [Z] (the [Shift]+[z] combination) key press on mupdf PDF viewer to “Zoom page to fit either to width or height of window.” after opening new PDF document.

Summary

Each of these tools plays some role in keyboard and mouse shortcuts on the X11 desktop. Together they are able to execute any solution you can imagine.

EOF.

.
.
.
.
.

FreeBSD Desktop – Part 8 – Key Components – Application Launcher

In the Part 8 of the FreeBSD Desktop series I would like to describe key components of self made custom desktop environment such as:

  • Window Manager
  • Status Bar
  • Task Bar
  • Wallpaper Handling
  • Application Launcher
  • Keyboard/Mouse Shortcuts
  • Locking Solution
  • Blue Light Spectrum Suppress

Today we will focus on the fifth part – the Application Launcher. In the next series each of these components configuration would also be described along with eventual needed scripts.

You may also check earlier articles of the FreeBSD Desktop series:

Application Launcher

While not being any crucial role of the desktop environment it have its uses and sometimes save time. As its not hard to add this ‘feature’ to our setup I will evaluate two light and fast solutions that fulfill that role:

  • Dmenu
  • Rofi

Resources

Lets start with resources, the Rofi implementation of application launcher uses almost 3 times more RAM – 21 MB – then Dmenu solution – 8 MB.

  PID USERNAME      THR PRI NICE   SIZE    RES STATE   C   TIME    WCPU COMMAND
16952 vermaden        1  24    0 13860K  8968K select  0   0:00   1.76% dmenu
86078 vermaden        3  24    0 32980K 21712K select  0   0:00   2.54% rofi

The Dmenu is also faster while Rofi have more eye candy and colors.

Dmenu

As Dmenu suits better to this ‘minimalist’ yet functional desktop I will use it instead of Rofi, but feel free to experiment between them and choose best option for You.

This Dmenu setup – after being run – will cover the Dzen2 status bar with filtered commands fitting nicely into the setup, here is how it looks in action.

Desktop without Dmenu launched.

launcher-dmenu.jpg

Desktop with Dmenu launched and with alc characters inserted to ‘filter’ commands in the search of a calculator application.

launcher-dmenu-run.jpg

Rofi

While Dmenu is doing a good job here lets have a look how Rofi behaves in that role.

While I use a custom script for Dmenu – which I will present later in the series – the Rofi requires more simple command.

% rofi -show run -theme solarized_alternate -font "Monaco 8"

Here is how Rofi looks in action.
launcher-rofi.jpg

For the record, I also entered same alc characters into Rofi to ‘filter’ commands in the search of a calculator application.

While Dmenu has very narrow ‘specialization’ the Rofi can also be used in other scenarios which are described on the project site.

EOF.

.
.
.
.
.