Akregator: ShutDown before Suspend / Reboot

KDE allows the Autostart of Programs, for AKREGATOR I’m using a script based on this posting.

Works fine! What surprises me: KDE obviously does not allow to AutoShutdown a program before shutdown the system. In case of AKREGATOR, I have this issue:

  • By default, having new messages, there is an icon in the system section of the control bar, that I can click on to open AKREGATOR. Clicking on the X in the window bar closes the window, but AKREGATOR remains active to fetch new messages. This is fine!
  • If I enter $ reboot in the console or reboot by startmenu, the system restarts as desired and AKREGATOR is started via System Settings > AutoStart. Also fine!
  • But: Now the icon in the system section of the control bar is not clickable. I’ve got a comment and could reproduce, that the reason for this is because AKREGATOR was not closed “properly”.
  • To restore the default behavior, the following procedure need to be performed:
    • Right-click on the icon
    • Click > Configure > Show icon in system tray > NO > Apply
    • Show icon in system tray > YES OK.

Or I always have to remember to deactivate AKREGATOR by File > Exit.

In order to avoid this, I’d like to have a solution (script?) to shutdown AKREGATOR before reboot.

That seems like rather extreme conjecture.

I would say it’s sounds like akregator isn’t shutting itself down correctly.


It sounds like a bug in Akregator or it’s panel app (or whatever it’s called in KDE), KDE bugs can be reported here.

However it could potentially be a configuration issue, perhaps someone else may know more. Either way you can test using a new user to see if it still happens.

2 Likes

You should add to Plasma’s settings a logout script which will close akregator.

Create the following script in your ~/.local/bin directory (make sure it is executable). Name it something easy to remember like close_akregator.sh:

#!/usr/bin/env bash

qdbus org.kde.akregator /akregator/MainWindow_1/actions/file_quit org.qtproject.Qt.QAction.trigger

exit 0

Then open System Settings → Autostart → Add New → Logout Script, browse to the ~/.local/bin directory & select the close_akregator.sh script.

akregator should now close properly when you logout of Plasma.

Edit: if akregator continues to give you the “not shutdown properly” message, maybe try adding a sleep command for 15-30 seconds to the line after the qdbus command. Possibly akregator is exiting, but a background process is still writing changes to the database. Delaying the shutdown for a few seconds may help. I don’t use akregator myself, but I did just install it for testing the above command. I’ve now removed akregator from my system, so I can’t test how it works with a lot of feeds/articles.

Also, you should not be using reboot or shutdown to exit a Plasma session. Here are some pre-prepared instructions for properly exiting Plasma via the command line:


This first command will exit a Plasma session the correct way. However, if you have an app open that requires confirmation to close (such as Firefox with multiple tabs open), then this may not be the best choice for a machine that will be unattended when shutting down:

qdbus org.kde.Shutdown /Shutdown logoutAndShutdown

To log out of Plasma & reboot:

qdbus org.kde.Shutdown /Shutdown logoutAndReboot

To exit a Plasma session, displaying the shutdown options page with the countdown timer first, any of these:

qdbus org.kde.LogoutPrompt /LogoutPrompt promptLogout

qdbus org.kde.LogoutPrompt /LogoutPrompt promptReboot

qdbus org.kde.LogoutPrompt /LogoutPrompt promptShutDown

To shutdown the same way as shutdown now:

systemctl poweroff

(you can also replace poweroff in the above with suspend or reboot or hibernate)

3 Likes

Thank you @scotty65,
I’ve followed your description:

[quote=“scotty65, post:3, topic:181777”]
Create the following script in your ~/.local/bin directory (make sure it is executable). Name it something easy to remember like close_akregator.sh:

#!/usr/bin/env bash
qdbus org.kde.akregator /akregator/MainWindow_1/actions/file_quit org.qtproject.Qt.QAction.trigger
exit 0

After that $ systemctl reboot and after the start-up I found, that Akregator has the same issue: The taskbar-Icon is non responsive,
To check, if the script runs I added at the beginning:

clear
OptDialog=kdialog

echo "shutdown" > /home/myname/Akregator.txt
echo "working..."
echo "Melody"
for note in C3 F4 A4 F4 C3 F4 A4 F4 C3 F4 F4 F4 E4 D4 C3; do play -q -n synth 0.25 pluck $note; done 
for Lauf in {1..3}; do
     echo "waiting $Lauf ..."
     $OptDialog --passivepopup "waiting $Lauf ..."  # alternativ: --msgbox, um auf Eingabe zu warten
     sleep 5s
done
echo "done"
$OptDialog --msgbox "To continue press Enter ..."

qdbus ... 

and again $ systemctl reboot but I don’t see / hear anything and the txt-file does not exist.
BUT: Re-Booting from Start-Menu creates the txt-file and plays the noise; and the icon is responsive.

Now what?

You put the script in AutoStart, right?
(… and I don’t know of anything like AutoEnd.)
So, I’d not be surprised that it runs @ startup - would be surprised if it ran when shutting down.

Don’t use systemctl reboot to exit Plasma. Even though it is considered the correct way to exit a GNU/Linux system that uses systemd, it is not the correct way to exit a Plasma session. systemctl reboot will prevent Plasma from doing its normal closure tasks, such as saving sessions and running logout scripts.

The correct way to reboot a Plasma session via the CLI is in the instructions I provided earlier. I assume that you do not want the reboot confirmation screen to display, so you should use the following command in place of systemctl reboot:

qdbus org.kde.Shutdown /Shutdown logoutAndReboot

That will result in Plasma shutting down properly (and the close_akregator.sh script running), as you have already confirmed happens when you reboot from the Application Launcher (aka Start Menu in Windoze):

In fact, you may not even need the close_akregator.sh script to run if you shutdown Plasma correctly. I’m fairly certain that properly logging out of Plasma instead of using systemctl reboot will ensure that any currently running KDE applications (including akregator) will be closed correctly. I used akregator a decade or so ago, never bothered manually closing it before I logged out of Plasma the correct way, and never had any akregator was not closed properly messages.

Logout scripts in Plasma are contained in ~/.config/plasma-workspace/shutdown/.

Adding a logout script via System Settings → Autostart → Add New → Logout Script will create a symlink to the actual script (as is the case with a script I set up a year ago to record my logout times):

ls -laH ~/.config/plasma-workspace/shutdown/ 
total 8
drwxr-xr-x 2 scotty scotty 4096 May  8  2024 .
drwxr-xr-x 4 scotty scotty 4096 May  8  2024 ..
lrwxrwxrwx 1 scotty scotty   29 May  8  2024 iloggedoutat -> /home/scotty/bin/iloggedoutat
4 Likes

Abandoned topic (60+ days)