[Fixed] Two problems after yesterday's system update

You have a problem with Slackel? Post here and we'll do what we can to help.
djemos
Site Admin
Posts: 676
Joined: 15 Apr 2016 06:03

Re: [Fixed] Two problems after yesterday's system update

Post by djemos »

Powerkit is also start here, last of all in the fbpanel.
For powerkit to not start automatically.

Code: Select all

sudo mv /etc/xdg/autostart/powerkit.desktop /tmp

Code: Select all

ps ax |grep powerkit
and kill it

Code: Select all

kill -9 number-of-pid
edit autostart.sh

Code: Select all

geany ~/.config/openbox/autostart.sh
add the line

Code: Select all

([ -x /usr/bin/powerkit ] && powerkit ) &
so can comment the line when you do not want to start or cannot add the line and run it with powerkit & from lxterminal

Also can install cbatticon with

Code: Select all

sudo slapt-src -i cbatticon 
It is working fine but i do not like the icon, which cannot be changed.
type in lxterminal cbatticon to run it.
Papasot
Posts: 231
Joined: 13 May 2016 22:32
Location: Patras, Greece

Re: [Fixed] Two problems after yesterday's system update

Post by Papasot »

That's exactly what I was looking for. I will have powerkit started in ~/.config/openbox/autostart.sh on my Slackel 64-bit system, and cbatticon on the slower 32-bit system. Thank you again, Dimitri!
djemos
Site Admin
Posts: 676
Joined: 15 Apr 2016 06:03

Re: [Fixed] Two problems after yesterday's system update

Post by djemos »

cbatticon use gtk-default-them for screen. Run lxapperance and choose Adwaita icon theme then icon is well looking.
Has three different icons, standard, symbolic, notification, from default used theme.
cbatticon -t to see a list of icons
cbatticon -i standard , use standard the default
cbatticon -i symbolic
cbatticon -i notification
cbatticon -u 1 , Set update interval in 1 sec

Look here for more
Papasot
Posts: 231
Joined: 13 May 2016 22:32
Location: Patras, Greece

Re: [Fixed] Two problems after yesterday's system update

Post by Papasot »

I was about to make a Slackel package for cbatticon but you were faster than me, Dimitri :D
This is what I ended up using (please correct me if I am wrong or there is a better way to do what I wanted):
cbatticon should shutdown the computer if battery level is critically low. This means cbatticon should execute sudo halt. There is a problem, however: sudo normally asks for user's password; I want to prevent this; system must shtdown without user intervention (because user might be away when battery level becomes critically low). My solution to this problem was this:create a new file, /etc/sudoers.d/20-halt:

Code: Select all

sudo vim /etc/sudoers.d/20-halt
(in this case I use vim but any editor can be used). In the new file add the line

Code: Select all

%wheel ALL=NOPASSWD: /sbin/halt
Save and exit. Now executing sudo halt will not ask for a user password for all users in group wheel. Then add this in ~/.config/openbox/autostart.sh:

Code: Select all

([ -x /usr/bin/cbatticon ] && dbus-launch cbatticon -n -i symbolic -c "sudo halt" -r 5)
This will run cbatticon when openbox starts. The essential flag is -c "sudo halt" which will shutdown the system at critical battery level. The rest of the flags are just personal preferences.
I am not quite sure if it's better to run cbatticon via dbus-launch. Since batti was launched that way, I did the same for cbatticon.

The above works very well and it's lightweight.
djemos
Site Admin
Posts: 676
Joined: 15 Apr 2016 06:03

Re: [Fixed] Two problems after yesterday's system update

Post by djemos »

I don't think cbatticon need dbus-launch
Try this. Without use sudo. This is used in wm-logout to halt or reboot the system (Stop is replaced by Restart)

Code: Select all

([ -x /usr/bin/cbatticon ] && dbus-launch cbatticon -n -i symbolic -c "dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop" -r 5) & 
or without dbus-launch

Code: Select all

([ -x /usr/bin/cbatticon ] && cbatticon -n -i symbolic -c "dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop" -r 5) & 
Using Adwaita or mate-brave icon theme without -i because standard is the default icon for cbatticon will have a nice icon.
Papasot
Posts: 231
Joined: 13 May 2016 22:32
Location: Patras, Greece

Re: [Fixed] Two problems after yesterday's system update

Post by Papasot »

