LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 10-05-2010, 10:22 AM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,531
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Xfce: could not use $( <command> ) in a launcher command


Hello :-)

I would like some programs, started from Xfce launchers, to open full screen. X has a "geometry" option but this allows only X and Y sizes to be specified, not full screen. I wrote a script that outputs the current screen's X x Y with the intention of using it in launcher commands.

Testing at the command line this worked:
Code:
/usr/bin/mrxvt -name c -geometry $(/home/c/d/bin/try/get_current_screen_size.sh) -ic /usr/share/pixmaps/mrxvt.xpm
so I pasted it into a launcher's command and it failed. On inspection it turned out that Xfce had silently removed the $.

I tried editing the /home/c/.config/xfce4/panel/launcher-<unique number>.rc file directly and it still did not work. Perhaps these files are loaded at session initialisation. Will try again after re-initialising the session and update this post.

EDIT: that didn't work. After re-initialising the session (actually a reboot for another reason), Xfce had re-written the /home/c/.config/xfce4/panel/launcher-<unique number>.rc file with the contents of the launcher (as viewed in the launcher's properties).

EDIT 2: logging out of Xfce and using a virtual terminal to edit the /home/c/.config/xfce4/panel/launcher-<unique number>.rc file did result in the $ appearing in the launcher command but it still didn't work -- presumably for the reason identified below by maybeway36 and David the H, that Xfce is not using a shell to process the command.

Best

Charles

Last edited by catkin; 10-05-2010 at 10:42 AM.
 
Old 10-05-2010, 10:30 AM   #2
maybeway36
LQ Newbie
 
Registered: Mar 2009
Posts: 7

Rep: Reputation: 2
$(command) is normally processed by the shell (e.g. bash or dash), so you can't use it in a launcher command. But you can do this:
1. make a shell script with the contents:
Code:
#!/bin/sh
/usr/bin/mrxvt -name c -geometry $(/home/c/d/bin/try/get_current_screen_size.sh) -ic /usr/share/pixmaps/mrxvt.xpm
2. make that script executable with
Code:
chmod +x {file}
3. point the launcher to that shell script instead of to mrxvt.
 
1 members found this post helpful.
Old 10-05-2010, 10:34 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
$() is a shell pattern for embedding commands. Chances are that xfce isn't using a full shell for launching commands, so the embedding syntax is unrecognized.

Wrap your command up inside a shell script and launch that instead.

Edit: beaten to the punch (and made a typing mistake anyway).

Last edited by David the H.; 10-05-2010 at 10:35 AM.
 
1 members found this post helpful.
Old 10-05-2010, 10:46 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,531
Blog Entries: 27

Original Poster
Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Thanks maybeway36 and David the H

That worked. To save having an idle bash process around, I prefaced the command in the script with exec.

I guess Xfce's designers chose to pass the command directly to one of the exec family of syscalls for performance rather than incur the overhead of starting a process running bash on the way.

EDIT:

One gotcha was that a PWD was picked up from somewhere (haven't worked out where) so I added a cd before calling the command.

In case anyone wants to see the script that gets the current geometry, here it is:
Code:
#!/bin/bash

# Configure script environment
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
unalias -a

# Get the current screen geometry
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
buf=$( xrandr --current )
buf=${buf##*current }
buf=${buf%%,*}
geometry=${buf// /}
echo "$geometry"

Last edited by catkin; 10-05-2010 at 10:50 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
gnome launcher won't run a sudo command directly or via a script gnreeke Linux - Desktop 1 06-23-2009 10:44 AM
Slackware, Xfce and command prompt wufo Slackware 15 03-13-2009 12:03 AM
Running a command from a launcher (on gnome desktop) Virtuality Linux - Newbie 1 12-17-2007 08:32 AM
exec command in Launcher? annehoog Linux - Newbie 4 11-23-2006 11:08 AM
launching mozilla with the run command or applicaton launcher allohakdan Linux - Newbie 2 11-19-2003 07:51 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration