Author Topic: vsido-exit (systemd based logout script for VSIDO)  (Read 6460 times)

hakerdefo

  • Posts: 520
    • View Profile
    • Looking at Linux through the Windows of Life
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #60 on: February 03, 2017, 09:03:50 AM »
Hi there Snap,
Thanks for the feedback. As I mentioned in my previous post I'll shortly be moving this over to GitHub and there I'll update the instruction on screen-lock helpers to reflect your suggestion.
Cheers!!!
You Can't Always Git What You Want

PackRat

  • Posts: 1965
    • View Profile
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #61 on: February 03, 2017, 02:02:42 PM »
Quote
I know it works with spectrwm, I'm curious if it works with dwm. Did you try it with your dwm build?

Jwm.  I did a quick build this morning before work.

I installed dwm, the script works as intended; good deal, dwm doesn't always work well with session management tools.
I am tired of talk that comes to nothing.
-- Chief Joseph

...the sun, the darkness, the winds are all listening to what we have to say.
-- Geronimo

hakerdefo

  • Posts: 520
    • View Profile
    • Looking at Linux through the Windows of Life
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #62 on: February 03, 2017, 07:56:04 PM »
Quote
I know it works with spectrwm, I'm curious if it works with dwm. Did you try it with your dwm build?

Jwm.  I did a quick build this morning before work.

I installed dwm, the script works as intended; good deal, dwm doesn't always work well with session management tools.

That's fantabulous  8)

I would again say this script wouldn't have been possible without PackRat.
It was his idea (Remember, he started the thread at code challenge).
And when I was happy and content with,
Code: [Select]
fluxbox-remote exitfor logout, it was PackRat who pushed me further  8)
And not to forget all the testing he has done  8)
Thanks a metric ton PackRat  :)

Cheers!!!
You Can't Always Git What You Want

PackRat

  • Posts: 1965
    • View Profile
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #63 on: February 04, 2017, 03:50:38 PM »
^ thanks, nice work writing the script.

Some simple tweaking - a bit of over-engineering for a script like this, but I wanted some practice.

Two changes:

the logout command is now:

Code: [Select]
loginctl terminate-session "$XDG_SESSION_ID
so no more parsing through awk. And the commands are now set up as variables so all a user/administrator has to do is change the variable to whatever custom command they want to use.

Code: [Select]
#!/usr/bin/env bash

LOGOUT="loginctl terminate-session "$XDG_SESSION_ID""
SUSPEND="systemctl suspend"
REBOOT="systemctl reboot"
POWEROFF="systemctl poweroff"

vslo_menu (){
vslo_ttle="vsido-logout"
vslo_clas="$vslo_ttle"
vslo_wico="/usr/share/pixmaps/logout_window_small.png"
vslo_wico_big="/usr/share/pixmaps/logout_window_big.png"
type xtrlock >/dev/null 2>&1
RETVAL=$?
if ! [[ "$RETVAL" == 0 ]]; then
type dm-tool >/dev/null 2>&1
RETVAL=$?
if ! [[ "$RETVAL" == 0 ]]; then
type slock >/dev/null 2>&1
RETVAL=$?
if ! [[ "$RETVAL" == 0 ]]; then
type i3lock >/dev/null 2>&1
RETVAL=$?
if ! [[ "$RETVAL" == 0 ]]; then
type light-locker >/dev/null 2>&1
RETVAL=$?
if ! [[ "$RETVAL" == 0 ]]; then
type xscreensaver >/dev/null 2>&1
RETVAL=$?
if ! [[ "$RETVAL" == 0 ]]; then
vslo_main=$(yad --class="$vslo_clas" --title="$vslo_ttle" --window-icon="$vslo_wico" --center --fixed --on-top --buttons-layout=center --button="Cancel!!Cancel:1" --button="Logout!!Logout of VSIDO:3" --button="Suspend!!Suspend VSIDO:4" --button="Reboot!!Reboot VSIDO:5" --button="Shutdown!!Shutdown VSIDO:6")
fi
fi
fi
fi
fi
fi
vslo_main=$(yad --class="$vslo_clas" --title="$vslo_ttle" --window-icon="$vslo_wico" --center --fixed --on-top --buttons-layout=center --button="Cancel!!Cancel:1" --button="Lock Screen!!Lock the screen:2" --button="Logout!!Logout of VSIDO:3" --button="Suspend!!Suspend VSIDO:4" --button="Reboot!!Reboot VSIDO:5" --button="Shutdown!!Shutdown VSIDO:6")
vslo_main=$?
case "$vslo_main" in
1)
exit 1
;;
2)
type xtrlock >/dev/null 2>&1
RETVAL=$?
if [[ "$RETVAL" == 0 ]]; then
xtrlock -b
exit 0
fi
type dm-tool >/dev/null 2>&1
RETVAL=$?
if [[ "$RETVAL" == 0 ]]; then
dm-tool lock
exit 0
fi
type slock >/dev/null 2>&1
RETVAL=$?
if [[ "$RETVAL" == 0 ]]; then
slock
exit 0
fi
type i3lock >/dev/null 2>&1
RETVAL=$?
if [[ "$RETVAL" == 0 ]]; then
i3lock
exit 0
fi
type light-locker >/dev/null 2>&1
RETVAL=$?
if [[ "$RETVAL" == 0 ]]; then
light-locker-command -l
exit 0
fi
type xscreensaver >/dev/null 2>&1
RETVAL=$?
if [[ "$RETVAL" == 0 ]]; then
xscrsav=$(which xscreensaver)
active_xscrsav=$(pidof "$xscrsav")
if [[ -z "$active_xscrsav" ]]; then
xscreensaver -no-splash &
sleep 1
xscreensaver-command -lock
exit 0
fi
fi
xscrsav_user=$(ps -p "$active_xscrsav" -o ruser=)
xscrsav_user_id=$(id -u "$xscrsav_user")
current_user_id=$(id -u)
if [[ "$xscrsav_user_id" == "$current_user_id" ]]; then
xscreensaver-command -lock
exit 0
fi
if [[ "$current_user_id" == 0 ]]; then
su "$xscrsav_user" -c "xscreensaver-command -lock"
exit 0
fi
yad --title="$vslo_ttle" --class="$vslo_clas" --window-icon="$vslo_wico" --borders=20 --center --fixed --image="$vslo_wico_big" --on-top --button=gtk-ok --text="xscreensaver was started by another user.\nso current user can't use the lock function.\nauto-start xscreensaver with your session.\n"
exit 0
;;
3)
$LOGOUT
exit 0
;;
4)
$SUSPEND
exit 0
;;
5)
$REBOOT
exit 0
;;
6)
$POWEROFF
exit 0
;;
130)
exit 1
;;
252)
exit 1
;;
esac
}
while :
do
vslo_menu
done

