Xfce Forum

Sub domains
 

You are not logged in.

#1 2022-04-25 17:55:32

hreba
Member
Registered: 2022-04-25
Posts: 4

Session and Startup: command "on logout" doesn't execute.

I am pissed off with the new firefox policy to download every pdf, even if you open it in a reader. So my idea was to create the directory ~/Temp/Download and set it as download directory for firefox. Then I called the xfce program "Session and Startup" and added an entry with the following properties:
Command: rm ~/Temp/Download/*.pdf
Trigger: on logout
It doesn't work, the pdf files remain there.

What I did:
- I executed the command from a terminal window and it worked.
- I changed the path to an absolute one (/home/...), and it works from terminal, but not in Session and Startup.
- I logged out and in again several times - to no avail.
- I looked for the entry in Session and Startup: it is there and it is checked.

My xfce version is 4.14.2 running under Linux Mint 20.1.

Offline

#2 2022-04-25 19:04:07

KBar
Member
Registered: 2021-11-05
Posts: 689

Re: Session and Startup: command "on logout" doesn't execute.

Hello and welcome.

Just use the /tmp directory.

As to your idea, we need to clarify something: on logout and on shutdown are two different things. You probably want the latter, which will force xfce4-session to run every item with the XFSM_RUN_HOOK_SHUTDOWN hook on system shutdown. 

Also, could you share the content of that .desktop file? It's in ~/.config/autostart/


Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please! tongue

Offline

#3 2022-04-26 06:46:10

hreba
Member
Registered: 2022-04-25
Posts: 4

Re: Session and Startup: command "on logout" doesn't execute.

Thanks for your fast answer.

/tmp is an intermediate solution. It is not an ideal one, because everything would be deleted, not only the pdf files.

I don't care whether the downloads are deleted upon logout or shutdown. I opted for logout, because this way the test cycle is faster.

Here is the desktop file:

frank@pc-frank:~$ cat .config/autostart/delete_downloads.desktop
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=delete_downloads
Comment=Delete all pdf files in ~/Temp/Download
Exec=rm /home/frank/Temp/Download/*.pdf
OnlyShowIn=XFCE;
RunHook=1
StartupNotify=false
Terminal=false
Hidden=false

Offline

#4 2022-04-26 08:31:36

KBar
Member
Registered: 2021-11-05
Posts: 689

Re: Session and Startup: command "on logout" doesn't execute.

Alright, try this:

Exec=sh -c 'rm /home/frank/Temp/Download/*.pdf'

This should work. If not, then set the XFSM_VERBOSE environment variable. Log out and log back in, put some PDF files in the directory, then log out. Then share the contents of ~/.xfce4-session.verbose-log and .xsession-errors.old.

Last edited by KBar (2022-04-26 08:34:56)


Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please! tongue

Offline

#5 2022-04-26 08:53:32

hreba
Member
Registered: 2022-04-25
Posts: 4

Re: Session and Startup: command "on logout" doesn't execute.

That did it, thanks a lot!

Perhaps a short explanation for the not-so-fluent in Linux?

Offline

#6 2022-04-26 09:18:34

KBar
Member
Registered: 2021-11-05
Posts: 689

Re: Session and Startup: command "on logout" doesn't execute.

As you might know, the asterisk is a wildcard that matches any string during pathname expansion. Before executing a command, the shell performs various expansions, field-splitting, and finally, quote removal. In the shell, you can execute that command successfully because the asterisk is expanded into a list of files that the rm command will act upon before it's executed.

However, in a desktop entry (i.e. .desktop files), programs are executed through the execve or similar system calls, and all arguments are fed to it literally. So, in your original desktop entry, the rm program is executed and its argument is set to the literal string /home/frank/Temp/Download/*.pdf. Pathname expansion is not performed because this mechanism is only used by the shell. Prepending sh -c ensures that the command is executed by the shell and not the execve system call (technically, it's still called, but the rest of the line is interpreted by the shell), and all expansions are performed as expected.

You can test this behavior. Revert the change to the desktop entry and create an empty file like so:

> ~/Temp/Download/\*.pdf

After that, log out and see if the file still exists. Hint: it doesn't. The removal was performed successfully.

Last edited by KBar (2022-04-26 09:19:52)


Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please! tongue

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.014 seconds, 7 queries executed - Memory usage: 540.52 KiB (Peak: 541.43 KiB) ]