xfce4_chat_shortcut/chat_shortcut.org

5.5 KiB
Raw Blame History

XFCE4 Application Shortcut for Starting my Chat Clients

I am using three chat clients on my personal laptop: Signal and two instances of Element, one with my personal account and one with my work account. Because I like to work on my computer without distractions, I do not have the clients running most of the time. To read new messages I start the clients and once I am done close them again.

In the past I started each client from the command line. Then I wrote a function in Emacs Lisp that I called using an XFCE4 Application Shortcut. The function created three buffers, if they did not exist already, and started a process for each of the chat clients. This always opened a new Emacs frame in addition to the clients and three buffers that I never used. The was not a satisfying solution.

My newest solution uses systemd user service units that are started and stopped via XFCE4 Application Shortcuts. This has the advantage that no Emacs frame is opened, no buffers clutter my Emacs session, and I can close all three clients with a single shortcut.

What still irks me in the current setup are the long startup times of the Element clients. oBut turning of notification is not enough for me, There may be no vestiges of these processes left on my desktop when I want to focus.

systemd Unit Files

The three unit files are very similar. I give a full explanation for the first one and restrict the others to changes.

Signal

The configuration file begins with the [Unit] block and a description.

[Unit]
Description=Signal chat client

In the [Service] block, I first give the command line to start the service. The argument is necessary, because without it Signal at some point stopped finding the credentials is stored during setup.

[Service]
ExecStart=/usr/bin/signal-desktop --password-store=gnome-libsecret

Next I configure the LANGUAGE environment variable to be set to two languages, so that Signals spellchecker uses both dictionaries instead of just the one for the system language.

Environment="LANGUAGE=en_US:de_DE"

I also want the process to be restarted on failure instead of not at all, as is the default, and store the standard output of the last session in a file, so I can debug any problems, when they arise.

Restart=on-failure
StandardOutput=file:%h/.cache/logs/signal.log

Private Element

The structure of the unit file for Element with my private profile is very similar. It obviously has a different command line, as it starts a different program. It also does not need any Environment variables. And the filename for the standard output is different.

[Unit]
Description=Element chat client (private)

[Service]
ExecStart=/usr/bin/element-desktop
Restart=on-failure
StandardOutput=file:%h/.cache/logs/element.log

Work Element

For the work account Element, the command line has an additional argument to select the profile. The profile name fsu stands for Friedrich Schiller University, which is my employer and the provider of the Matrix server on which the account resides.

Again, the file for the standard output is different.

[Unit]
Description=Element chat client (fsu)

[Service]
Type=simple
ExecStart=/usr/bin/element-desktop --profile fsu
Restart=on-failure
StandardOutput=file:%h/.cache/logs/element_fsu.log

Setup

Running org-babel-tangle (C-c C-v t) on this file creates all three unit files in the same directory.

To let systemd now about the unit files, which are supposed to be only available to my user, I create symlinks to them in ~/.config/systemd/user/ (see man page systemd.unit) by running

  for unit in signal element element_fsu; do
      ln -s -t ~/.config/systemd/user $(realpath "${unit}.service");
  done

Afterwards I trigger a reload of the systemd configuration

  systemctl daemon-reload

I also make sure that the directory for the log files exist, otherwise systemd will not be able start the processes:

  mkdir -p ~/.cache/logs

To put it on an XFCE4 Application Shortcut, I open the settings (xfce4-settings), choose “Keyboard”, then the “Application Shortcuts” tab, and click “Add” to add first one, then another.

In my case I configure Super+R to start the chat clients, running the command line

  systemctl --user start signal element element_fsu

and Super+I (like ignore) to stop the chat clients, running the command line

  systemctl --user stop signal element element_fsu