Friday, May 3, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 12675  / 2 Years ago, tue, october 11, 2022, 7:00:57

I am having problems with my .desktop files. I have a shell script that constantly watches for a file to be put into the "Downloads" folder. When a file is put into the folder it automatically executes a C program that I wrote in the terminal, and offers me different options for where I would like to move the file.



All is well there. However, I want a desktop shortcut to the program. I tried using the shortcut editor to specify the command to run, and to excecute it in terminal, and to keep terminal running after the execution of the command. All that is in the command is cd ~/Documents/prog/c/learn/inotify-tools && ./notifyscript.sh



However, that won't work. Also, I tried writing a C program that basically told the system the above command, thinking that the shortcut editor was messing up.



INTERESTINGLY, it runs fine when I am in its directory and type ./'Download Manager'



However, I don't want to keep changing to the directory on every reboot and run the program. Instead, I want a .desktop shortcut or, even better, a way to start on reboot automatically. I don't understand why it isn't working. If I don't execute in terminal it doesn't work...



Here is the Desktop File:



[Desktop Entry]
Name=Download Manager
Comment=
Exec=cd ~/Documents/prog/c/learn/inotify-tools && ./notifyscript.sh
Icon=icon name
Terminal=true
Type=Application
StartupNotify=true
X-KeepTerminal=true


Here is the C Source Code and its Desktop file as well, just as another option:



[Desktop Entry]
Name=Download Manager
Comment=
Exec=./'Download Manager'
Icon=icon name
Terminal=true
Type=Application
StartupNotify=true
X-KeepTerminal=true


C Source Code:



/*
desktoplauncher.c Source Code
Written by me
This program is used to launch
the inotify monitor shell script
which in turn launches the
download manager program
whenever a file is placed in the
"Downloads" folder.
*/

#include <stdio.h>

int main()
{
system("cd ~/Documents/prog/c/learn/inotify-tools && ./notifyscript.sh");
}

More From » command-line

 Answers
5

I got it to work by moving the script to my home folder and editing the desktop configuration file to the following.



[Desktop Entry]
Name=Download Manager
Comment=
Exec=lxterminal --command="./.notifyscript.sh"
Icon=icon name
Terminal=false
Type=Application
StartupNotify=true


This seems really strange, especially because terminal is false... Anyhow it works, so I'm happy! Thanks everyone for your help!


[#23379] Wednesday, October 12, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tigehanc

Total Points: 162
Total Questions: 113
Total Answers: 122

Location: Zambia
Member since Sat, Oct 31, 2020
4 Years ago
tigehanc questions
;