Under development, it won't work properly till this warning disappears :p
Ubuntu Shutdown Timer (UST from now on) is a C# (over the .NET Core Framework 3.1) program that allows scheduling a set of automated shutdowns for computers running Ubuntu Desktop OS (20.04 and above), including a set of configurable user-oriented warnings that can be used to cancel the scheduled shutdowns (or just to warn about an imminent power off).
Please, note that event it has been developed over the .NET Core Framework 3.1, the application has been published as self-contained so there's no need to install the .NET Core SDK or runtime; it can just be executed as a regular binary!
- Tmds.DBus by Tom Deseyn: under the MIT License (https://www.nuget.org/packages/Tmds.DBus/)
- Download the latest release wherever you want to install the application (for example in
/usr/local/ust
). - Update the
settings/settings.json
settings file to fit up your needs. - Set execution permissions to the application main file with
chmod +x ust
. - Install the application with
./ust --install
which will setup the server and client instances. - Congrats! The application is ready and working :)
Update the settings/settings.json
settings file to fit up your needs.
- PopupThreshold (in minutes): The user will be warned about the shutdown event X minutes before the shutdown.
- IgnoreThreshold (in minutes): The server will ignore the scheduled shutdown if it must happen before than X minutes.
- AutocancelThreshold (in minutes): The client will auto-cancel a server scheduled shutdown if it must happen before than X minutes.
- Schedule: Array of shutdown events, the nearest shutdown will be the first one to be scheduled (obviously, the past ones will be ignored); if the user cancels one, the next one will be scheduled.
- Shutdown (local time): When the shutdown event will be fired.
- Mode (pop-up behaviour):
- SILENT: No pop-up or warning will be displayed to the user.
- INFORMATIVE: The user will be warned about a scheduled shutdown, but no interaction is allowed.
- CANCELLABLE: The user will be warned about a scheduled shutdown, and is allowed to cancel the scheduled event (the server will schedule the next one in the list).
- As root, uninstall the application with
ust --uninstall
and all the settings and changes will be reverted. - Remove the application folder.
- That's it! It's sad, but was fun :)
It has been built as a client-server application that uses D-Bus for communication, because it must work properly when a set of users are logged (sharing a computer) and also when there's no user logged at all.
The application can be split into two main parts:
- The server: Works with root permissions as a system.d service defined into
/lib/systemd/system/ust-server.service
launching a self-contained .NET Core 3.1 server-instance application. - The client: Works with user permissions as a regular application defined into
/etc/profile.d/ust-client.sh
launching a self-contained .NET Core 3.1 client-instance application.
-
The server starts:
- Registers and exposes the interface within D-Bus.
- The nearest (in the future) shutdown event is scheduled from the given schedule times (inside the
files/settings.json
file), if there's no more schedule times for today, it will be scheduled for tomorrow. - Listens for requests through D-Bus using events (no polling needed).
-
The client starts:
- Connects to the server using the D-Bus interface and asks for the current scheduled shutdown event.
- Schedules the warning pop-up using the given settings.
- Listens for cancellations over the scheduled event on server-side through D-Bus using events (no polling needed).
-
Scenario 1 - An info pop-up rises on client-side:
- An scheduled info pop-up rises on client-side (the user cannot cancel it).
- No interaction is performed over the server.
- The shutdown event rises on server and the computer poweroffs.
-
Scenario 2 - A cancellable pop-up rises on client-side:
- An scheduled cancellable pop-up rises on client-side and the user requests for cancellation.
- A cancellation request is performed over the server.
- The server accepts the cancellation (validation over scheduled IDs is done to avoid repeated requests from different user sessions).
- The server aborts the current shutdown and schedules the next one.
- The server sends a signal to all the client to warn them about a cancellation.
- The clients (all the connected ones) requests for the new scheduled event.
- The client cancels their current pop-ups and schedules the new ones.
-
D-Bus policies:
- If needed, a new file will be added to
/etc/dbus-1/system-local.conf
. - The previous file will be modified to allow communication through the
net.xeill.elpuig.UST1
interface for all users.
- If needed, a new file will be added to
-
Server service:
- A new service will be added to
/lib/systemd/system/ust-server.service
. - The service will run the application in server mode with root permissions on startup, so all users will find a unique running instance to connect with.
- A new service will be added to
-
Client application:
- A new launcher will be added to
/etc/profile.d/ust-client.sh
. - The application will run on client mode with user permissions on logon, so all users will connect with the server in order to display pop-ups if needed.
- A new launcher will be added to
-
Reload D-Bus:
- A call to ReloadConfig() will be performed over D-Bus.
- The D-Bus daemon will be forced to reload its config with a HUP signal (as the official documentation suggests).
-
D-Bus policies:
- The file
/etc/dbus-1/system-local.conf
won't be removed in order to preserve other configurations. - The policy entries for the
net.xeill.elpuig.UST1
interface will be removed.
- The file
-
Server service:
- The service
/lib/systemd/system/ust-server.service
will be disabled and removed.
- The service
-
Client application:
- The launcher
/etc/profile.d/ust-client.sh
will be removed.
- The launcher
-
Reload D-Bus:
- A call to ReloadConfig() will be performed over D-Bus.
- The D-Bus daemon will be forced to reload its config with a HUP signal (as the official documentation suggests).