Xfce Commands and Other Useful Stuff

Version: 

Section: 

Xfce

On this page:

This document brings together some of the important commands, scripts and other information for working with Xfce. Many are extracted from various Xfce Forum posts, usually by ToZ.

NOTE: for now, the document lacks any overriding structure, serving merely as a repository of material.

 

Refresh the icon cache

This command can be used to install a new icon set (does not work on svg icons).

gtk-update-icon-cache /path/to/my/icon/theme

Wrap mouse at end of multiple screens (script)

#!/bin/bash

#calculate total width of all screens
let "totalWidth = -1"
let "numOfScreens = -1"
for size in $(xrandr | grep -w connected | awk -F'[ +]' '{print $3}' | cut -d x -f 1)
do
let "totalWidth += $size"
let "numOfScreens += 1"
done

while true
do
#get mouse position
mdata=`xdotool getmouselocation`

#extract x/y coordinates
mx=`echo "$mdata"|cut -f1 -d' '|cut -d: -f2`
my=`echo "$mdata"|cut -f2 -d' '|cut -d: -f2`

#check for position and if at either left or right edge, move the mouse
if [ $mx == $totalWidth ]; then
xdotool mousemove 1 $my
elif [ $mx == 0 ]; then
xdotool mousemove --screen $numOfScreens $totalWidth $my
fi
done

 

List configuration settings

xfconf-query -c <name of channel> -lv

 

  • Channel names are those in ~/.config/xfce4/xfconf/xfce-perchannel-xml/, see the Xfce4 Start page.
    • displays
    • keyboard-layout
    • keyboards
    • thunar
    • thunar-volman
    • xfce4-appfinder
    • xfce4-desktop
    • xfce4-keyboard-shortcuts
    • xfce4-mime-settings
    • xfce4-mixer
    • xfce4-notifyd
    • xfce4-panel
    • xfce4-power-manager
    • xfce4-session
    • xfce4-settings-editor
    • xfce4-settings-manager
    • xfce4-xfwm4
    • xfce4-xsettings
  • More on the command xfconf-query here.

Change folder icon on desktop

Xfdesktop does support custom folders as of version 4.11.0. Simply put a jpg file in the same folder with the name either folder.jpg, cover.jpg, albumart.jpg, or fanart.jpg and it will become the folder icon on the desktop

Use Thunar to edit remote files

Assuming you have a server with sshd running and access to this server, enter into the Thunar address bar:

sftp://xx.xx.xx.xx

...and authenticate when prompted. This will create a gvfs-mounted share in thunar. Simply right-click the file in question and select "Open With Mousepad/Leafpad". If you have write permissions on the server for this file, you should be able to edit and save the file.

Note: you need to have gvfs (or gvfs-fuse) installed.

Trick for recovering from Suspend

If you have tried solutions for recovering correctly from Suspend, try mapping:

xrandr --auto

...to a keyboard combination. When you resume from suspend, press the keyboard combination.

Get longer titles on desktop icons

Make a file in your home folder called .gtkrc-2.0 (or edit if you have one) and add the following info.

style "xfdesktop-icon-view" {
    XfdesktopIconView::ellipsize-icon-labels = 0
}
widget_class "*XfdesktopIconView*" style "xfdesktop-icon-view"

log out and log in and you should have long file names.
 

Change font on Whisker menu

You can change the font of the title if you use the pango markup language.

  • Right-click on the Menu > Properties.
  • Set the top pull-down Display menu to 'Title' or 'Icon and title'. That way text will be displayed on a Whisker Menu button.
  • Log out and back in to see the change

Then, change the 'Title' to what you want. For example:

<span foreground="black" size="large">Menu</span>

OR

<span font_desc="Droid Sans Bold 10">Applications</span>

Kiosk mode

Some components of Xfce have support for kiosk mode. This can be enabled by creating and modifying the system kioskrc file found at:

${sysconfdir}/xdg/xfce4/kiosk/kioskrc

By default, ${sysconfdir} points to /etc

Details in the Xfce Wiki.

Icon size in Panel

If you go to the Panel Preferences > Items tab, and hover your mouse over one of the items, a tooltip will pop up that will contain the internal-name (e.g., launcher-7). The internal-name is the widget name, so you open ~/.gtk-2.0/gtkrc and add something like:

style "my-launchers"
{
xthickness = 3
ythickness = 3
}


widget "*launcher*" style "my-launchers"

This will affect all launchers, but you can be more specific with the widget name to affect individual launchers.

If you don't know the widget name or you want to effect a class of widgets, you can use the widget_class parameter. Referring back to the hierarchy, you can see that alot of button widgets are derived from the GTKButton. Therefore, to effect all button-based widgets you can do something like:

