LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Xfce: could not use $( <command> ) in a launcher command (https://www.linuxquestions.org/questions/linux-desktop-74/xfce-could-not-use-%24-command-in-a-launcher-command-836329/)

catkin 10-05-2010 10:22 AM

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

maybeway36 10-05-2010 10:30 AM

$(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.

David the H. 10-05-2010 10:34 AM

$() 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).

catkin 10-05-2010 10:46 AM

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"



All times are GMT -5. The time now is 11:37 AM.