More XFCE and Thunar Customizations

Round two: workspaces, panel readouts, a colour picker, and two more right-click actions

The first post built a Thunar toolbox out of small scripts. This one widens the net: desktop workspaces, live panel status, a screen colour picker, and a couple more context-menu entries.

Everything here is reproducible from the command line via xfconf-query, which is XFCE’s settings database. If you’d rather click, every one of these also lives somewhere under Settings → Window Manager / Workspaces / Keyboard / Panel.


First, a fix

Last round’s Copy path to clipboard action didn’t work — due to dependency I’d flagged but not installed. One install fixed it:

sudo apt install xclip

Two more Thunar actions

Open in VS Code

The simplest possible custom action — VS Code already has a CLI launcher:

  • Name: Open in VS Code
  • Command: code %F
  • Appearance: all file types and directories (so you can open a whole folder as a workspace).

%F passes the full selection, so multi-selecting three files opens all three as tabs.

Run in terminal (a reusable wrapper)

The trick is a terminal that doesn’t vanish the instant the command exits. That’s a one-line wrapper worth having on your PATH:

#!/usr/bin/env bash
# run-in-terminal — run a command in a terminal that stays open afterwards.
#   usage: run-in-terminal CMD [ARGS...]
set -euo pipefail
[ "$#" -ge 1 ] || { echo "usage: run-in-terminal CMD [ARGS...]" >&2; exit 1; }
exec xfce4-terminal --hold --title="run: $1" -x "$@"

--hold is the important flag — the window stays after the program ends so you can read the output. I wired it to a Run in terminal action scoped to executable/script types:

  • Command: run-in-terminal %f
  • File Pattern: *.sh;*.py;*.pl;*.rb;*.bash;*.zsh;*.AppImage;*.run;*.bin

Now right-clicking a script runs it in a window that waits for you. And because it’s a generic wrapper, any of the earlier actions can be made verbose by prefixing its command with run-in-terminal — e.g. run-in-terminal sha256sum %F to watch a checksum scroll by.

Housekeeping

While in ~/.config/Thunar/uca.xml I deleted a leftover blank custom action (empty name and command) from an earlier editing session. It did nothing but clutter the Configure custom actions dialog.


Virtual workspaces

This rig was running on one workspace, but I need more:

xfconf-query -c xfwm4 -p /general/workspace_count -s 4

XFCE’s workspace keyboard shortcuts were already defined, just useless with a single desktop.

Shortcut Action
Ctrl+Alt+←/→/↑/↓ move to the adjacent workspace
Ctrl+F1 … Ctrl+F12 jump straight to workspace N
Ctrl+Alt+Home/End send the current window to the prev/next workspace
Ctrl+Alt+Shift+←/→/↑/↓ (move-window variants)
Alt+Insert / Alt+Delete add / remove a workspace on the fly

The pager (workspace switcher)

To see the workspaces on the panel I added the pager plugin (see the panel section below). It draws the little grid of desktops you can click to switch, and it shows window positions at a glance.


Window tiling — already there

I went in expecting to bind half/quarter-screen tiling and found xfwm4 already had the full set wired up:

Shortcut Tiles window to
Super+← / Super+→ left / right half
Super+↑ / Super+↓ top / bottom half (and maximize-ish)
Super + Numpad 7/9/1/3 the four corners (quarter-screen)

Nothing to do but document it. Super+D was likewise already bound to show desktop, and Super+T / Ctrl+Alt+T to launch terminal

# How I audited the existing bindings:
xfconf-query -c xfce4-keyboard-shortcuts -l | grep '/xfwm4/custom/'

A screen colour picker

Grab the hex of any pixel on screen. No such utility was installed, so:

sudo apt install gpick

gpick has a one-shot CLI mode, so a tiny wrapper turns “pick a pixel” into “pick a pixel → hex on clipboard → desktop notification”:

#!/usr/bin/env bash
# pick-color — pick a screen colour with gpick, copy hex to the clipboard.
set -euo pipefail
hex=$(gpick -p -s -o --no-newline 2>/dev/null) || exit 0
[ -n "$hex" ] || exit 0
printf '%s' "$hex" | xclip -selection clipboard
command -v notify-send >/dev/null 2>&1 && notify-send -i gpick "Colour copied" "$hex" || true

Bound to a free chord, Super+C:

xfconf-query -c xfce4-keyboard-shortcuts \
  -p "/commands/custom/<Super>c" -n -t string -s "pick-color"

Press Super+C, click any pixel, paste the hex wherever you need it.


Panel plugins

XFCE’s panel is a row of plugins along the top of screen in my case, each with a numeric id, listed in the xfce4-panel xfconf channel. Adding a plugin is three steps: name a new id, declare its type, and splice that id into the panel’s plugin-ids array. Then restart the panel.

I added three: pager (workspaces), genmon (a scriptable status readout), and netload (network throughput). The pulseaudio, clock, systray, and power plugins were already present. I’m already a nice customization conky, but sometimes I can’t see my desktop.

The genmon system monitor

genmon (“generic monitor”) runs a script on a timer and shows whatever it prints. That makes it the most flexible plugin on the panel — anything you can script becomes a live readout. Mine shows load, memory, and CPU temp:

