Xfce Forum

Sub domains
 

You are not logged in.

#1 2018-04-17 08:40:06

fabrice.regnier
Member
Registered: 2018-04-17
Posts: 2

open thunar with multiple tabs in command line

Hi all,

When i type "thunar directory1 directory2", it opens 2 thunar windows. I'd like to open only one thunar windows with 2 tabs in it, one tab for directory1 and the other tab for directory2. Is there a way to do this ?

I've used xdotool to open a new tab in thunar but no way to force this new tab to be directory2:

thunar directory1; xdotool key ctrl+t;

have a good day and thank you wink

f.

Offline

#2 2018-04-17 10:07:49

Jerry3904
Member
Registered: 2013-11-09
Posts: 850

Re: open thunar with multiple tabs in command line

I asked this on the Forum month ago, then wrote the Devs about it. Answer: there is no way, but they would be happy for us to work on a patch they could look at.

I'm glad to see that I'm not the only one who thinks that would be a good idea!

Last edited by Jerry3904 (2018-04-17 10:08:21)


MX-23 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

#3 2018-04-17 10:16:42

fabrice.regnier
Member
Registered: 2018-04-17
Posts: 2

Re: open thunar with multiple tabs in command line

Thank you for answering. It's a pity i'm not a C dev.

regards,

f.

Offline

#4 2018-04-17 14:08:07

Misko_2083
Member
Registered: 2015-10-13
Posts: 191
Website

Re: open thunar with multiple tabs in command line

This script on LM forums https://forums.linuxmint.com/viewtopic.php?t=244076 opens new tabs in thunar when open all is selected on desktop.

The script requires: xdotool gridsite-clients contains urlencode

Changed it for directories: save it somewhere as thunartab and make it executable. Note that it will open new tabs in a thunar that is already open. If it's not open it will launch thunar with a dir1 and dir2 in a new tabs.

#!/bin/bash
# Script to open new file manager tab instead of window (e.g., Thunar) in XFCE. 
# Version 1. 2017-04-18

# Lock script to process multiple instances consecutively when "Open All" on Desktop. 
if [[ -d "${1}" ]]; then
	ME=`basename "$0"`;
	LCK="/tmp/${ME}.LCK";
	exec 8>$LCK;
	flock -x 8;  # lock $LCK
	trap 'rm -f $LCK' exit # remove $LCK regardless of exit status
	sleep .1 # hack to give time for each script to execute properly--weird!
fi

# Convert desktop file urls to thunar-friendly local paths. 
# Accommodates special characters in directory names (!@#$, etc).
fileurl="${1}"
filepath="$(urlencode -d ${fileurl%/})/"

# Check for running instances of $app on current desktop/workspace.
app=thunar
wid=( $(xdotool search --desktop $(xdotool get_desktop) --class $app) ) 
lastwid=${wid[*]: -1} # Get PID of newest active thunar window.

# If $wid is null launch app with filepath.
if [ -z $wid ]; then
	$app "$filepath"
        
# If app is already running, activate it and use shortcuts to paste filepath into path bar.
else  
	xdotool windowactivate --sync $lastwid key ctrl+t ctrl+l # Activate pathbar in thunar 
	xdotool type -delay 0 "$filepath" # "--delay 0" removes default 12ms between each keystroke
	xdotool key Return
fi
exit 0


# Easy Installation: 
# cd ~/Downloads && tar -zxvf thunartab.tar.gz && sudo chmod 755 thunartab && sudo cp thunartab /usr/local/bin/
# Install dependencies: sudo apt install gridsite-clients xdotool # gridsite-clients contains urlencode 
# Reboot # if you want to run "thunartab" as a command in terminal
# Select script in the XFCE's GUI "Preferred Applications"
#
# For alternatives for script location run "echo $PATH" (without quotes) in terminal
# Troubleshooting: If more than one thunar window opens with "Open All", try increasing sleep value on line 12
# 
# For other file-managers (e.g., Nemo, Caja, Nautilus), change app name on line 21 
# You may also have to modified  the xdotool shortcuts on line 31.
# For example for Nemo, change line 31 to something like
# xdotool windowactivate --sync $lastwid key ctrl+t ctrl+l ctrl+v Return ctrl+l Escape
# Manually test shortcuts in file manager first. 
# 
# Main sources for learning bash for this script include: 
# http://ryanstutorials.net/bash-scripting-tutorial/ "Bash Scripting Tutorial" (Very good for beginners like myself"
# http://jdimpson.livejournal.com/5685.html "Using flock to protect critical sections in shell scripts"
# https://askubuntu.com/questions/55656/open-nautilus-as-new-tab-in-existing-window (the starting idea for this script)
#
# Bug reports or suggestions, please email me, Sam, at sampub@islandroots.ca

Now we need a wrapper which will pass on the arguments to the script
Save next script, change path to thunartab, and make executable (chmod +x)

#!/bin/bash
#wrapper for thunartab
for dir in "${@}"; do
  /path/to/thunartab "$dir"
done

Now run the script:
for example

/home/misko/Desktop/tabwrapper 'dir1' 'dir2'

Last edited by Misko_2083 (2018-04-17 14:10:15)


Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c

Offline

#5 2018-04-17 20:35:55

Jerry3904
Member
Registered: 2013-11-09
Posts: 850

Re: open thunar with multiple tabs in command line

Good workaround, thanks for posting.


MX-23 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

Board footer

Powered by FluxBB