Programatically set .desktop file to trusted - x11

With my application, when user clicks "Create Shortcut on Dekstop" I created a desktop file (location: /home/noi/Desktop/mysc.desktop) I would like to set this to be trusted programtcially (as user clicked create, otherwise they have to go to desktop right click > permissions tab > check "execute").
How can I accomplish this with X11 api? I am using Ubuntu 14 but would like a method that works across linux.
Thanks
Contents of my .desktop file:
[Desktop Entry]
Name=Mozilla Firefox - dev
Type=Application
Comment=Web Application
Exec=/usr/lib/firefox/firefox -P dev -no-remote
Icon=/home/noi/Desktop/test.png

Related

Isabelle/jEdit just starts with ~/Scratch.thy (or does not launch) by clicking .thy file or using open command in MacOS

Recently, I restarted playing with Isabelle/HOL.
However, I faced the following problem in MacOS (Monterey):
When I click foo.thy file, Isabelle/jEdit launches but ignores foo.thy and starts with ~/Scratch.thy. The same happens when I uses open foo.thy from terminal.
(Also, in MacOS Catalina, Isabelle/jEdit cannot be launched by clicking a file (it tries to launch in the sense that the icon hops in Dock, but after some seconds, it stops), though I cannot re-check it since I've already upgraded MacOS.)
How can I open a theory file by clicking the file?
Some additional information (these are under Monterey):
My Isabelle/jEdit is of Isabelle2021-1 from Isabelle's official site.
I checked Isabelle/jEdit can be launched by clicking Isabelle2021-1.app.
After launching Isabelle/jEdit, I can open files from File > Open... in the Menu bar.
I can open foo.thy directly by /Applications/Isabelle2021-1.app/bin/isabelle jedit foo.thy.
When I launch by clicking a file named Chapter01.thy, then the activity log includes
12:06:08 PM [main] [message] jEdit: starting with command line arguments: -settings=/Users/suzuyu/.isabelle/Isabelle2021-1/jedit -server=Isabelle2021-1 -reuseview -nobackground -nosplash -log=9 /Users/suzuyu/Scratch.thy
so, it seems that the file is already ignored at this stage.

How to open a desktop entry as root?

I have a desktop entry placed in usr/share/applications that runs a Java jar and looks something like:
[Desktop Entry]
Encoding=UTF-8
Exec=pkexec /usr/bin/java -jar something-something.jar
Icon=default.png
Type=Application
Terminal=false
Name=foo
GenericName=bar
StartupNotify=false
Categories=Game
I need to run the JAR as root, so I tried using pkexec to have a GUI password prompt appear so I can run the JAR as sudo (I am using Ubuntu 18). However, it would not work and when I tried to open the desktop entry in the terminal (using something like xdg-open) I got: Refusing to render service to dead parents
I believe the problem is with my using pkexec. While I would be interested to know why pkexec does not work for my usage, I would like to know what I can do to run the JAR with sudo from the GUI? That way, when I click on the desktop entry from the menu, a password prompt appears.
Edit:
Actually, I've been using gtk-open and getting the dead parents error. xdg-open results in the desktop entry simply being opened in vim.
pkexec is part of PolicyKit, which allows a finer distribution of rights. To execute programs with graphical user interface using pkexec, you can use the following call:
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/java -jar something-something.jar

Connect from Mac to PC with terminal

how can we do to connect to a PC folder with the Mac Terminal ?
For example with the Terminal I would like to go to:
smb://PCServer01/Folder01/FinalFolder
I think the command you're looking for is open.
open takes an URL argument and can open files, applications, folders, web pages, ...
See man open.

Start local meteor app after windows boot

A local meteor (1.2) application should get started in the background right after windows has been booted. What are my options to get the job done?
You can use the following steps, if you want to start Meteor automatically when a user logs in:
Create a batch file.
Open the newly created batch file and place the following lines into it:
#echo off
cd "<the path to your Meteor project>"
meteor
timeout /t 10
start "C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe" http://localhost:3000
Create a shortcut:
Open the Run window (Win + R).
Open shell:startup (or go to: C:\Users\John Doe\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup).
Copy the shortcut into the folder.
Now, when a user logs in, Meteor should start your project and Microsoft Edge should open http://localhost:3000 after 10 seconds.
Applications cannot run without a user being logged in. So "started in the background right after windows has been booted" is not something that is going to happen. You would need a service for that, and services are not interactive. Assuming that you're talking about the Meteor JS framework, you can't build a service out of that.
If you're talking about starting an application when a user logs in, then you can do that easily by adding a shortcut to the executable to the user's "Startup" folder. On modern versions of Windows, the path would be something like:
C:\Users\UserName\AppData\Local\Microsoft\Windows\Start Menu\Programs\Startup

Is it possible to open a remote mac .app application from a web server?

I'd like to launch a mac application (.app) directly from a web server from a shell script.
I can launch shell scripts directly from the server using curl:
curl -s http://myserver/myscript.sh | sh
I can open a local mac app with open:
open /Applications/Myapp.app
But if I try and open an app directly from the web server using open, it just tries to open my application in a browser window (the default for open):
open http://myserver/myapp.app
Can anyone think of a way (with curl or open or anything else!) that I can open an app remotely without having to first download it locally?

Resources