#!/usr/bin/env bash
# genmon-sysstat — compact system status for xfce4-genmon-plugin.
set -euo pipefail
load=$(cut -d' ' -f1 /proc/loadavg)
mem=$(free -m | awk '/^Mem:/{printf "%d%%", $3*100/$2}')
temp=$(sensors 2>/dev/null \
    | awk '/^(Tctl|Tdie|Package id 0|CPU)/{gsub(/[+°C]/,"",$2); printf "%.0f", $2; exit}')
[ -n "$temp" ] && tempstr=" ${temp}°C" || tempstr=""
printf '<txt>⚙ %s · %s%s</txt>\n' "$load" "$mem" "$tempstr"
printf '<tool>Load avg: %s\nMemory used: %s%s\nClick: System Monitor</tool>\n' "$load" "$mem" "$tempstr"
printf '<txt-click>xfce4-taskmanager</txt-click>\n'

Output: ⚙ 1.79 · 61% 71°C. genmon understands a little markup — <txt> is the panel text, <tool> the hover tooltip, <txt-click> a command to run when clicked (here, the task manager). The temp line uses lm-sensors; on this AMD box the CPU reports as Tctl, on Intel it’d be Package id 0 — the awk matches either.

Extend it: the obvious next version pings the niva PostGIS database and shows a green/red dot for connectivity — genmon doesn’t care what the script does, only what it prints.

How the plugins were added

# 1. Declare three new plugin ids (22-24 were free; 21 was the highest).
xfconf-query -c xfce4-panel -p /plugins/plugin-22 -n -t string -s pager
xfconf-query -c xfce4-panel -p /plugins/plugin-23 -n -t string -s genmon
xfconf-query -c xfce4-panel -p /plugins/plugin-24 -n -t string -s netload

# 2. Point genmon at the script, label off, refresh every 2s.
xfconf-query -c xfce4-panel -p /plugins/plugin-23/command       -n -t string -s "genmon-sysstat"
xfconf-query -c xfce4-panel -p /plugins/plugin-23/use-label     -n -t bool   -s false
xfconf-query -c xfce4-panel -p /plugins/plugin-23/update-period -n -t int    -s 2000

# 3. Rewrite the panel order, inserting the new ids where I want them
#    (pager near the window list; genmon + netload just before the clock).
#    An array property must be set all at once, every element typed.
xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids \
  -t int -s 1 -t int -s 2 -t int -s 22 -t int -s 3 -t int -s 15 \
  -t int -s 14 -t int -s 13 -t int -s 11 -t int -s 4 -t int -s 5 \
  -t int -s 6 -t int -s 7 -t int -s 8 -t int -s 9 -t int -s 23 \
  -t int -s 24 -t int -s 10 -t int -s 16 -t int -s 17 -t int -s 18 \
  -t int -s 12 -t int -s 19 -t int -s 20 -t int -s 21

# 4. Reload the panel to pick up the new plugins.
xfce4-panel -r

The all-at-once array rewrite is the one fiddly bit. xfconf-query can’t append a single element to an array property — you re-send the entire list, each value with its -t int -s. Read the current array first (xfconf-query -c xfce4-panel -p /panels/panel-1/plugin-ids) and edit from there. If you’d rather not, just right-click the panel → Panel → Add New Items… and drag the plugin where you want it; the GUI does the array surgery for you.

If you prefer the GUI throughout: right-click the panel → Panel → Add New Items…, pick Generic Monitor, Network Load Monitor, Workspace Switcher, then double-click each to configure.

Other panel plugins worth a look

  • Weather (xfce4-weather-plugin) — needs a one-time location setup, so it’s easiest to add via the GUI.
  • CPU Graph / Sensor / DiskPerf — dedicated monitors if you’d rather not script genmon.

Packages installed this round

sudo apt install xclip gpick xfce4-genmon-plugin xfce4-netload-plugin

(xcolor would have been a lighter colour picker but isn’t in these repos, so gpick it is.)

New scripts in ~/.local/bin

Script Used by Purpose
run-in-terminal Run in terminal action, any verbose action run a command in a terminal that stays open
pick-color Super+C pick a screen pixel’s hex → clipboard
genmon-sysstat genmon panel plugin load / memory / CPU-temp readout

What changed, at a glance

  • Fixed: Copy-path-to-clipboard (installed xclip).
  • Thunar: + Open in VS Code, + Run in terminal; removed a blank action.
  • Desktop: 1 → 4 workspaces; added the pager to the panel.
  • Confirmed already-bound: tiling (Super+arrows), show-desktop (Super+D), launch-terminal (Super+T), all the workspace shortcuts.
  • New shortcut: Super+C → screen colour picker.
  • Panel: + genmon (scripted system status), + netload.

As always: scripts in ~/.local/bin/, Thunar actions in ~/.config/Thunar/uca.xml, and everything else in xfconf-query channels (xfwm4, xfce4-panel, xfce4-keyboard-shortcuts). Nothing here needs a logout — xfce4-panel -r reloads the panel and xfconf changes apply live.