Customizing Xfce and Thunar

Introduction

    The whole point of using computers is supposed to be to make our lives more efficient, easier, and more productive.  While I am a very big advocate of linux users learning their way around a terminal or shell, and learning commands, there is a point at which you want to make life easier for yourself.  That is the point if this page: here are some ways to make your life easier using Xfce .desktop files and Thunar custom commands.  Enjoy!

Setting Hotkeys

    This section is for anyone whose HotKeys don't work by default.  If your "hotkeys", "multimedia keys", "function keys", etc, do not work for audio control, here's a way to add the keys to Xfce's keyboard shortcuts.  Go to Xfce Keyboard Section under the Application Shortcuts section.  When you add a key, here are some handy commands that will give you control over your sound.  All these commands assume you want to control the Master slider on the first sound card.

xfce keyboard
        application shortcuts picture

# This raises the volume a bit
amixer -c 0 sset Master 2dB+
# This lowers it a bit
amixer -c 0 sset Master 2dB-
# This mutes/unmutes (toggles) it
amixer -c 0 sset Master toggle

Adding Custom Commands to Thunar

    I wrote this to give some examples of some Thunar custom commands that I have found useful.  Thunar is the file manager program / desktop manager program for the Xfce desktop.

Convert PostScript Files into Adobe Acrobat Files


    Here's a script you can add that you can right-click a PostScript file, which usually end in .ps, like from printing to file from within Firefox:

ps2pdf13 %n && rm %n

    This uses the && to make sure that it does not remove the old PostScript file unless the command to convert to an Adobe Acrobat file was successful.  If you do not want it to remove the old PostScript file after conversion, remove the && and everything after it.

Compress Files in BZip Format


    Here's a script that will compress all files you've selected in Thunar, which appends the .bz2 extension to them:

bzip2 %N

    The command automatically moves the old file to the new file during the process.  If you do not want that, add the -k option to the command before %N, which tells BZip2 to keep the input file(s).  Note: the concensus is that BZip2 does a better job with text files, while GZip is better for binaries.

Compress Files in GZip Format


    Here's a script that will compress all files you've selected in Thunar, appending the .gz extension to them:

gzip %N

    I do not think there is an option to keep the old (input) file: all get converted to GZip.

Convert WAV files to FLAC files


    Here's a script for possibly saving some space for us audiophiles: convert your files from WAV format to FLAC format  using this command:

flac --best %N && rm %N


    This should give you a nice FLAC file and delete the old WAV file.  Once again, be sure to remove && and everything afterwards if you don't want it removing the old (input) file.

Convert FLAC files to MP3

       I wrote my own script for this, found here, for ripping FLAC to MP3.  I prefer to have them put the output file (i.e. the MP3) in Desktop/Outgoing folder so I can drag and drop into audio players.

~/flac2mp3.sh %N

Creating tarballs from directories

    These commands don't often get used, but they're handy to have around in case you want to do work.  Remember, the goal of all this stuff is to make work faster and more efficient.  Anyways, here's the command:

terminal -x tar -cvvzf %f.tar.gz %f

    This should give you (per directory) a nice .tar.gz file.  You can change the format as you wish, possibly to make the file extension .tgz, etc.

Encrypt A File "On The Fly" To A Password

    Here's a script that I wrote.  Inside ~/encrypt.sh, put the following:

gpg --bzip2-compress-level 9 -c --cipher-algo AES -i $1

    Now you can build a command in Thunar that runs

terminal -x ~/encrypt.sh %f

    Which causes it to run that script but in a Terminal so you can enter the password to encrypt the file to.  If you have KDE installed, usually Thunar already understands that double-clicking a .gpg file (i.e. an encrypted file) means you need to run the kgpg program.  So decrypting files in Thunar already works by default.  Just enter the password you used and it's decrypted.

Judging If A Command Is Done

    You may have trouble with some of these, since they run the command without you seeing the progress or the command itself run.  For any of these, simple put "terminal --execute " in front of the command and it will open a terminal to run the command, which should close automatically when the command is complete.  Also, in addition, the gzip command, the bzip2 command, and several others have the ability to go into "verbose" mode, where they give more text output as to what they are doing.  To get this, add the "-v" switch to them.  Be sure you read the documentation on the commands before just blindly adding "-v" to commands.

Xfce Desktop Launchers

    A fairly recent feature on the Xfce desktop is Desktop management: now the Desktop isn't just for looks, but it has funtionality too!  Here's how to add launchers to your desktop:

.desktop Files

    These are files that end in .desktop located on your Desktop.  They contain the following text:

[Desktop Entry]
Exec=xchat
Icon=xchat
Name=XChat
Type=Application


    The first part tells Xfce that this is a Desktop Entry.  The second part tells Xfce what command to run.  In this example you see that this is for XChat.  Third, you see the name of the icon.  While this seems the same, it is not always the same.  You should check in /usr/share/pixmaps and /usr/share/icons for what icons are available for this application.  For example, for the SeaMonkey program, the icon name is actually seamonkey-icon.  Fourth is the name of the program.  This is what you will see as the desktop icon's name.  Last, the type of launcher this is; in this case, it's a launcher for an application.

Desktop Entry Specification

    For more information about these launchers, see the Free Desktop: Desktop Entry Specification website.  There are several more things you can do with these files, so I'll leave this part up to you.

Thunar New Document Templates

    If you want to see items populate in the Create From Template dialog, for convenience, this is really easy.  Just open the application you want a template document from, and save this document (a blank one) to the Templates directory under your home directory (create the directory if it does not exist).  Then save the blank documents as the name that will appear when you right click to create new (example: save an Open Office Text Document as ~/Templates/Open Office Text Document.odt and it will appear as Create From Template > Open Office Text Document).  Enjoy!

Summary

    If you set everything up really nice, your desktop can look like this (click for full size):

XFCE Thunar
   



Valid HTML 4.01 Strict