LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 01-27-2017, 12:07 AM   #1
dannybpng
Member
 
Registered: Sep 2003
Location: USA
Distribution: Fedora 35
Posts: 79

Rep: Reputation: 22
KDE .desktop Exec key does not work with command line options


I have spend a day or so trying to get .desktop files to let me pass command line parameters (i.e. -x) to bash scripts that I'm executing via the Exec key.

I wanted to set up a drag-and-drop type system to let non-command-line users run my tools from Dolphin by dragging and dropping files or directories onto .desktop files created to run the scripts.

This string works. A terminal window comes up and shows the progress.
Quote:
Exec=slgsync /home/distributions/SaveLongGod %f
This does not. No terminal window comes up. A button shows on the panel for several seconds and then goes away. The -x is a valid parameter for my script.
Quote:
Exec=slgsync -x /home/distributions/SaveLongGod %f
No matter what Linux command line program I specify, it runs without a command line parameter and if I add a valid parameter it fails.

I think it's a bug in my configuration as other examples on the web show commands with parameters, but they don't work with my setup.

Fedora 23
KDE Plasma: 5.7.5
KDE Frameworks: 5.27.0
Dolphin: 15.12.3

I know Fedora 23 is EOL, but having a very expensive internet service has not let me upgrade yet. I'm working on it.
 
Old 01-27-2017, 12:43 AM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
most of the time i place a tiny shell script to launch the program in the folder with that program
then in the .desktop file i point to the script

an example for the HP 11c rom calculator i use
http://nonpareil.brouhaha.com/
the *.desktop file
Code:
[Desktop Entry]
Categories=Utility;Calculator;
Encoding=UTF-8
Exec=/DATA/nonpareil/bin/HP11c.sh
GenericName[en_US]=HP-Calculator
GenericName=HP-Calculator
Icon=/DATA/nonpareil/bin/11c.png
MimeType=
Name[en_US]=HP-11c
Name=HP-11c
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=
this points to "/DATA/nonpareil/bin/HP11c.sh"
Code:
#!/bin/sh
/DATA/nonpareil/bin/nonpareil 11c.kml
as to what you want ?
i do not think a "*.desktop" file will act a a linked FOLDER

Last edited by John VV; 01-27-2017 at 12:47 AM.
 
Old 01-27-2017, 01:36 AM   #3
Brains
Senior Member
 
Registered: Apr 2009
Distribution: All OS except Apple
Posts: 1,591

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Code:
[Desktop Entry]
Categories=Application;Multimedia;
Comment[en_CA]=Link to VLC
Comment=Link to VLC
Encoding=UTF-8
Exec=/usr/bin/vlc
Icon=
GenericName[en_CA]=Music player
GenericName=Music player
MimeType=
Name[en_CA]=Music player
Name=Music player
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
Version=1.0
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=
I've never tried this before, but when I dropped an mp3 on the .desktop above, VLC popped up and played it.
Maybe I'm off here, but the slgsync -x part should be in the script the .desktop runs. The EXEC= should only point to the script, not pass arguments.

Also, users generally cannot run scrips with root commands on my Debian, I originally did like John and had the .desktop launch a script that would launch another script as sudo with both scripts added to /etc/sudoers file. But then I managed to get rid of one of the scripts by adding sudo to the EXEC= section of the .desktop file. Below are the examples:
Code:
[Desktop Entry]
Categories=Application;Network;
Comment[en_CA]=Connect to Internet
Comment=Connect to Internet
Encoding=UTF-8
Exec=sudo /home/jo/Desktop/net.sh
Icon=
GenericName[en_CA]=Wifi UP
GenericName=Wifi UP
MimeType=
Name[en_CA]=Wifi UP
Name=Wifi UP
Path=
StartupNotify=true
Terminal=true
TerminalOptions=
Type=Application
Version=1.0
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=
/etc/sudoers entry:
Code:
# User privilege specification
root	ALL=(ALL:ALL) ALL
jo	ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo	ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
jo  ALL=(ALL:ALL) NOPASSWD:/home/jo/Desktop/net.sh
I had the net.sh script that would bring up the wifi connection in my /home/jo/Desktop folder with the .desktop file.

Last edited by Brains; 01-27-2017 at 01:51 AM.
 
Old 01-27-2017, 01:48 AM   #4
Brains
Senior Member
 
Registered: Apr 2009
Distribution: All OS except Apple
Posts: 1,591

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Maybe try adding slgsync -x to the TerminalOptions= value of the .desktop
 
1 members found this post helpful.
Old 01-27-2017, 01:50 AM   #5
dannybpng
Member
 
Registered: Sep 2003
Location: USA
Distribution: Fedora 35
Posts: 79

Original Poster
Rep: Reputation: 22
I don't fully understand what you are presenting and how that would help with my situation. I was hoping for a simple menu system. Have a bunch of .desktop files each representing the available actions. Each .desktop file would provide different command line arguments passed to a program depending on the desired action to perform. I'd like all the files in one folder so that the user can see the list of possible actions as a list of files in one pane via Dolphin and drag files from another pane onto the desired action.

Quote:
Synchronize to Drive.desktop
Synchronize to FTP.desktop
Update web pages.desktop
It seemed like a very simple way of creating a system where they could drop folders or files or run them directly by clicking on them and default values could be used.
 
Old 01-27-2017, 02:09 AM   #6
Brains
Senior Member
 
Registered: Apr 2009
Distribution: All OS except Apple
Posts: 1,591

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
In the .desktop examples John and I posted, there is a value called: TerminalOptions=
Try putting the -x there.

EDIT: And pardon me for including extra information that may come in handy for others stumbling upon this thread in the future trying to get their .desktop working.

Last edited by Brains; 01-27-2017 at 02:21 AM.
 
Old 01-27-2017, 05:31 PM   #7
dannybpng
Member
 
Registered: Sep 2003
Location: USA
Distribution: Fedora 35
Posts: 79

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by Brains View Post
In the .desktop examples John and I posted, there is a value called: TerminalOptions=
Try putting the -x there.

EDIT: And pardon me for including extra information that may come in handy for others stumbling upon this thread in the future trying to get their .desktop working.
----
Thanks. I'll try this when I get back to the office.
 
Old 01-29-2017, 05:07 PM   #8
dannybpng
Member
 
Registered: Sep 2003
Location: USA
Distribution: Fedora 35
Posts: 79

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by John VV View Post
most of the time i place a tiny shell script to launch the program in the folder with that program
then in the .desktop file i point to the script
...
It looks like I will have to try something like this. My frustration about the Exec command line arguments is that I have seen them in other examples on Ubuntu systems with "-s" options in them, but that doesn't work on my Fedora KDE system.
 
Old 01-29-2017, 05:11 PM   #9
dannybpng
Member
 
Registered: Sep 2003
Location: USA
Distribution: Fedora 35
Posts: 79

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by Brains View Post
In the .desktop examples John and I posted, there is a value called: TerminalOptions=
Try putting the -x there.

EDIT: And pardon me for including extra information that may come in handy for others stumbling upon this thread in the future trying to get their .desktop working.
This only send arguments to the terminal emulation program not my program and in the latest specs is deprecated.
 
Old 02-06-2017, 07:13 PM   #10
dannybpng
Member
 
Registered: Sep 2003
Location: USA
Distribution: Fedora 35
Posts: 79

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by dannybpng View Post
It looks like I will have to try something like this. My frustration about the Exec command line arguments is that I have seen them in other examples on Ubuntu systems with "-s" options in them, but that doesn't work on my Fedora KDE system.
I have implemented a version of my system using an intermediary script (as suggested) that passes the needed command line arguments to the main scripts, but it is adding more unnecessary levels of complication. I would mark this as solved, but I'm still wondering why Dolphin (or whatever level is interpreting the .desktop files) is not following the specs. Does someone know where I could post to see if this has been changed in newer Fedoras (after 23) or find out other options to get an updated version of Dolphin?
 
  


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
[SOLVED] Field codes in desktop file Exec key montagdude Slackware 8 12-14-2016 10:47 AM
How command line options work after switching the user in script? visu_kvg Linux - General 7 02-21-2013 03:48 PM
help with find command (specifically the -o and -exec options) Bez Vozvrata Linux - General 3 06-06-2010 03:46 PM
Cmd Line Command for KDE Refresh Desktop? mac57 SUSE / openSUSE 5 01-03-2010 12:09 AM
launch ssh or other command line app from desktop shortcut kde pauledwards03 Linux - Newbie 5 09-04-2008 03:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 01:47 PM.

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