@hackerdefo - or anyone that likes to see the icons in the dialog box, I shrank the icons to 22x22 and think it looks better. The icons do not overpower the text in the dialog box.
I am tired of talk that comes to nothing.
-- Chief Joseph

...the sun, the darkness, the winds are all listening to what we have to say.
-- Geronimo

hakerdefo

  • Posts: 520
    • View Profile
    • Looking at Linux through the Windows of Life
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #64 on: February 04, 2017, 05:17:39 PM »
Thanks for the ideas PackRat. Assigning commands to variables can make editing the script easy. And I'm in the process of updating the script so these suggestions will be implemented in the new version.
Cheers!!!
You Can't Always Git What You Want

ozitraveller

  • Posts: 365
    • View Profile
    • Star
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #65 on: February 06, 2017, 05:41:06 AM »
I just have one small comment to make:

Code: [Select]
130)
exit 1
;;
252)
exit 1
;;

Could we have a comment or variable to indicate what 130 and 252 mean, my memory isn't what it used to be.

:)


PackRat

  • Posts: 1965
    • View Profile
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #66 on: February 06, 2017, 02:16:42 PM »
I think 130 is Script Terminated by CTL-c - which I think a user would only see if the script is run from a terminal and CTL-c issued when the terminal - not the dialog box - has focus. That stanza may be superfluous.

I think 252 is so the close button will function if a user leaves the dialog window decorated. Can't verify that one though.
Edit - sort of verified it. Comment out that sections and the close button no longer functions.
I am tired of talk that comes to nothing.
-- Chief Joseph

...the sun, the darkness, the winds are all listening to what we have to say.
-- Geronimo

jedi

  • DEFCON 1
  • Posts: 1547
  • Not all those who wander are lost.
    • View Profile
    • NixNut.com
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #67 on: February 06, 2017, 08:49:44 PM »
This is a cleaned up version of V2 that hakerdefo created that has all the buttons and no icons and a cancel.. I also changed the title

Looks like this - Plain Jane Version - 34 Lines of code with 821 characters and all functional - A thing of beauty IMO thank you hakerdefo!



This is now the default for VSIDO

Very Nice VastOne!!!  Just added love the looks of it.  Small is nice!  Works as advertised.  Thanks to everyone who worked on this...
Forum Netiquette

"No matter how smart you are you can never convince someone stupid that they are stupid."  Anonymous

ozitraveller

  • Posts: 365
    • View Profile
    • Star
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #68 on: February 07, 2017, 12:23:19 AM »
I think 130 is Script Terminated by CTL-c - which I think a user would only see if the script is run from a terminal and CTL-c issued when the terminal - not the dialog box - has focus. That stanza may be superfluous.

I think 252 is so the close button will function if a user leaves the dialog window decorated. Can't verify that one though.
Edit - sort of verified it. Comment out that sections and the close button no longer functions.

Thanks PackRat!

hakerdefo

  • Posts: 520
    • View Profile
    • Looking at Linux through the Windows of Life
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #69 on: February 09, 2017, 08:29:29 PM »
It is released to the public  8)

It is now known as lepo-logout  ;D

Many things have been improved  :)

Here is the link to the GitHub repo,

lepo-logout on GitHub

Cheers!!!
You Can't Always Git What You Want

PackRat

  • Posts: 1965
    • View Profile
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #70 on: February 10, 2017, 03:23:47 PM »
Many things have been improved  :)

Care to elaborate? There a changelog somewhere.

It works - well done. Just did a quick proof read. Looks like the big change are the yad boxes (?) asking for a password if a user needs use sudo to shutdown or reboot.
I am tired of talk that comes to nothing.
-- Chief Joseph

...the sun, the darkness, the winds are all listening to what we have to say.
-- Geronimo

hakerdefo

  • Posts: 520
    • View Profile
    • Looking at Linux through the Windows of Life
Re: vsido-exit (systemd based logout script for VSIDO)
« Reply #71 on: February 10, 2017, 10:17:06 PM »
It now better handles inhibition locks. Avoid them when it can and ask when it can't.
It also handles multiuser scenario a bit better. root or superuser can reboot-shutdown evenif other users are logged in.
It can now reboot-shutdown system even without polkit.
Many improvements, wouldn't you agree?
Cheers!!!
You Can't Always Git What You Want