Xfce Forum

Sub domains
 

You are not logged in.

#1 2012-04-06 10:37:50

oodavid
Member
From: Newcastle, UK
Registered: 2012-04-06
Posts: 16
Website

[Solved] exo-open in a terminal script - program closes with the terminal

I've written a simple bash script that prompts for a file or directory path and opens it with exo-open, I've then assigned the script to a keyboard shortcut so that I can CTRL+SHIFT+ALT+O to open anything at anytime via a terminal prompt:

969uuc.png

And the script:

#!/bin/bash

# CD to the home folder (not sure if this is needed, no harm either way)
cd ~/

# Request the filepath
echo -e "\e[1;31mEnter a file or directory:\e[00m"
read -e -i "~/" filename

# Convert ~/ to /home/username/
filename=`eval "echo $filename"`
echo -e "opening\e[1;32m" $filename "\e[00m"

# Open the file
exo-open "$filename"

echo "press enter to exit"
read enter

My problem is that the spawned program is linked to the terminal, when the terminal closes it takes the program with it - as a simple workaround I have another user prompt at the end to stop the terminal from closing; does anyone know how I would be able to unlink the fate exo-open from the terminal?

Last edited by oodavid (2012-04-06 11:09:38)

Offline

#2 2012-04-06 12:55:45

ToZ
Moderator
From: Toronto, Canada
Registered: 2011-06-02
Posts: 3,154

Re: [Solved] exo-open in a terminal script - program closes with the terminal

Try setsid (setsid exo-open "$filename"):

#!/bin/bash

# CD to the home folder (not sure if this is needed, no harm either way)
cd ~/

# Request the filepath
echo -e "\e[1;31mEnter a file or directory:\e[00m"
read -e -i "~/" filename

# Convert ~/ to /home/username/
filename=`eval "echo $filename"`
echo -e "opening\e[1;32m" $filename "\e[00m"

# Open the file
setsid exo-open "$filename"

#echo "press enter to exit"
#read enter

...you can also remove the last two lines to have the terminal window close automatically.


How To Ask For Help           Xfce FAQ                            Xfce Release Information
The Xfce Community          Xfce Tips and Tricks

Offline

#3 2012-04-06 13:26:08

oodavid
Member
From: Newcastle, UK
Registered: 2012-04-06
Posts: 16
Website

Re: [Solved] exo-open in a terminal script - program closes with the terminal

ToZ wrote:

Try setsid (setsid exo-open "$filename"):

Sir you are a gentleman and a scholar! Many thanks to you :-)

Offline

Board footer

Powered by FluxBB