Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-11-05 11:44:57

D.dave
Member
Registered: 2019-12-06
Posts: 58

Override xfce4-session-logout has no effects

Hi,

since I need to execute some commands before that the system goes to suspend to ram (delete and made some files) I made a script which run such actions and then trigger the sleep.
I set it in the keyboard shortcuts and works as expected (when I press fn+f3 > sleep), but I also need to make it run when the system goes to sleep after x minutes of inactivity: this is set in Xfce Power Manager.
Lets say that I set the "go to sleep after 20 minutes of inactivity", after that time the suspend to ram occurs, and obviously my needed actions are ignored; after some searches I found this discussion to override /usr/bin/xfce4-session-logout

https://forum.xfce.org/viewtopic.php?id=12222

But I modified it in this way:

##########################

#!/bin/bash

## located as ~/.local/bin/xfce4-session-logout

case $1 in
        "--suspend")
                ~/scripts/customsuspend
        ;;
        *)
                /usr/bin/xfce4-session-logout "$1"
        ;;
esac

exit 0

##########################


But doesn't work... Am I miss something? Is this the proper way to override /usr/bin/xfce4-session-logout ?
I also tried this one https://unix.stackexchange.com/question … nd-command but still doesn't works.

Thanks.

Offline

#2 2020-11-05 12:00:25

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Override xfce4-session-logout has no effects

which xfce4-session-logout

...will tell you which executable is being called.

You need to make sure that the new executable is in your $PATH and that it precedes the directory that the original executable resides in. Is ~/.local/bin in your path preceeding the normal /usr/bin location? If you:

echo $PATH

...you can see your PATH. Usually, /usr/local/bin preceeds /usr/bin, so you should probably put it there.

That being said, if you need to execute some scripts before suspend, you could use other built-in functionality - but this is dependent on the distro you are using. For example, if you are using systemd, then you could use a sleep hook.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2020-11-05 12:19:46

D.dave
Member
Registered: 2019-12-06
Posts: 58

Re: Override xfce4-session-logout has no effects

which xfce4-session-logout:
/home/dave/.local/bin/xfce4-session-logout

whereis xfce4-session-logout:
xfce4-session-logout: /usr/bin/xfce4-session-logout /home/dave/.local/bin/xfce4-session-logout /usr/share/man/man1/xfce4-session-logout.1.gz

echo $PATH:
/usr/bin:/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/dave/scripts:/usr/share/zenmap:/home/dave/Samsung_Magician:/home/dave/.local/bin:/home/dave/scripts/hs100:/home/dave/go/bin

I am aware of the ability to make a systemd unit which is called on suspend, and I tried: it works flawlessly, but for some reason a specific command (rmmod $module_name) doesn't works (obviously this command is also indicated in the sudoers config file, so I am able to run it without insert the root password); my customsuspend script, instead, works ok, when called from shortcut, or also by an icon on the Desktop.

Offline

#4 2020-11-05 12:51:53

D.dave
Member
Registered: 2019-12-06
Posts: 58

Re: Override xfce4-session-logout has no effects

I have no idea of what is happening here... To made a test, I temporarily disabled /usr/bin/xfce4-session-logout (renamed /usr/bin/xfce4-session-logout.bk); I waited 20 mins, the system has gone to sleep, but my script has not been executed yet, however.

How can check, to be totally sure, which commands, executable or script is called by power manager?

Offline

#5 2020-11-05 12:52:51

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Override xfce4-session-logout has no effects

In your PATH, /usr/bin precedes ~/.local/bin, so it is processed first. Try changing the order. Something like:

export PATH="~/.local/bin:$PATH"

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#6 2020-11-05 12:57:37

D.dave
Member
Registered: 2019-12-06
Posts: 58

Re: Override xfce4-session-logout has no effects

Yes: then i fixed it and now, in facts, reports
echo $PATH
/home/dave/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/dave/scripts:/usr/share/zenmap:/home/dave/Samsung_Magician:/home/dave/scripts/hs100:/home/dave/go/bin

But I am at loss, puzzled

Offline

#7 2020-11-05 13:18:09

D.dave
Member
Registered: 2019-12-06
Posts: 58

Re: Override xfce4-session-logout has no effects

I think (and hope!) that I solved it.

I edited ~/.local/bin/xfce4-session-logout in such way:

if [ "$1" = "--suspend" ] || [ "$1" = "-s" ] || [ "$1" = "-f -s" ] || [ "$1" = "-s -f" ]; then
    ~/.local/bin/xfce4-session-logout
else
    /usr/bin/xfce4-session-logout "$@"
fi

To intercept any option related to suspend triggered byxfce4-session-logout :
xfce4-session-logout --suspend xfce4-session-logout -s xfce4-session-logout -f -s

Offline

Board footer

Powered by FluxBB