Search code examples
xfcethunar

add View menu to thunar context menu


How can I add the View menu to right click in Thunar? I would like to be able to right click an empty area in the Thunar window to at least select between icon, compact list, or details list if not access the rest of the View menu. In reference to documentation at https://docs.xfce.org/xfce/thunar/custom-actions what custom action can I program to change the Thunar view of the current folder? I'm working in Linux Mint, XFCE4 desktop environment using Thunar 1.6.15.


Solution

  • One way to do this is by using xdotool to emit the keyboard shortcut for the different views and tying it to a Thunar custom action. To do so, you will need to create 3 custom actions:

    • Icon View
    • Detailed List item
    • Compact List View

    For each of these, make sure you select the "Directories" box on the custom action's Appearance Conditions tab. On the Basic tab, enter the name, description and select an icon for each action and use the following as the command for each action:

    • Icon View = xdotool key Ctrl+1
    • Detailed List View = xdotool key Ctrl+2
    • Compact List View = xdotool key Ctrl+3

    This will create 3 new custom actions - one for each view. The drawback is that you will have 3 menu entries.

    You can get away with 1 custom action (and 1 menu entry) if you are okay with cycling through the 3 options. To do so, create an executable file with the following content:

    #!/bin/bash
    
    case $(xfconf-query -c thunar -p /last-view) in
        ThunarIconView) xdotool key Ctrl+2 ;;
        ThunarDetailsView) xdotool key Ctrl+3 ;;
        ThunarCompactView) xdotool key Ctrl+1 ;;
    esac
    

    Create one new Custom Action with the title of "Cycle View" (and a description and icon of your choice) and set the command to point to this script. Also ensure that on the Appearance Conditions tab, that Directories are checked.

    This script will cycle between Icon, Detailed and Compact view every time the custom action is selected.

    There is no easy way to display the View menu from the right click. You could use the same procedure as above to send the keyboard shortcut for the view menu, but it will only open directly below the view menu on the menubar - in which case you might as well just click on View and save yourself one click.

    Hope this helps.