djemos wrote:I don't think cbatticon need dbus-launch
cbatticon doesn't need dbus-launch, I was just wondering if it's better to use it or not. I guess it doesn't matter.
djemos wrote:Try this. Without use sudo. This is used in wm-logout to halt or reboot the system (Stop is replaced by Restart)

Code: Select all

([ -x /usr/bin/cbatticon ] && dbus-launch cbatticon -n -i symbolic -c "dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop" -r 5) & 
or without dbus-launch

Code: Select all

([ -x /usr/bin/cbatticon ] && cbatticon -n -i symbolic -c "dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop" -r 5) & 
This works perfectly, I actually made a script called system-halt which can be used by any user without needing to use sudo:

Code: Select all

#!/bin/sh
dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
I didn't know about that, so I was looking for a way to halt the system without dbus-launch. As far I know, there is no way for a normal user to use the halt command directly. It must be sudo halt. So I added a new "rule" for sudoers in /etc/sudoers.d/20-halt to bypass the need for a password, but only for the halt command. I wonder if this solution is legit, or there is a reason to avoid it.
djemos wrote:Using Adwaita or mate-brave icon theme without -i because standard is the default icon for cbatticon will have the same icon as powerkit.
I prefer the "symbolic" icon for cbatticon because it fits better with the Adwaita-Dark theme, which is what I use (less bright colors seem better for me, especially on my main Slackel 64-bit system which has a big monitor). It's all about personal taste though.

Thank you again, Dimitri. Not only the problem was solved in an elegant way, but I also learned something in the proccess.
djemos
Site Admin
Posts: 676
Joined: 15 Apr 2016 06:03

Re: [Fixed] Two problems after yesterday's system update

Post by djemos »

No need to do that.
First user is created at installation time is added to wheel group to have superuser privileges. So can use sudo.
Next user, users created are simple users without sudo privileges. Unless you add them in wheel group.
So they cannot run sudo for any program need superuser privileges. And cannot run sudo halt.

There is no need to add rule to sudoers because any user in the system super or simple, can shutdown or reboot or suspend or hibernate the system, using the dbus and consolekit like as in the above command.
The prove is that any user can shutdown or reboot the system from wm-logout.
So having the line to /home/user_name/.config/openbox/autostart.sh (which can automatically added for every new user created, if add it the line in the /etc/skel/.config/openbox/autostart.sh) can automatically shutdown system when battery is low.

In general in Slackel any user can shutdown or reboot the system from wm-logout
or by hand from command line typing

Code: Select all

dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
or create a bash file as you did

Code: Select all

#!/bin/sh
dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
and run it.
no sudoers rules need.
Papasot
Posts: 231
Joined: 13 May 2016 22:32
Location: Patras, Greece

Re: [Fixed] Two problems after yesterday's system update

Post by Papasot »

djemos wrote:Next user, users created are simple users without sudo privileges. Unless you add them in wheel group.
So they cannot run sudo for any program need superuser privileges. And cannot run sudo halt.
Good point, ESPECIALLY when my wife also uses my Slackel computers, and of course she should never be in wheel group because she is not experienced enough to have access to sudo. :D
I changed my autostart.sh so that dbus-launch is used to shutdown the computer when battery level is critically low. I am glad I learned another way to do it though.

EDIT: I duplicated the above post by mistake. Sourceforge was lagging when I tried to submit the post, and I resent it. I apologize for that. There is no way for me to delete the duplicated post.
Last edited by Papasot on 04 Dec 2020 16:47, edited 1 time in total.
djemos
Site Admin
Posts: 676
Joined: 15 Apr 2016 06:03

Re: [Fixed] Two problems after yesterday's system update

Post by djemos »

No problem, I deleted the second post.
Sourceforge have a lot of problems very often last week or more. I also have problems often to see the forum. It is also very slow sometimes. I get ngix error and other errors. Sometimes is going down because of too traffic. But it is free and i cannot use anything else to host slackel.
Papasot
Posts: 231
Joined: 13 May 2016 22:32
Location: Patras, Greece

Re: [Fixed] Two problems after yesterday's system update

Post by Papasot »

djemos wrote:I get ngix error and other errors. Sometimes is going down because of too traffic. But it is free and i cannot use anything else to host slackel.
ngix error is indeed common lately. But that's ok, it works in the end and it's free.
Post Reply