widget_class "*Button*" style "mystyle"

Run executable with click

Having shell scripts execute like that through thunar or from the desktop was deemed a security risk (it was too easy to mistakenly execute a script that would run) so that functionality was turned off by default. You can re-enable that functionality by enabling the misc-exec-shell-scripts-by-default xfconf key. To do so, create the key via the xfce4-settings-editor, or run the following command:

xfconf-query --channel thunar --property /misc-exec-shell-scripts-by-default --create --type bool --set true

Change default name of Screenshot files

There are two settings available that you can add to xfce4-screenshooter config file (~/.config/xfce4/xfce4-screenshooter) that will allow you to change the default filename:

title=<YOUR_TITLE_HERE>
timestamp=<TRUE_OR_FALSE>

The title parameter will change the first part of the filename (defaults to "Screenshot") and the second will turn on or off the appending of the timestamp after the filename.

If you turn off the timestamp, the program is smart enough to append a -1, -2, -3, etc to the end of the filename, if a file exists with that name already.

Launch multiple applications with a single click

Launch multiple programs with a single click

1. Create a new script listing the items that you want to launch, following this example:

#!/bin/bash

/opt/firefox/firefox &
/usr/bin/Thunar &
/usr/bin/thunderbird &

exit 0

Be sure that the paths and names are correct. Save it somewhere in your Home directory, and give it a name. Let's suppose you name it "LaunchAll.sh" and place it in ~/Home/Scripts. Right-click it > Properties, Permissions tab, and check the box to make it run as a program.

2. Right-click the panel > Panel > Add New Items... > Launcher, click Add; then right-click the new icon > Properties and click the Add a new empty item icon. Alternatively, on the desktop > Create Launcher. Either way, you will end up looking at the launcher's dialog box.
launcher.png
Give the launcher a name such as LaunchAll, and then click on the little square to the right of the Command line to navigate to your script. Select an icon if you want one.

That's it: now when you click that icon, all the programs you listed in your script will launch. BTW: if you want those applications not to show up on the same disorganized workspace, this would be a great time to make use of gdevilspie.

Gtkrc files

In a nutshell (lowest to highest priority):
GTK2:
- built-in theme (raleigh)
- built into the app config info
- theme location (either /usr/share/themes or ~/.themes)
- /etc/gtk-2.0/gtkrc   /   ~/.gtkrc-2.0   /   GTK2_RC_FILES
*preferred locations:
   - in a theme file if its your own custom-designed theme
   - /etc/gtk-2.0/gtkrc for system-wide overrides
   - ~/.gtkrc-2.0 for user-specific overrides
   - GTK2_RC_FILES to override gtk theme for one specific application

GTK3:
- built-in theme (adwaita)
- built into the app config info
- theme location (either /usr/share/themes or ~/.themes)
- /etc/gtk-3.0/gtk.css   /   ~/.config/gtk-3.0/gtk.css   /   GTK_THEME
*preferred locations:
   - in a theme file if its your own custom-designed theme
   - /etc/gtk-3.0/gtk.css for system-wide overrides
   - ~/.config/gtk-3.0/gtk.css for user-specific overrides
   - GTK_THEME to override gtk theme for one specific application

Dual Monitor customization

You could use a udev rule and script such as this one that will be called and executed when udev reports the connection/disconnection of the monitor.

Assign key to Custom actions in Thunar

You can easily assign a key combination to any Custom action. For example, if you have the "Open in Terminal" custom action (or something similar), you can assign a keyboard shortcut key to it. To do so, first enable editable accelerators in Settings Manager > Appearance > Settings. Then, in Thunar, hover your mouse over the File>Open in Terminal menu item and press the keyboard combination that you would like to use for that action. Then when browsing in Thunar, use the keyboard combination to open a terminal window in your active directory.

Force regular icons

With the migration to GTK+ 3, symbolic icons will be used in the Panel. But those are a GNOME-only thing so you will always have a panel mixed with regular and symbollic icons. To solve this, you can use this hint:

-gtk-icon-style: regular;

in the (new) folder ".gtk-3.0* to force non-symboic icons for the panel plugins that have ported to GTK3.

Add timestamp to a file

Use this script with a Thunar custom action:
------------
#!/bin/bash

TS="$(date +"%d-%b-%Y_%H:%M:%S")"

for f in "$@"
do

   dir=$(dirname "$f")
   fullfilename=$(basename "$f")
   extension="${fullfilename##*.}"
   filename="${fullfilename%.*}"

   # append timestamp
   cp "$f" "$dir/$filename-$TS.$extension"

   # prepend timestamp
   cp "$f" "$dir/$TS-$filename.$extension"

