Xfce Forum

Sub domains
 

You are not logged in.

#1 2016-05-05 14:48:20

millzy
Member
From: Near Melbourne
Registered: 2016-04-19
Posts: 13
Website

Running a command or script after xfce4-session executes

Hi there,

I'm trying to run a command via a bash script after xfce4-session and xfce4-session-logout finish executing, I'm sure there are may ways to do this and I am fairly new to the xfce world, so please be gentle...


What I am currently doing is I have renamed /usr/bin/xfce4-session to /usr/bin/xfce4-session.org and /usr/bin/xfce4-session-logout to /usr/bin/xfce4-session-logout.org, I have replaced each with a bash script using their original filenames executing each session library respectively.

Now the /usr/bin/xfce4-session-logout works well and I can add and execute commands before and after the /usr/bin/xfce4-session-logout.org library file is executed; unfortunetly i'm not getting anywhere executing anything after the /usr/bin/xfce4-session.org has executed, before it executes is fine as you would expect seeing the script runs first.

So I am wondering if there is something in /usr/bin/xfce4-session (or as I have renamed it /usr/bin/xfce4-session.org) that is terminating the script before it can run a command after it executes.  Is there a better way to do what I am doing, or a session-ready trigger once the session completely runs that is system and not user based?

By the way what I am doing is enabling and disabling the compositing setting so it is enabled after the xfce4 desktop loads from lightdm so I have a seemless transition between the two and each background, this prevents the grey screen background while xfce4 loads.  I have provided each file below, hope someone can point me in the right direction to resolve this:


The xfce4-session-logout script
>>
#!/bin/bash

# Test this will happen before session logout [works]
echo "xfce4-session-logout @ $(date)" >>/home/user/Desktop/session-logout.txt

# run the xfce4-sesion-logout library [works]
/usr/bin/xfce4-session-logout.org

# Test this will happen after session logout [works]
echo "xfce4-session-logout @ $(date)" >>/home/user/Desktop/session-logout.txt

# Turn off compositing [works, this could be put in lightdm somewhere once it loads, but is here for now so compositing is disabled on next load]
xfconf-query --channel=xfwm4 --property=/general/use_compositing --set=false

exit


The xfce4-session script, anything after the original xfce4-session is ignored
>>
#!/bin/bash

# Test that this works before session is started [this works, however compositing needs to be after the real xfce4-session executes]
echo "xfce4-session executed @ $(date)" >>/home/user/Desktop/session.txt

# run the renamed real xfce4-session library
/usr/bin/xfce4-session.org

# this is not reached
echo "xfce4-session finished @ $(date)" >>/home/user/Desktop/session.txt

# this is not reached
xfconf-query --channel=xfwm4 --property=/general/use_compositing --set=true

# this is not reached
echo "xfce4 composite turned on @ $(date)" >>/home/user/Desktop/session.txt

exit


I'm running:
>>
Debian Jessie 8.4.0
XFCE4 4.10.1
LightDM 1.10.3-3

Offline

#2 2016-05-05 22:43:13

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

Re: Running a command or script after xfce4-session executes

xfce4-session, once executed, will run for the entire session. When it exits so do you from the X session. None of the commands after /usr/bin/xfce4-session.org will be executed for the session.

You can try adding the command to Settings Manager > Session and startup > Application Autostart, but I'm not sure it will solve the problem you are trying to solve.

The other method would be to change your script to something like:

#!/bin/bash

# Test that this works before session is started [this works, however compositing needs to be after the real xfce4-session executes]
echo "xfce4-session executed @ $(date)" > /home/user/Desktop/session.txt
echo "state of compositor = "$(xfconf-query --channel=xfwm4 --property=/general/use_compositing) >> /home/user/Desktop/session.txt

# turn the compositor on after a delay
sleep 3 && xfconf-query --channel=xfwm4 --property=/general/use_compositing --set=true &

# Test for after the compositor is set
sleep 4 && echo "after compositor changed @ $(date)" >> /home/user/Desktop/session.txt &
sleep 4 && echo "state of compositor = "$(xfconf-query --channel=xfwm4 --property=/general/use_compositing) >> /home/user/Desktop/session.txt &


# run the renamed real xfce4-session library
/usr/bin/xfce4-session.org

...to run the compositing command in the background with a 3 second delay (to allow time for xfce4-session to start). Adjust the sleep timeout to suit.


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 2016-05-06 13:14:35

millzy
Member
From: Near Melbourne
Registered: 2016-04-19
Posts: 13
Website

Re: Running a command or script after xfce4-session executes

Hi ToZ,


Thanks for the suggestion, not quite what I'm looking for as session load time would vary from system to system.  I tested adding the composite change via Session and Startup > Application Autostart but it is a little to early and makes the desktop loading a little erratic.

Is everything managed by xfce4-session once it starts, is there a workflow of what processes xfce4-session runs? I am looking...

So I am wondering if I could trigger the change once the desktop has finished displaying icons, this would be the ideal point to make the change.  Correct me if I am off track in thinking that can be done, hence your suggestion to use sleep.


Many thanks

Last edited by millzy (2016-05-07 02:49:34)

Offline

#4 2016-05-06 18:42:40

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

Re: Running a command or script after xfce4-session executes

