Skip to content

Commit

Permalink
feat: Add the --tray --enable option to automatically set the systr…
Browse files Browse the repository at this point in the history
…ay applet in autostart apps (#197)

Add the optional `--enable` argument to the `--tray` option to automatically set the systray applet in the autostart apps by copying the "arch-update-tray.desktop" file to `${XDG_CONFIG_HOME:-${HOME}/.config}/autostart/arch-update-tray.desktop`

Closes #180
  • Loading branch information
Antiz96 committed Jul 4, 2024
1 parent 8531c29 commit 2b3857f
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 18 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ install:
install -Dm 664 "src/icons/${pkgname}.svg" "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/${pkgname}.svg"
install -Dm 664 "src/icons/${pkgname}_updates-available.svg" "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/${pkgname}_updates-available.svg"

# Install the .desktop file
# Install .desktop files
install -Dm 644 "res/desktop/${pkgname}.desktop" "${DESTDIR}${PREFIX}/share/applications/${pkgname}.desktop"
install -Dm 644 "res/desktop/${pkgname}-tray.desktop" "${DESTDIR}${PREFIX}/share/applications/${pkgname}-tray.desktop"

# Install systemd units
install -Dm 644 "res/systemd/${pkgname}.service" "${DESTDIR}${PREFIX}/lib/systemd/user/${pkgname}.service"
Expand Down Expand Up @@ -63,8 +64,9 @@ uninstall:
rm -rf "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/${pkgname}.svg"
rm -rf "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/${pkgname}_updates-available.svg"

# Delete the .desktop file
# Delete .desktop files
rm -f "${DESTDIR}${PREFIX}/share/applications/${pkgname}.desktop"
rm -f "${DESTDIR}${PREFIX}/share/applications/${pkgname}-tray.desktop"

# Delete systemd units
rm -f "${DESTDIR}${PREFIX}/lib/systemd/user/${pkgname}.service"
Expand Down
8 changes: 6 additions & 2 deletions README-fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ L'utilisation consiste à démarrer [l'applet systray](#lapplet-systray) et à a

### L'applet systray

Pour démarrer l'applet systray automatiquement au démarrage du système, ajoutez la commande `arch-update --tray` a vos commandes 'auto-start'/configuration de votre WM ou démarrez/activez le service systemd associé comme ceci :
Pour démarrer l'applet systray, lancez l'application "Arch-Update Systray Applet" depuis votre menu d'application.
Pour la démarrer automatiquement au démarrage du système, vous pouvez soit lancer la commande `arch-update --tray --enable` (c'est la méthode privilégiée pour certains environnements de bureau spécifiques, comme XFCE par exemple) ou vous pouvez démarrer/activer le service systemd associé comme ceci :

```bash
systemctl --user enable --now arch-update-tray.service
```

*Si vous utilisez un gestionnaire de fenêtre/compositeur Wayland, vous pouvez plutôt ajouter la commande `arch-update --tray` à vôtre fichier de configuration.*

L'icône du systray changera automatiquement en fonction de l'état actuel de votre système ('à jour' ou 'mises à jour disponibles'). Lorsque vous cliquez dessus, il lance `arch-update` via le fichier [arch-update.desktop](https://github.com/Antiz96/arch-update/blob/main/res/desktop/arch-update.desktop).

L'applet systray essaie de lire le fichier `arch-update.desktop` dans les chemins ci-dessous avec l'ordre suivant :
Expand Down Expand Up @@ -161,7 +164,7 @@ Options :
-D, --debug Afficher les traces de débogage
--gen-config Générer un fichier de configuration par défaut/exemple (voir la page de manuel arch-update.conf(5) pour plus de détails)
--show-config Afficher le fichier de configuration `arch-update.conf` actuellement utilisé (s'il existe)
--tray Lancer l'applet systray d'Arch-Update
--tray Lancer l'applet systray d'Arch-Update, vous pouvez optionnellement ajouter l'argument `--enable` pour la démarrer automatiquement au démarrage du système.
-h, --help Afficher ce message d'aide et quitter
-V, --version Afficher les informations de version et quitter
Expand All @@ -176,6 +179,7 @@ Codes de sortie :
7 Aucune mise à jour en attente durant l'utilisation de l'option `-l/--list`
8 Erreur lors de la génération d'un fichier de configuration avec l'option `--gen-config`
9 Erreur lors de la lecture du fichier de configuration avec l'option `--show-config`
10 Erreur lors de la creation du fichier desktop autostart pour l'applet systray avec l'option `--tray --enable`
```

Pour plus d'informations, consultez la page de manuel arch-update(1).
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ The usage consist of starting [the systray applet](#the-systray-applet) and enab

### The systray applet

To start the systray applet automatically at boot, add the `arch-update --tray` command to your auto-start commands/WM config or start/enable the associated systemd service like so:
To start the systray applet, launch the "Arch-Update Systray Applet" application from your app menu.
To start it automatically at boot, either run the `arch-update --tray --enable` command (this is the preferred method on some specific desktop environments, like XFCE for instance) or start/enable the associated systemd service like so:

```bash
systemctl --user enable --now arch-update-tray.service
```

*If you use a window manager/Wayland compositor, you can add the `arch-update --tray` command to your configuration file instead.*

The systray icon will automatically change depending on the current state of your system ('up to date' or 'updates available'). When clicked, it launches `arch-update` via the [arch-update.desktop](https://github.com/Antiz96/arch-update/blob/main/res/desktop/arch-update.desktop) file.

The systray applet attempts to read the `arch-update.desktop` file at the below paths and in the following order:
Expand Down Expand Up @@ -161,7 +164,7 @@ Options:
-D, --debug Display debug traces
--gen-config Generate a default/example configuration file (see the arch-update.conf(5) man page for more details)
--show-config Display the `arch-update.conf` configuration file currently used (if it exists)
--tray Launch the Arch-Update systray applet
--tray Launch the Arch-Update systray applet, you can optionally add the `--enable` argument to start it automatically at boot.
-h, --help Display this help message and exit
-V, --version Display version information and exit
Expand All @@ -176,6 +179,7 @@ Exit Codes:
7 No pending update when using the `-l/--list` option
8 Error when generating a configuration file with the `--gen-config` option
9 Error when reading the configuration file with the `--show-config` option
10 Error when creating the autostart desktop file for the systray applet with the `--tray --enable` option
```

For more information, see the arch-update(1) man page.
Expand Down
12 changes: 10 additions & 2 deletions doc/man/arch-update.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ARCH-UPDATE" "1" "June 2024" "Arch-Update 2.1.0" "Arch-Update Manual"
.TH "ARCH-UPDATE" "1" "July 2024" "Arch-Update 2.1.0" "Arch-Update Manual"

.SH NAME
arch-update \- An update notifier/applier for Arch Linux that assists you with important pre/post update tasks.
Expand Down Expand Up @@ -66,7 +66,11 @@ Display debug traces.

.TP
.B \-\-tray
.RB "Launch the Arch-Update systray applet (you can alternatively start/enable the associated systemd service like so: " "systemctl \-\-user enable \-\-now arch-update-tray.service").
Start the Arch-Update systray applet.
.br
.RB "To start it automatically at boot, you can either run the " "arch-update --tray --enable " "command (this is the preferred method on some specific desktop environments, like XFCE for instance) or start/enable the associated systemd service like so: " "systemctl \-\-user enable \-\-now arch-update-tray.service".
.br
.RB "If you use a window manager/Wayland compositor, you can add the " "arch-update --tray " "command to your configuration file instead."

.TP
.B \-v, \-\-version
Expand Down Expand Up @@ -219,6 +223,10 @@ Error when calling the reboot command to apply a pending kernel update
.B 9
.RB "Error when reading the configuration file with the " "--show-config " "option"

.TP
.B 10
.RB "Error when creating the autostart desktop file for the systray applet with the " "--tray --enable " "option"

.SH SEE ALSO
.BR checkupdates (8),
.BR pacman (8),
Expand Down
12 changes: 10 additions & 2 deletions doc/man/fr/arch-update.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH "ARCH-UPDATE" "1" "Juin 2024" "Arch-Update 2.1.0" "Manuel de Arch-Update"
.TH "ARCH-UPDATE" "1" "Juillet 2024" "Arch-Update 2.1.0" "Manuel de Arch-Update"

.SH NAME
arch-update \- Un notificateur/applicateur de mises à jour pour Arch Linux qui vous assiste dans les tâches importantes d'avant/après mise à jour.
Expand Down Expand Up @@ -66,7 +66,11 @@ Afficher les traces de débogage.

.TP
.B \-\-tray
.RB "Lancer l'applet systray d'Arch-Update (alternativement, vous pouvez démarrer/activer le service systemd associé comme ceci : " "systemctl \-\-user enable \-\-now arch-update-tray.service").
Démarrer l'applet systray d'Arch-Update.
.br
.RB "Pour la démarrer automatiquement au démarrage du système, vous pouvez soit exécuter la commande " "arch-update --tray --enable " "(c'est la méthode privilégiée pour certains environnements de bureau spécifiques, comme XFCE par exemple) ou vous pouvez démarrer/activer le service systemd associé comme ceci : " "systemctl \-\-user enable \-\-now arch-update-tray.service".
.br
.RB "Si vous utilisez un gestionnaire de fenêtres/un compositeur Wayland, vous pouvez plutôt ajouter la commande " "arch-update --tray " "à votre fichier de configuration."

.TP
.B \-v, \-\-version
Expand Down Expand Up @@ -219,6 +223,10 @@ Erreur lors de l'appel de la commande reboot pour appliquer une mise à jour du
.B 9
.RB "Erreur lors de la lecture du fichier de configuration avec l'option " "--show-config"

.TP
.B 10
.RB "Erreur lors de la création du fichier desktop autostart pour l'applet systray avec l'option " "--tray --enable"

.SH VOIR AUSSI
.BR checkupdates (8),
.BR pacman (8),
Expand Down
23 changes: 22 additions & 1 deletion po/arch-update.pot
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ msgstr ""

#: src/script/arch-update.sh:192
#, sh-format
msgid " --tray Launch the Arch-Update systray applet"
msgid ""
" --tray Launch the Arch-Update systray applet, you can "
"optionally add the '--enable' argument to start it automatically at boot"
msgstr ""

#: src/script/arch-update.sh:193
Expand Down Expand Up @@ -485,6 +487,25 @@ msgstr ""
msgid "No configuration file found"
msgstr ""

#: src/script/arch-update.sh:743
#, sh-format
msgid "Arch-Update tray desktop file not found"
msgstr ""

#: src/script/arch-update.sh:750
#, sh-format
msgid "The '${tray_desktop_file_autostart}' file already exists"
msgstr ""

#: src/script/arch-update.sh:755
#, sh-format
msgid ""
"The '${tray_desktop_file_autostart}' file has been created, the Arch-Update "
"systray applet will be automatically started at your next log on\\nTo start "
"it right now, you can launch the \"Arch-Update Systray Applet\" application "
"from your app menu"
msgstr ""

#: src/script/arch-update-tray.py:118
msgid "Run Arch-Update"
msgstr ""
Expand Down
31 changes: 29 additions & 2 deletions po/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,12 @@ msgstr " --gen-config Générer un fichier de configuration par défaut/ex

#: src/script/arch-update.sh:192
#, sh-format
msgid " --tray Launch the Arch-Update systray applet"
msgstr " --tray Lancer l'applet systray d'Arch-Update"
msgid ""
" --tray Launch the Arch-Update systray applet, you can "
"optionally add the '--enable' argument to start it automatically at boot"
msgstr ""
" --tray Lancer l'applet systray d'Arch-Update, vous pouvez "
"optionnellement ajouter l'argument '--enable' pour la démarrer automatiquement au démarrage du système"

#: src/script/arch-update.sh:193
#, sh-format
Expand Down Expand Up @@ -521,6 +525,29 @@ msgstr "Le fichier de configuration '${config_file}' a été généré"
msgid "No configuration file found"
msgstr "Aucun fichier de configuration n'a été trouvé"

#: src/script/arch-update.sh:743
#, sh-format
msgid "Arch-Update tray desktop file not found"
msgstr "Le fichier Arch-Update tray desktop n'a pas été trouvé"

#: src/script/arch-update.sh:750
#, sh-format
msgid "The '${tray_desktop_file_autostart}' file already exists"
msgstr "Le fichier '${tray_desktop_file_autostart}' existe déjà"

#: src/script/arch-update.sh:755
#, sh-format
msgid ""
"The '${tray_desktop_file_autostart}' file has been created, the Arch-Update "
"systray applet will be automatically started at your next log on\\nTo start "
"it right now, you can launch the \"Arch-Update Systray Applet\" application "
"from your app menu"
msgstr ""
"Le fichier '${tray_desktop_file_autostart}' a été créé, l'applet systray d'Arch-Update "
"sera automatiquement démarré à votre prochaine connexion\\nPour la démarrer "
"immédiatement, vous pouvez lancer l'application \"Arch-Update Systray Applet\" "
"depuis votre menu d'application"

#: src/script/arch-update-tray.py:118
msgid "Run Arch-Update"
msgstr "Lancer Arch-Update"
Expand Down
6 changes: 6 additions & 0 deletions res/desktop/arch-update-tray.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=Arch-Update Systray Applet
Icon=arch-update_updates-available
Exec=arch-update --tray
Categories=Utility
38 changes: 33 additions & 5 deletions src/script/arch-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ $(eval_gettext " -d, --devel Include AUR development packages updates")
$(eval_gettext " -n, --news [Num] Display latest Arch news, you can optionally specify the number of Arch news to display with '--news [Num]' (e.g. '--news 10')")
$(eval_gettext " -D, --debug Display debug traces")
$(eval_gettext " --gen-config Generate a default/example configuration file")
$(eval_gettext " --tray Launch the Arch-Update systray applet")
$(eval_gettext " --tray Launch the Arch-Update systray applet, you can optionally add the '--enable' argument to start it automatically at boot")
$(eval_gettext " -h, --help Display this help message and exit")
$(eval_gettext " -V, --version Display version information and exit")
Expand Down Expand Up @@ -728,11 +728,39 @@ case "${option}" in
fi
;;
--tray)
if [ ! -f "${statedir}/current_state" ]; then
state_up_to_date
fi
if [ "${2}" == "--enable" ]; then
if [ -f "${XDG_DATA_HOME}/applications/${name}-tray.desktop" ]; then
tray_desktop_file="${XDG_DATA_HOME}/applications/${name}-tray.desktop"
elif [ -f "${HOME}/.local/share/applications/${name}-tray.desktop" ]; then
tray_desktop_file="${HOME}/.local/share/applications/${name}-tray.desktop"
elif [ -f "${XDG_DATA_DIRS}/applications/${name}-tray.desktop" ]; then
tray_desktop_file="${XDG_DATA_DIRS}/applications/${name}-tray.desktop"
elif [ -f "/usr/local/share/applications/${name}-tray.desktop" ]; then
tray_desktop_file="/usr/local/share/applications/${name}-tray.desktop"
elif [ -f "/usr/share/applications/${name}-tray.desktop" ]; then
tray_desktop_file="/usr/share/applications/${name}-tray.desktop"
else
error_msg "$(eval_gettext "Arch-Update tray desktop file not found")"
exit 10
fi

tray_desktop_file_autostart="${XDG_CONFIG_HOME:-${HOME}/.config}/autostart/arch-update-tray.desktop"

if [ -f "${tray_desktop_file_autostart}" ]; then
error_msg "$(eval_gettext "The '\${tray_desktop_file_autostart}' file already exists")"
exit 10
else
mkdir -p "${XDG_CONFIG_HOME:-${HOME}/.config}/autostart/"
cp "${tray_desktop_file}" "${tray_desktop_file_autostart}" || exit 10
info_msg "$(eval_gettext "The '\${tray_desktop_file_autostart}' file has been created, the Arch-Update systray applet will be automatically started at your next log on\nTo start it right now, you can launch the \"Arch-Update Systray Applet\" application from your app menu")"
fi
else
if [ ! -f "${statedir}/current_state" ]; then
state_up_to_date
fi

arch-update-tray || exit 3
arch-update-tray || exit 3
fi
;;
-h|--help)
help
Expand Down

0 comments on commit 2b3857f

Please sign in to comment.