done

exit 0

------------------

It will work with single files (%f) and multiple files (%F).  Comment out one of the append or prepend actions if you don't want both to happen.

Adjust spacing of Thunar columns

The text inside the columns of Thunar is often jammed up against the right column edge. ToZ looked at the code and found that this snippet will fix it. Create a new file ~/.gtkrc-2.0 and paste in the code below. Then log out and back in to see the effect.

----------

style "my-details-view"
{
GtkTreeView::horizontal-separator = 20
}
widget_class "*ThunarDetailsView*" style "my-details-view"

----------

You can vary the value (10, 15, ,etc.) to suit your tastes.

Center a window using the keyboard

You can center a window using a keyboard with this script:

----------

#!/bin/bash

IFS='x' read screenWidth screenHeight < <(xdpyinfo | grep dimensions | grep -o '[0-9x]*' | head -n1)

width=$(xdotool getactivewindow getwindowgeometry --shell | head -4 | tail -1 | sed 's/[^0-9]*//')
height=$(xdotool getactivewindow getwindowgeometry --shell | head -5 | tail -1 | sed 's/[^0-9]*//')

newPosX=$((screenWidth/2-width/2))
newPosY=$((screenHeight/2-height/2))

xdotool getactivewindow windowmove "$newPosX" "$newPosY"

----------

Save it somewhere (/usr/local/bin if you want all users to access it), make it executable and assign it to a keyboard shortcut.

GTK+ CSS

The place to start is with the Gnome overview. Also helpful is the GTK Inspector which will allow you to see and manipulate the style classes, widgets, etc. To run it temporarilyi with respect to xfce4-panel, for instance, you would do the following:

GTK_DEBUG=interactive xfce4-panel

Test GTK3 theme

You can always test theme issues by using the default Adwaita theme. To test firefox with the default GTK3 theme (adwaita), first close firefox then start it with:

GTK_THEME=Adwaita firefox

Reset to default Xfce

You can remove all MX Linux modifications and restore the native Xfce configuration when you log in with a single command when not logged in (as root from another user's account or a LiveMedium):

$ mv ~/.config/xfce4/ ~/.config/xfce4-bak

You can return to the MX Linux config by restoring the backup. [Arch Wiki via ToZ).

Order partitions in Thunar

Normally Thunar reorders partitions with each login. Here is a trick to get it how you would like it (from user Paul1149):

  • Go to each internal drive, and from the right pane or address bar drag it into the PLACES list.
  • Drag them into your desired order.
  • Now right-click the empty space to the right of the word "DEVICES" in the left pane and uncheck them.
  • They will disappear, giving their vertical space back, and you will be left with a tidy list of devices in the order you want.

Change volume increments to xfce4-pulseaudio-plugin

The xfce4-pulseaudio-plugin has a hidden "volume-step" property that can be enabled. To do so, you would run a command like:

xfconf-query -c xfce4-panel -p /plugins/plugin-18/volume-step --create -t int -s 15

...where:

  • "plugin-18" is the actual plugin number for the pulseaudio plugin which you can get via:

    xfconf-query -c xfce4-panel -lv | grep pulseaudio

  • "-s 15" is the step size  - change the 15 to whatever step size you want

Check Xfce version

Since Xfce is modular, its various components have their own versioning scheme. Usually the version reported is for xfdesktop. There are a couple of ways to do this.

  • Click Start menu > MX Tools > Quick System Info (command line: inxi -S). You will see in the first stanza an entry called "Desktop" followed by a version number.
  • Install libxfce4ui-utils. Then you will find an entry in the menu called "About Xfce" or get the same information from entering xfce4-about in a console.

Theming Whisker Menu

From the developer Graeme Gott:

Working with the Menu

See this separate Wiki entry

Change icon size in Notification Area

For gtk3 panel plugins, add padding as in following examples to ~/.config/gtk-3.0/gtk.css (create the file if you don't already have it):

For the power manager:
#xfce4-power-manager-plugin { padding: 2px; }

For the pulseaudio plugin:
#pulseaudio-button { padding: 3px; }

For the notifyd plugin:
#xfce4-notification-plugin { padding: 4px; }

Update native xfce4-panel clock after suspend

See this lengthy Forum post.

Disable all Alt + F1-4 combinations

A quick way to make such a global change is to use xfconf-query commands.

These commands will list all the shortcuts for you (second one will list only the custom ones):

xfconf-query -c xfce4-keyboard-shortcuts -l -v
xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom -l -v

And you can reset / remove a specific shortcut with this command (for example Alt+F2):

xfconf-query -c xfce4-keyboard-shortcuts -p '/commands/custom/<Alt>F2' -r -R

Language: 

English