We have moved to a new Sailfish OS Forum. Please start new discussions there.
2

Situations app to stop Alien-dalvik via a command [answered]

asked 2020-06-20 11:45:00 +0200

branja6 gravatar image

Ahoy, sailors

I've searched everywhere, and I couldn't find a way to do it. I would like to set the Situations app to stop Alien Dalvik when I go into an airplane mode. It should be quite easy, I guess, but I am a bit of noob. It seems that the Situations app can use custom commands, which is excellent. The only problem I have is that I have to stop Alien Dalvik via this command "systemctl stop aliendalvik.service", and it only works if I type it with root privileges.

Any help is appreciated.

Thx in advance

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by olf
close date 2020-06-20 23:06:08.409437

3 Answers

Sort by » oldest newest most voted
3

answered 2020-06-20 14:32:24 +0200

pawel gravatar image

download dalvik stop from openrepos. then use situatons to start an app and select dalvik stop

you dont even need cmdline for that

i have set it up like that, in my case trigger is a time, but ...

edit flag offensive delete publish link more

Comments

That is amazing! I will try it out right away. Thanks a ton, Pawel.

branja6 ( 2020-06-20 15:09:10 +0200 )edit
3

answered 2020-06-20 22:54:58 +0200

ziellos gravatar image

The academic answer would be to install and configure sudo. A bit more work than installing an app, but you have to do it only once.

When configured correctly, user nemo may execute privileged commands such as systemctl to control services. You can then use such commands in Situations or in any other context. No clear-text passwords, no security risk.

edit flag offensive delete publish link more

Comments

So far, I know only how to install sudo, but to configure it to get what I want is still a mystery to me. :) If you care to explain, I'm all ears. @ziellos

branja6 ( 2020-06-20 23:31:20 +0200 )edit

All I did after the sudo installation was to include entries for the desired privileged commands in /etc/sudoers:

nemo     ALL = NOPASSWD: /usr/bin/dbus-send
nemo     ALL = NOPASSWD: /bin/systemctl
nemo     ALL = NOPASSWD: /usr/bin/connmanctl

With these settings, the Situations app is able to control flight mode, wifi, and systemd services via shell scripts.

ziellos ( 2020-06-23 11:08:32 +0200 )edit

Thank you very much for this! Next stop for me: learning how to make shell scripts.

branja6 ( 2020-06-23 11:28:05 +0200 )edit

If you only want to start/stop Alien Dalvik using Situations, the following commands should be sufficient (with a working sudo configuration):

Stop service:

sudo /bin/systemctl stop aliendalvik.service

Start service:

sudo /bin/systemctl start aliendalvik.service

However, creating small shell scripts that are triggered by Situations switching may be preferable because you can then simply extend the scripts to add functionality.

ziellos ( 2020-06-23 11:51:40 +0200 )edit
2

answered 2020-06-20 15:35:03 +0200

updated 2020-06-20 15:35:56 +0200

Thanks @pawel there is still lots to discover on openrepos ;)

But does really every command line needs an 'app'?

@branja6
You may achieve it via

echo myPasswd | devel-su -c systemctl stop aliendalvik

This is a bit of security concerning but if you put into an executable sh script and hide it somewhere under /bin ? hmm (I did it a few times on N900)

edit flag offensive delete publish link more

Comments

Excellent! I will tamper with this code as well. Thank you very much, Peter.

branja6 ( 2020-06-20 15:45:26 +0200 )edit

Question tools

Follow
3 followers

Stats

Asked: 2020-06-20 11:45:00 +0200

Seen: 432 times

Last updated: Jun 20 '20