LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-04-2004, 06:16 AM   #1
Galik
Member
 
Registered: Mar 2003
Location: UK
Distribution: gentoo
Posts: 67

Rep: Reputation: 15
XFCE 2 state launcher conundrum


Hi.
I wondered if anyone out there knew how to use the 2 state launcher in XFCE. Basically I want to create a launcher that mounts/unmounts my usb drive. Not I guess I need to write a script to do the mounting/unmounting but I'm confused as to how the script should work. How does the launcher determine whether to display the on or off icon? Does my script need to return a particular value for that? How does my script differentiate between a click on the launcher from the mouse from the launcher just polling the script to detect the state of the icon (on or off). Or is it all something else entirely?

It would be really good to get my usb drive mounting/unmounting and reflecting it's state so any help would be appreciated.
 
Old 08-04-2004, 09:03 AM   #2
Galik
Member
 
Registered: Mar 2003
Location: UK
Distribution: gentoo
Posts: 67

Original Poster
Rep: Reputation: 15
Okay after a bit of dipping into the source code and some experimentation I have a working script
I'll post it here for future googlers to find

Basically when you click on the launcher in xfce's panel the script is called with either a "1" or a "0" added as a parameter. When the launcher is just querying the script no parameters are added and the output of the script is collected (it needs to be a "1" or a "0".

So here's the basic script...

Code:
#!/bin/sh

# mount
#  0 -> success
# 32 -> failed to mount

mpoint="/mnt/usb"
action=${1}

if [ $# -gt 0 ]; then


	if [ ${action} = "1" ]; then

		mount ${mpoint} > /dev/null
		err=$?
	
		if [ ${err} -eq 0 ]; then

			#echo "success"
			echo "1" > ~/.usbmount

		fi


	else

		umount ${mpoint} > /dev/null
		err=$?
	
		if [ ${err} -eq 0 ]; then

			#echo "success"
			echo "0" > ~/.usbmount

		fi
	fi

else

	cat ~/.usbmount

fi
This can definately be improved upon. Don't hesitate to post it here if ou do

Last edited by Galik; 08-04-2004 at 09:06 AM.
 
Old 08-04-2004, 08:12 PM   #3
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Well Done.
This script works very well.

--Ian
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Xfce problems with task bar and xfce-panel aeruzcar Linux - Software 4 06-26-2006 05:29 AM
Creating a launcher (could be java launcher) The_Messiah Linux - Newbie 12 04-06-2005 01:36 AM
poweroff reboot launcher for xfce w/ KDM? r_jensen11 Linux - Software 2 01-17-2004 04:00 PM
XFCE and kde/gnome apps (launcher menu question) JimDog Linux - Newbie 2 10-11-2003 07:43 AM
Quite the conundrum...... Randall Linux - Newbie 10 11-09-2001 05:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration