Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
0 answers
191 views
"Allow launching" via sudo for .desktop file
I am trying to set "Allow launching" on a newly created .desktop file via a shell script. Please note that the shell script is run by `sudo`. Below is a sample script: #!/bin/bash # Ensure the script is run with sudo if [ "$EUID" -ne 0 ]; then echo "Please run as root or with sudo." exit 1 fi ORIGIN...
I am trying to set "Allow launching" on a newly created .desktop file via a shell script. Please note that the shell script is run by sudo. Below is a sample script: #!/bin/bash # Ensure the script is run with sudo if [ "$EUID" -ne 0 ]; then echo "Please run as root or with sudo." exit 1 fi ORIGINAL_USER="${SUDO_USER}" USER_HOME=$(eval echo ~"$ORIGINAL_USER") DESKTOP_FILE="$USER_HOME/Desktop/test.desktop" # For testing cp /usr/share/applications/firefox.desktop "$DESKTOP_FILE" # for testing chown "$ORIGINAL_USER":"$ORIGINAL_USER" "$DESKTOP_FILE" chmod a+x "$DESKTOP_FILE" sudo -u "$ORIGINAL_USER" -g "$ORIGINAL_USER" dbus-launch gio set "$DESKTOP_FILE" metadata::trusted true I found similar questions, such as 1 , 2 but none of them worked for this case. I also tried desktop-file-install to install on user's dekstop, but it did not work as well. BTW, I am using Ubuntu 20.04 LTS.
ravi (143 rep)
Oct 16, 2024, 03:59 PM
0 votes
1 answers
59 views
why resets `desktop-file-edit` the permissions of a file?
let's say i have set the umask system-wide to 027 via a one-liner at `/etc/profile.d/` on a multiuser-system. after some time resp. reboots i want to hide an existing desktop-file system-wide from the menu with the following commands: ``` # just in case the folder doesn't exist, create it: sudo inst...
let's say i have set the umask system-wide to 027 via a one-liner at /etc/profile.d/ on a multiuser-system. after some time resp. reboots i want to hide an existing desktop-file system-wide from the menu with the following commands:
# just in case the folder doesn't exist, create it:
sudo install -o root -g root -m 755 -p -d '/usr/local/share/applications/'

# copy the existing desktop file and preserve all attributes (which are permissions 644 for the old & new file):
sudo cp -vi --preserve=all '/usr/share/applications/application.desktop' '/usr/local/share/applications/'

# add or change the existing key to true:
sudo desktop-file-edit --set-key=NoDisplay --set-value=true '/usr/local/share/applications/application.desktop'
it kind of works, **but** not as intended: if you open alacarte this desktop-file is still activated but not shown in the menu! with a closer look at /usr/local/share/applications/ the reason can be found... the permissions of application.desktop are 640 instead of 644, so the file would still be shown but it can't be read by the normal user and hence it doesn't show up in the menu *(and therefore the correctly set NoDisplay=true does not really mater in this case)*. i even tried to the add the option -m 644 mentioned at the man page, but it seems to be exclusively for desktop-file-install. 1. is this behavior intended? and if so, why? 2. is there an easy workaround instead of using an appended chmod? 3. why does editing a file, change the permissions of it at all?!?
DJCrashdummy (527 rep)
Oct 2, 2023, 10:07 PM • Last activity: Oct 3, 2023, 09:09 AM
0 votes
0 answers
974 views
how to make desktop file ask for sudo password through gui
I want to run an app that needs sudo to run. I do not want to run it through terminal but through its desktop file or by clicking on a file associated with the program. is there anyway to have it ask for sudo through gui like some system utilities do? I know muon package manager does when you want t...
I want to run an app that needs sudo to run. I do not want to run it through terminal but through its desktop file or by clicking on a file associated with the program. is there anyway to have it ask for sudo through gui like some system utilities do? I know muon package manager does when you want to upgrade in it. additionally I need the sudo timeout to be kept like it is in terminal or for the password to timeout immediately so not to pose a security risk.
stacking and exchanging woohoo (63 rep)
Feb 6, 2023, 08:01 PM
1 votes
1 answers
631 views
How do I keep stdin open when launching an executable via a Desktop Entry File (i.e. .desktop)?
I have a desktop application that relies on stdin. If I run it in the terminal, it runs great and quits when stdin closes (CTRL+D). I also have a systemd activation socket set up which can launch this application. In this case, stdin is connected to the socket and when that socket is closed, the app...
I have a desktop application that relies on stdin. If I run it in the terminal, it runs great and quits when stdin closes (CTRL+D). I also have a systemd activation socket set up which can launch this application. In this case, stdin is connected to the socket and when that socket is closed, the application closes. But when I launch this via /usr/share/applications/*.desktop in gnome, stdin is closed and so the application closes immediately. I see stdin is linked to /proc/12345/fd/0 -> /dev/null. Is there a way to launch an application via the desktop environment so that stdin is open (even if it doesn't have anything writing to it)?
Stewart (15631 rep)
Apr 29, 2021, 02:08 PM • Last activity: Jan 13, 2023, 04:58 AM
2 votes
0 answers
82 views
Pycharm snap folder empty, how to create desktop file
I installed Pycharm community edition by: sudo snap install pycharm-community --classic The IDE has been installed and it's working fine, but now I wanted to create a desktop file in order to add it to the launchbar. The problem is, the snap folder appears to be empty: [![enter image description her...
I installed Pycharm community edition by: sudo snap install pycharm-community --classic The IDE has been installed and it's working fine, but now I wanted to create a desktop file in order to add it to the launchbar. The problem is, the snap folder appears to be empty: enter image description here So I don't know which path I should set when creating the desktop file.
Carlo (121 rep)
Nov 1, 2022, 12:58 PM
2 votes
2 answers
3464 views
.desktop file not executing
I just recently downloaded a game called Starsector and instead of going into the folder every time and running `./starsector.sh`, I want to create a desktop entry. Below is my current `.desktop` file called `starsector.desktop`: ``` [Desktop Entry] Version=1.0 Name=Starsector GenericName=Starsector...
I just recently downloaded a game called Starsector and instead of going into the folder every time and running ./starsector.sh, I want to create a desktop entry. Below is my current .desktop file called starsector.desktop:
[Desktop Entry]
Version=1.0
Name=Starsector
GenericName=Starsector
Exec=sh -c "cd /usr/games/starsector && sudo ./starsector.sh"
Terminal=false
Icon=/usr/games/starsector/graphics/icons/cargo/ai_core_alpha.png
Type=Application
Categories=Game
I have moved this file into ~/.local/share/applications. When copying the Exec line and running it in my shell, it runs the game perfectly fine, but when clicking on the icon it does nothing. ##### Things I have tried I have tried to set Terminal=true \ Run desktop-file-validate; there are no errors present \ Adding exec permissions to the file\ Copying file to the desktop and clicking "Allow launching"\ Running gio set myapp.desktop metadata::trusted yes As of now, the file permissions are -rw-rw-r--. I don't know if this is a file permission problem or simply a problem with the game executable itself somehow. EDIT: ##### More things I have tried Setting Exect=sh -c "cd /usr/game/starsector && sh ./starsector.sh \ Changed owner and group of starsector.sh from root to my own user Changed owner and group of starsector.desktop from my own user to root:root
Caleb Collier (19 rep)
May 14, 2022, 04:58 AM • Last activity: May 14, 2022, 05:16 PM
2 votes
0 answers
599 views
xdg-scheme-handler doesn't open script with same terminal that launching it from a desktop menu does
I'm trying to set a x-scheme-handler URI for my python application. This application is launched via a shell script in `/usr/bin`. I've had a desktop file for a while, and it's worked fine, opening the program in the KDE terminal, Konsole. I just added the `MimeType=x-scheme-handler/iicalc;` to the...
I'm trying to set a x-scheme-handler URI for my python application. This application is launched via a shell script in /usr/bin. I've had a desktop file for a while, and it's worked fine, opening the program in the KDE terminal, Konsole. I just added the MimeType=x-scheme-handler/iicalc; to the desktop entry, and did xdg-mime default iicalc.desktop x-scheme-handler/iicalc, and the custom URI works, it runs the correct script. The problem is the it doesn't open in Konsole, like launching it from the application menu would. Instead, it opens in xterm, which also happens to be what my $TERM variable is set to. How can I make this behave in the same way launching it from the application menu would, while also working cross-platform? Here's my current desktop file:
[Desktop Entry]
Version=2.3
Type=Application
Name=ImaginaryInfinity Calculator
Comment=Expandable calculator
Exec=iicalc %u
Terminal=true
Icon=/usr/share/icons/iicalc.tiff
Categories=Education;Office;Utilities;Math;
Keywords=calculator;math;
MimeType=x-scheme-handler/iicalc;
Tabulate (121 rep)
Dec 12, 2020, 01:57 AM
2 votes
2 answers
4930 views
How to set environment variable in KDE desktop file
I need to set `GDK_BACKEND=x11` prior to launching Eclipse, because of [https://bugs.kde.org/show_bug.cgi?id=389495][1]. I tried the following in the .desktop file: Exec=GDK_BACKEND=x11 /home/glodt/Software/eclipse-4.7/eclipse Exec=env GDK_BACKEND=x11 /home/glodt/Software/eclipse-4.7/eclipse Exec=ex...
I need to set GDK_BACKEND=x11 prior to launching Eclipse, because of https://bugs.kde.org/show_bug.cgi?id=389495 . I tried the following in the .desktop file: Exec=GDK_BACKEND=x11 /home/glodt/Software/eclipse-4.7/eclipse Exec=env GDK_BACKEND=x11 /home/glodt/Software/eclipse-4.7/eclipse Exec=export GDK_BACKEND=x11; /home/glodt/Software/eclipse-4.7/eclipse but none of them yield the expected result. When I launch Eclipse from the command-line like this it works: GDK_BACKEND=x11 /home/glodt/Software/eclipse-4.7/eclipse How can I set this environment variable in the desktop file ?
yglodt (283 rep)
Feb 26, 2018, 07:31 AM • Last activity: Sep 7, 2020, 11:02 PM
0 votes
1 answers
2833 views
Launch BASH script by clicking icon and preserve terminal icon
My problem is pretty simple, but I must admit, I don't know any elegant solution. I have a problem, that I often accidentally click different icon that I wanted. It's really very unpleasant, so I've decided to write a bash script, which will ask me if I really want to launch the program ( especially...
My problem is pretty simple, but I must admit, I don't know any elegant solution. I have a problem, that I often accidentally click different icon that I wanted. It's really very unpleasant, so I've decided to write a bash script, which will ask me if I really want to launch the program ( especially Eclipse, because it's pretty large and so it takes lots of time to load ). I had written it, then added its location to the __eclipse.desktop__ file... And now there's my problem. The Eclipse launcher works, but if I launch only Terminal, Eclipse icon shows up instead of original Terminal's. Do you know how could I solve this, if I wanted to keep my bash script working? ___ Here is my bash script __eclipseLaunch.sh__: #!/bin/bash echo "Do you really want to launch Eclipse? (yes = y)" read answer if [[ "$answer" = "y" ]]; then ~/.eclipse/eclipse fi And here is my __eclipse.desktop__ file: [Desktop Entry] Type=Application Encoding=UTF-8 Name=Eclipse Exec=gnome-terminal -e "bash -c \"~/.eclipse/eclipseLaunch.sh; exec bash\"" Icon=/home/martin/.eclipse/icon.xpm Terminal=false
Eenoku (1245 rep)
Nov 1, 2014, 12:06 AM • Last activity: Nov 3, 2014, 03:28 PM
1 votes
0 answers
2081 views
Programmatically creating .desktop file to autostart application
Using a Java program, I added a `.desktop` file in `/etc/xdg/autostart` to run a script when a user logs in. The script didn't run at user login, and when I checked the start up applications dialog manually, it wasn't added to it. The file I added is `/etc/xdg/autostart/Startup.desktop`, and the scr...
Using a Java program, I added a .desktop file in /etc/xdg/autostart to run a script when a user logs in. The script didn't run at user login, and when I checked the start up applications dialog manually, it wasn't added to it. The file I added is /etc/xdg/autostart/Startup.desktop, and the script I want to be run on user login is /usr/bin/Startscript. The code I wrote to add the desktop file is as follows: private void writeDesktopFile() { File f = new File("/etc/xdg/autostart/Startup.desktop"); if (!(f.exists())) { try { f.createNewFile(); BufferedWriter bw = new BufferedWriter(new FileWriter(f, true)); bw.write("[Desktop Entry]"); bw.newLine(); bw.append("Name=Startup"); bw.newLine(); bw.append("Exec=Startscript"); bw.newLine(); bw.append("Type=Application"); bw.newLine(); bw.append("Terminal=false"); bw.newLine(); bw.append("Categories=GNOME;GTK;Utility;"); bw.newLine(); bw.append("X-Ubuntu-Gettext-Domain=Startscript"); bw.newLine(); bw.flush(); bw.close(); Runtime.getRuntime().exec("chmod +x /usr/bin/Startscript"); } catch (IOException ex) { Logger.getLogger(LinuxStartup.class.getName()) .log(Level.SEVERE, null, ex); } } Why isn't my script being run on start up?
Joker (161 rep)
Jul 1, 2014, 04:32 AM • Last activity: Jul 1, 2014, 12:41 PM
Showing page 1 of 10 total questions