How can I use a "while" loop in a desktop entry to run a bash command without having to create a ".sh" file?


those cars 82

If I copy and paste the following command into the terminal it works as expected:

    uxterm -e "bash -c 'while :
do
    xdotool getmouselocation;   sleep 0.3
done'"

The following desktop entries also work as expected:

[Desktop Entry]
Version=1.0
Name=getLocation_v1      
Comment=Test the terminal running a command inside
Exec=uxterm -e "bash -c 'xdotool getmouselocation;sleep 0.3;$SHELL'"
Icon=utilities-terminal
Terminal=false
Type=Application
Categories=Application;

But for some reason the following desktop entry doesn't work:

[Desktop Entry]
Version=1.0
Name=getLocation
Comment=Test the terminal running a command inside
Exec=uxterm -e "bash -c 'while :
do
    xdotool getmouselocation;   sleep 0.3
done'"
Icon=utilities-terminal
Terminal=false
Type=Application
Categories=Application;

Does anyone know how I can fix this desktop entry so it works without creating an extra ".sh" file?

Thanks in advance!

vanadium

try

uxterm -e "bash -c 'while : ; do xdotool getmouselocation ;   sleep 0.3 ; done'"

The secret is to replace newlines with ;command separators .

Related


How can I run a shell script without using the "sh" command?

Shuma I have a sh file that executes a php file. I am trying to run it without the sh command. I want to run it using the command test.sh instead of "sh test.sh". How do I do this? rot Add a hashbang as the first line of the script: #!/bin/sh Then make it exe

How can I run a shell script without using the "sh" command?

Shuma I have a sh file that executes a php file. I am trying to run it without the sh command. I want to run it using the command test.sh instead of "sh test.sh". How do I do this? rot Add a hashbang as the first line of the script: #!/bin/sh Then make it exe

How can I run a batch file without launching a "command window"?

Srujana Enduri I don't want to open a command window when running the application, but direct the shortcut to the .bat file when creating the application's python based .exe file The code in the .bat file is like this @python\python.exe -m demo.demo %* where d

How can I run a batch file without launching a "command window"?

Srujana Enduri I don't want to open a command window when running the application, but direct the shortcut to the .bat file when creating the application's python based .exe file The code in the .bat file is like this @python\python.exe -m demo.demo %* where d

How can I use the output of a command in a for loop in bash?

bob I am trying to use this output in a for loop: $wc -l example.mgn | awk '{print $1}' 12 However, I get this: for i in {1..`wc -l example.mgn | awk '{print $1}'`}; do echo $i; done {1..12} Chepner Bracket expansion happens before any other type of expansio

How can I use the output of a command in a for loop in bash?

bob I am trying to use this output in a for loop: $wc -l example.mgn | awk '{print $1}' 12 However, I get this: for i in {1..`wc -l example.mgn | awk '{print $1}'`}; do echo $i; done {1..12} Chepner Bracket expansion happens before any other type of expansio

Bash: I can't run eval command inside twice while loop

Jared Weinstein My goal is to have a program that loops through two files and evaluates a single shell script with all line combinations from file 1 and file 2. I verified that my evaluation line worked by moving it out of the while loop. #!/bin/bash while rea

Bash: I can't run eval command inside twice while loop

Jared Weinstein My goal is to have a program that loops through two files and evaluates a single shell script using all combinations of lines from file1 and file2. I verified that my evaluation line worked by moving it out of the while loop. #!/bin/bash while

How do I create a desktop entry for a .jar file?

Ivan I created a desktop entry and moved it to ~/.local/share/applications, but it doesn't execute when I click on it from the start menu. Here is my .desktopfile: [Desktop Entry] Type=Application Categories=Game Name=Minecraft Icon=/home/user/Games/Minecraft/

How can I run the while loop here?

Rampage 01 ok, here is my code, everything works fine except the while loop. The purpose of this program is to enter a number "40235", then divide it by 10, take the remainder (5), subtract it from the main number, and divide by 10 again to get its perfect quo

How can I run sh without reading ~/.profile?

it bashFor example, with , a flag can be passed --norc --noprofileto prevent reading the shell initialization file. What is the equivalent sh? If not sh, is there at least one dash? (I've tried hacks based on not being set up HOMEyet, but they seem too fragile