[Software] How can I run a script just before xfce4 starts and just before it quits?

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
rayandrews
Posts: 148
Joined: 2014-01-31 21:32
Has thanked: 7 times
Been thanked: 2 times

[Software] How can I run a script just before xfce4 starts and just before it quits?

#1 Post by rayandrews »

I have a few things I want to get done before xfce4 starts. And a few more things I want to do before it quits. Is there some point at which I can add a script to the chain of execution?

amin11
Posts: 53
Joined: 2023-03-25 09:04
Has thanked: 7 times
Been thanked: 7 times

Re: [Software] How can I run a script just before xfce4 starts and just before it quits?

#2 Post by amin11 »

Research the following files and their differences

/etc/bash.bashrc
/etc/profile

/etc/bash.bash_logout

You can even use systemd-run

rayandrews
Posts: 148
Joined: 2014-01-31 21:32
Has thanked: 7 times
Been thanked: 2 times

Re: [Software] How can I run a script just before xfce4 starts and just before it quits?

#3 Post by rayandrews »

Sorry, what does shell configuration have to do with it? I'd love to use systemd-run is someone answers my question as to how systemd-run might do the job.

User avatar
wizard10000
Global Moderator
Global Moderator
Posts: 996
Joined: 2019-04-16 23:15
Location: southeastern us
Has thanked: 112 times
Been thanked: 161 times

Re: [Software] How can I run a script just before xfce4 starts and just before it quits?

#4 Post by wizard10000 »

rayandrews wrote: 2024-06-03 13:16Sorry, what does shell configuration have to do with it?
.profile and .bashrc can both run scripts, the difference is that .profile is run once, .bashrc is sourced every time you run a script or open a terminal window so .bashrc wouldn't be a great choice for startup scripts but .profile should work just fine.

On logout? .bash_logout executes every time a shell terminates so that probably wouldn't be the place to run your scripts either.

Probably better to create systemd units to run your scripts.

Hope this helps -
we see things not as they are, but as we are.
-- anais nin

rayandrews
Posts: 148
Joined: 2014-01-31 21:32
Has thanked: 7 times
Been thanked: 2 times

Re: [Software] How can I run a script just before xfce4 starts and just before it quits?

#5 Post by rayandrews »

> Probably better to create systemd units to run your scripts.

I tried that. Seems the 'shutdown' scripts have a sequence problem, I try to save a session but by the time the unit is reached dbus is too far gone to save anything. I need to run the script prior to dbus quitting.

User avatar
wizard10000
Global Moderator
Global Moderator
Posts: 996
Joined: 2019-04-16 23:15
Location: southeastern us
Has thanked: 112 times
Been thanked: 161 times

Re: [Software] How can I run a script just before xfce4 starts and just before it quits?

#6 Post by wizard10000 »

dbus relies on a GUI session. There are tons of people who know more about XFCE than I do but I did find this, which sounds promising - https://forum.xfce.org/viewtopic.php?id=16176
If you add a new Autostart item under Settings --> Session and Startup --> tab "Autostart Applications", you can specify at which time you want it to run--this includes logout and restart, among others.
Hope this helps -
we see things not as they are, but as we are.
-- anais nin

rayandrews
Posts: 148
Joined: 2014-01-31 21:32
Has thanked: 7 times
Been thanked: 2 times

Re: [Software] How can I run a script just before xfce4 starts and just before it quits?

#7 Post by rayandrews »

Thanks wiz, but it doesn't work. Damn, why not?

User avatar
wizard10000
Global Moderator
Global Moderator
Posts: 996
Joined: 2019-04-16 23:15
Location: southeastern us
Has thanked: 112 times
Been thanked: 161 times

Re: [Software] How can I run a script just before xfce4 starts and just before it quits?

#8 Post by wizard10000 »

rayandrews wrote: 2024-06-03 17:39Thanks wiz, but it doesn't work. Damn, why not?
Sorry, but I'm afraid I don't know why - and can't be sure whether it's XFCE or the script. Maybe try putting together a script that does something simple like creating a text file and see if XFCE runs that? If that runs successfully the issue is most likely either the script or how the script is called. If it fails it's most likely an XFCE thing.

We should probably open this up to our studio audience, though - as I haven't run XFCE in a whole bunch of years :)
we see things not as they are, but as we are.
-- anais nin

CwF
Global Moderator
Global Moderator
Posts: 3001
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 60 times
Been thanked: 243 times

Re: [Software] How can I run a script just before xfce4 starts and just before it quits?

#9 Post by CwF »

rayandrews wrote: 2024-06-03 01:43 Is there some point at which I can add a script to the chain of execution?
Not intuitive, there is the autostart dialog
Settings>Session and Startup>Application Autostart

Create a new item and you will see there is an option for when to execute, on shutdown and on logout are options. This is the session manager doing the job.

Oh wait, wizard10000 already said that...
Mottainai

rayandrews
Posts: 148
Joined: 2014-01-31 21:32
Has thanked: 7 times
Been thanked: 2 times

Re: [Software] How can I run a script just before xfce4 starts and just before it quits?

#10 Post by rayandrews »

"Oh wait, wizard10000 already said that..."

Doesn't work. Very strange. Identical command at CLI in a terminal works perfectly.

Post Reply