maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   How to make a launcher for a shell script (https://talk.maemo.org/showthread.php?t=101329)

nonsuch 2022-05-01 10:15

How to make a launcher for a shell script
 
Disclaimer: I posted this yesterday on SFOS forums but it got hijacked.

It’s easy to add a custom launcher to your app menu, just drop a <something>.desktop file in ~/.local/share/applications that might look like this:

Code:

[Desktop Entry]
Type=Application
Name=Un/mount Server
Exec=/home/nemo/.local/bin/server-sshfs
Icon=/home/nemo/.local/share/icons/sshfs.png

This works as desired, but I’m getting a cover tile with a spinner (created by the lipstick launcher I presume) that does not disappear after the script has completed, it just times out after 10-20s.

How can I avoid that?

I don't really need a cover tile at all. The script sends notifications, that's enough.

I tried from within the .desktop file - all those commented options:

Code:

#X-Nemo-Application-Type=generic
#Custom-Launcher=yes
#X-Nemo-Single-Instance=no
#"StartupNotify=false

#[X-Sailjail]
#Sandboxing=Disabled

None made any difference.

Maybe there’s some command I can add to the shell script just before it exits?

I have been looking around existing projects and installed apps' .desktop files, but nothing seems to adress the situation.

ric9K 2022-05-01 13:01

Re: How to make a launcher for a shell script
 
I have no idea and wonder if there's even a way or if it is part of silica behaviour.
Even for app's covers, there doesn't seem to be delay/timeout properties. I fell on this looking for "cover" timeout or delay:
https://sailfishos.org/develop/docs/...he-home-screen

Hijacked?
It is not against your question. Maybe you should insist a bit...

nonsuch 2022-05-01 14:56

Re: How to make a launcher for a shell script
 
Basically I'd want something telling the home screen (?) that the app is finished, done, not to bother with it anymore, forget about it.

A shell command would be nice, but I'm open to other suggestions.

I have terms like dbus-send and invoker swirling around my brain, but nothing makes sense.

suicidal_orange 2022-05-01 17:13

Re: How to make a launcher for a shell script
 
It's cheating but what happens if you run the script as an argument to the terminal app and exit at the end?

nonsuch 2022-05-02 05:25

Re: How to make a launcher for a shell script
 
Quote:

Originally Posted by suicidal_orange (Post 1574071)
It's cheating but what happens if you run the script as an argument to the terminal app and exit at the end?

Something weird happens: It opens the terminal full size, and executes the script. However, the helpful message I coded into the script is not displayed.
Then it minimizes.
If I then tap the cover again, it executes the script again, and this time the helpful message appears, and the terminal does not minimize again...

It would have been a good idea if fingerterm a) could be made to minimize straight away and b) would behave more consistently...

nonsuch 2022-05-06 04:01

Re: How to make a launcher for a shell script
 
Running it through a terminal works better with ToeTerm, but I'm still not satisfied with the result.

Frankly I'd still prefer for the launcher to not create a cover tile at all, just show the notifications.

mrsellout 2022-05-06 23:34

Re: How to make a launcher for a shell script
 
Does prefixing
Quote:

sh -c
before the command make a difference?

I noticed @nas gave an example .desktop file using this here

nonsuch 2022-05-07 08:38

Re: How to make a launcher for a shell script
 
Unfortunately it doesn't make a difference.
Thanks for the example, it suffers the same limitations as discussed here but the dbus notification method is cool to have nonetheless.

I've been faffing around with all sorts of settings inside the .desktop file, starting the script with invoker etc. and many fail. The pointless cover is at least succesful.

Short of getting the SDK and compiling a shell wrapper, or learning how to register my script with dbus and launch it via dbus, I see no solution.

nieldk 2022-05-13 06:55

Re: How to make a launcher for a shell script
 
You could use shc to compile the script to binary.
I cant recall if thats available on SailfishOS, but otherwise, its fairly simple.
Sources for shc is available so if its not already in repositories, it Can be compiled and used.
https://github.com/neurobin/shc

ric9K 2022-05-13 22:28

Re: How to make a launcher for a shell script
 
Does that mean "Shell to C"?
This is gorgeous!
edit: didn't find any shc in openrepos though :(

nieldk 2022-05-14 07:59

Re: How to make a launcher for a shell script
 
1 Attachment(s)
Did a quick compile
Extract this (tar xvf.shc.tar.gz)
copy the shc to /usr/local/bin/

nonsuch 2022-05-14 20:19

Re: How to make a launcher for a shell script
 
Quote:

Originally Posted by nieldk (Post 1574111)
You could use shc to compile the script to binary.
I cant recall if thats available on SailfishOS, but otherwise, its fairly simple.
Sources for shc is available so if its not already in repositories, it Can be compiled and used.
https://github.com/neurobin/shc

shc works.
But the compiled script suffers exactly the same ailments as the script itself, i.e. the launcher (lipstick I guess?) doesn't know that the script started, or that it finished, and just keeps spinning a waiting spinner for some time. It is not harmful, just not nice to look at.
I was wondering if it was possible to send the appropriate commands to the launcher (dbus???) via shell commands, or if I had to create a Silica wrapper around the script to get it to behave "nicely".

That said, is it possible to create a sort of Hello World Silica/QML program without having to install the complete SDK (on my desktop)?

nieldk 2022-05-15 13:30

Re: How to make a launcher for a shell script
 
Quote:

Originally Posted by nonsuch (Post 1574114)
shc works.
But the compiled script suffers exactly the same ailments as the script itself, i.e. the launcher (lipstick I guess?) doesn't know that the script started, or that it finished, and just keeps spinning a waiting spinner for some time. It is not harmful, just not nice to look at.
I was wondering if it was possible to send the appropriate commands to the launcher (dbus???) via shell commands, or if I had to create a Silica wrapper around the script to get it to behave "nicely".

That said, is it possible to create a sort of Hello World Silica/QML program without having to install the complete SDK (on my desktop)?

Really don’t know about dbus, but the API docs are here.
Coderus might know, but not sure how active he is here atm.

https://docs.sailfishos.org/Referenc...Is/D-Bus_APIs/

mrsellout 2022-05-15 18:46

Re: How to make a launcher for a shell script
 
What is the purpose of the mount?
Is it for a backup or just to access files eg. (music)?

Perhaps there could be another way of doing this.

The Situations app could be used to trigger a mount when you connect to a WIFI network during a specific time frame (and unmount when you disconnect).

nonsuch 2022-05-17 17:19

Re: How to make a launcher for a shell script
 
^ Nah, I want it on-demand, clickable.
Anyhow, my question is not so much about this application specifically, but rather generally about how I can launch a shell script through the launcher (lipstick?) without getting this pointless cover with a spinner.

nonsuch 2022-05-17 17:21

Re: How to make a launcher for a shell script
 
Quote:

Originally Posted by nieldk (Post 1574117)
Really don’t know about dbus, but the API docs are here.
Coderus might know, but not sure how active he is here atm.

https://docs.sailfishos.org/Referenc...Is/D-Bus_APIs/

Thanks anyhow.
Looks like the only command for lipstick is to trigger a screenshot...


All times are GMT. The time now is 16:41.

vBulletin® Version 3.8.8