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
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

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.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

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

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.008 seconds, 7 queries executed - Memory usage: 524.89 KiB (Peak: 529.82 KiB) ]