Just as an FYI, this bug was fixed post 4.10 (can't find the commit right now though).

Is everything managed by xfce4-session once it starts, is there a workflow of what processes xfce4-session runs? I am looking...

Yes. As I understand it, xfce4-session will load clients from ~/.cache/sessions (if a session file exists), otherwise it will load a set of default applications that include (depending on your distro):
- xfsettingsd
- xfwm4
- xfdesktop
- xfce4-panel
- Thunar --daemon
(see: /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml)


Have you tried using a session splash screen (Settings Manager > Session and Startup > Splash? Maybe one of the splash screens will fix the grey screen issue? On 4.12 I get mixed results.


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

#5 2016-05-07 02:49:19

millzy
Member
From: Near Melbourne
Registered: 2016-04-19
Posts: 13
Website

Re: Running a command or script after xfce4-session executes

Hi ToZ,


Yes, I had read that the bug was fixed in another post somewhere(should have bookmarked it) however I am still getting the grey screen issue, and am running XFCE 4.10.1 on a fresh install of Debian Jessie 8.4.0, I will try and track the bug report down.  Thanks for the session process explanation and links, and I will see if splash can help.

Offline

#6 2016-05-12 12:34:40

millzy
Member
From: Near Melbourne
Registered: 2016-04-19
Posts: 13
Website

Re: Running a command or script after xfce4-session executes

Just an update on this,


Found the bug report, or one of them, it is for Xubuntu and a little old @ https://bugs.launchpad.net/xfwm4/+bug/1232804, was that the one you were talking about ToZ?  Not sure whether to raise it again?

Thought about using sleep however that will only pause before executing the command sitting behind && , and tested that it does just that, so it is not an option.

I am now looking at xsession triggers to possibly achieve the outcome I am after.  Will post results...

Offline

#7 2016-05-12 13:09:35

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

Re: Running a command or script after xfce4-session executes

millzy wrote:

Found the bug report, or one of them, it is for Xubuntu and a little old @ https://bugs.launchpad.net/xfwm4/+bug/1232804, was that the one you were talking about ToZ?  Not sure whether to raise it again?

Yes, that was the report, but note that it was fixed in xfwm4 4.11. There is no need to raise the bug report with Xfce because it has been fixed. Unfortunately, your distro and version of xfwm4 doesn't include it. You might consider raising it with Debian to see if they will back-port the fix to their package of 4.10 - but I understand that debian is quite stringent about changes to stable releases.

I am now looking at xsession triggers to possibly achieve the outcome I am after.

Interesting. Keep us updated.


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

#8 2016-05-13 11:58:42

millzy
Member
From: Near Melbourne
Registered: 2016-04-19
Posts: 13
Website

Re: Running a command or script after xfce4-session executes

At this point I doubt it can be done without a scheduled task/timer triggered later that when the current session starts, which is what needs to happen;  compositor needs to be triggered (if using compositor) after the desktop and panel have loaded, using anything related to session, startup, or xsession trigger at the initial startup stage of the session which is to early.

My conclusion is to move to Debian stretch where they use >= xfwm4 4.12.0 , goodbye Jessie it was fun!

Offline

#9 2016-05-25 12:00:46

millzy
Member
From: Near Melbourne
Registered: 2016-04-19
Posts: 13
Website

Re: Running a command or script after xfce4-session executes

Damn, looks like it is broken again,

I have upgraded my system to the latest Debian alpha release:

Debian 4.5.3-2 (2016-05-08)
lightdm 1.18.1-1
xfwm4 4.12.3-2

Unfortunately the dreaded grey background appears once again between lightdm login and xfce4 session startup.  Should I be raising this through xfce4 or xfwm4?

Offline

#10 2016-05-25 17:18:08

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

Re: Running a command or script after xfce4-session executes

The fix from the launchpad report above included two parts:
- xfwm4 > -DMONITOR_ROOT_PIXMAP patch
- lightdm-gtk-greeter > xsetroot patch

You should probably first check to see if both of those patches are included in the debian versions of those packages.

I just installed debian weekly build from 2016-05-23 into a VM next to my Xubuntu 16.04 VM and notice that Xubuntu does not have the grey screen where as debian does. Which make me wonder whether debian hasn't included both patches in their packages.


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

#11 2016-05-28 05:56:04

millzy
Member
From: Near Melbourne
Registered: 2016-04-19
Posts: 13
Website

Re: Running a command or script after xfce4-session executes

G'day ToZ,


So the 2 packages on my version of Debian stretch weekly (it would be the build before yours earlier this month) were:

lightdm-gtk-greeter_2.0.1-2_i386
xfwm4_4.12.3-2_i386

I looked for entries with the patch names in change logs (changelog and changelog.Debian) and a thorough search of each deb's contents with no success.


Where to from here ToZ, is it time to create a Debian Reportbug entry for this?

And thanks, I appreciate the assistance...

Offline

#12 2016-05-28 12:19:01

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

Re: Running a command or script after xfce4-session executes

millzy wrote:

Where to from here ToZ, is it time to create a Debian Reportbug entry for this?

Yes. Perhaps a bug report is needed now to have the patches included.


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

#13 2016-06-08 09:09:34

millzy
Member
From: Near Melbourne
Registered: 2016-04-19
Posts: 13
Website

Re: Running a command or script after xfce4-session executes

Hi Toz,


Contacted Debian about the bug, and trying to track down both of the patches but can only find the one patch for the lightdm-gtk-greeter on the initial bug report, do you know where the patch for Xfwm4 is located?


Thanks

Offline

#14 2016-06-08 12:26:52

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

Re: Running a command or script after xfce4-session executes

It looks like that change was only made to the Xubuntu package of xfwm. Here is the mailing list discussion which links to this branch which appears to be the source of the patch.


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

#15 2016-06-08 13:35:28

millzy
Member
From: Near Melbourne
Registered: 2016-04-19
Posts: 13
Website

Re: Running a command or script after xfce4-session executes

Thanks Toz,


I have passed that information on, hopefully it is what they are after.  I will update this post with the outcome once I hear back.

Last edited by millzy (2016-06-08 13:35:59)

Offline

Board footer

Powered by FluxBB