ActivityWatch / ActivityWatch/activitywatch

¡Working! GNOME Wayland on Ubuntu 25.10: workaround is `aw-awatcher` + Focused Window D-Bus

Open
#1,218 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
18.9k
Forks
1k
Avg merge
1d 4h
Merged PRs (30d)
28

Description

# Running ActivityWatch on GNOME Wayland (Ubuntu 25.10) by replacing default watchers with `aw-awatcher`

## Summary

On an **Acer Predator PT315-52** running **Ubuntu 25.10**, **GNOME Shell 49.0**, **Wayland**, and **Linux 6.17.0-19-generic**, the standard ActivityWatch Linux setup worked partially: the web UI came up, but the default Linux watchers failed repeatedly with X11 display authorization errors.

The workaround that succeeded was:

1. Install ActivityWatch normally.
2. Confirm that the desktop session is **Wayland**.
3. Stop using the default watchers (`aw-watcher-window` and `aw-watcher-afk`).
4. Keep `aw-server` as the backend.
5. Install the GNOME extension **Focused Window D-Bus**.
6. Install **`aw-awatcher`** as the Wayland-compatible replacement.
7. Use custom `start.sh` / `kill.sh` scripts and a GNOME autostart entry.

---

## Environment

```text
Static hostname: PT315-52
Icon name: computer-laptop
Chassis: laptop 💻
Machine ID: ****
Boot ID: ****
Operating System: Ubuntu 25.10
Kernel: Linux 6.17.0-19-generic
Architecture: x86-64
Hardware Vendor: Acer
Hardware Model: Predator PT315-52
Firmware Version: V1.09
Firmware Date: Mon 2021-01-04
Firmware Age: 5y 2month 1w 6d
Desktop: GNOME Shell 49.0
Session type: Wayland
```

---

## Original problem

After installing ActivityWatch and launching it, the web UI was available at `http://localhost:5600`, but `aw-watcher-window` kept failing with this error:

```text
Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Authorization required, but no authorization protocol specified\n'
```

Later, when trying a script-based startup with `aw-watcher-afk`, that watcher also failed with the same X11 authorization problem.

So the core pattern was:

- `aw-server` worked.
- the web UI worked.
- the default watchers failed on GNOME + Wayland.

---

## What we verified first

We confirmed the session type:

```bash
echo "$XDG_SESSION_TYPE"
```

Output:

```text
wayland
```

We also checked the GNOME version:

```bash
gnome-shell --version
```

Output:

```text
GNOME Shell 49.0
```

---

## Step 1 - Install ActivityWatch normally

We first installed the regular Linux build exactly as recommended for Linux ZIP installs.

```bash
sudo apt update
sudo apt install -y wget unzip

mkdir -p ~/.local/opt
cd ~/.local/opt

wget -O activitywatch.zip https://github.com/ActivityWatch/activitywatch/releases/download/v0.13.2/activitywatch-v0.13.2-linux-x86_64.zip
unzip -q activitywatch.zip
rm activitywatch.zip

cd activitywatch
./aw-qt
```

At this stage, the web UI became available, but the default watchers were not usable in this GNOME Wayland setup.

---

## Step 2 - Stop the failing default watchers

We stopped the watchers that were flooding the terminal/logs:

```bash
pkill -f aw-watcher-window
pkill -f aw-watcher-window-wayland
ps aux | grep aw-watcher
```

This confirmed that `aw-watcher-window` was no longer running.

---

## Step 3 - Inspect how ActivityWatch was configured

We looked for ActivityWatch-related autostart entries and config files.

### Search autostart-related entries

```bash
grep -RniE '^(Exec|Name|Hidden|X-GNOME-Autostart-enabled)=|aw-qt|aw-watcher-window|aw-watcher-afk|start.sh' \
~/.config/autostart ~/.local/share/applications 2>/dev/null
```

### Check config directory

```bash
ls -R ~/.config/activitywatch 2>/dev/null
```

### Inspect `aw-qt.toml`

```bash
sed -n '1,120p' ~/.config/activitywatch/aw-qt/aw-qt.toml
```

The file contained only commented defaults:

```toml
[aw-qt]
#autostart_modules = ["aw-server", "aw-watcher-afk", "aw-watcher-window"]

[aw-qt-testing]
#autostart_modules = ["aw-server", "aw-watcher-afk", "aw-watcher-window"]
```

---

## Step 4 - Remove the default watchers from `aw-qt`

We replaced the commented defaults with an explicit configuration.

First, we tried keeping only `aw-server` and `aw-watcher-afk`:

```bash
cp ~/.config/activitywatch/aw-qt/aw-qt.toml ~/.config/activitywatch/aw-qt/aw-qt.toml.bak

cat > ~/.config/activitywatch/aw-qt/aw-qt.toml <<'EOF2'
[aw-qt]
autostart_modules = ["aw-server", "aw-watcher-afk"]

[aw-qt-testing]
autostart_modules = ["aw-server", "aw-watcher-afk"]
EOF2
```

But `aw-watcher-afk` also failed under this environment.

So we reduced the configuration to **`aw-server` only**:

```bash
cat > ~/.config/activitywatch/aw-qt/aw-qt.toml <<'EOF2'
[aw-qt]
autostart_modules = ["aw-server"]

[aw-qt-testing]
autostart_modules = ["aw-server"]
EOF2
```

---

## Step 5 - Try GNOME-style script-based startup

Because GNOME/Wayland is a special case, we switched to a script-based startup model.

### First version of `start.sh`

```bash
cat > ~/.local/opt/activitywatch/start.sh <<'EOF2'
#!/bin/bash
cd ~/.local/opt/activitywatch
pkill -f aw-watcher-window 2>/dev/null
pkill -f aw-watcher-afk 2>/dev/null
pkill -f '/aw-server/aw-server' 2>/dev/null
./aw-server/aw-server >/tmp/aw-server.log 2>&1 &
EOF2
```

### First version of `kill.sh`

```bash
cat > ~/.local/opt/activitywatch/kill.sh <<'EOF2'
#!/bin/bash
pkill -f aw-watcher-window
pkill -f aw-watcher-afk
pkill -f '/aw-server/aw-server'
EOF2

chmod +x ~/.local/opt/activitywatch/start.sh ~/.local/opt/activitywatch/kill.sh
```

### Test

```bash
~/.local/opt/activitywatch/kill.sh
~/.local/opt/activitywatch/start.sh
sleep 2
ps aux | grep -E 'aw-server|aw-watcher-afk|aw-watcher-window' | grep -v grep
```

Result: `aw-server` stayed up, but the default watchers remained unusable.

---

## Step 6 - Confirm `aw-watcher-afk` also fails on this setup

When we tried starting `aw-watcher-afk`, we inspected its log:

```bash
cat /tmp/aw-watcher-afk.log 2>/dev/null || echo "no hay log"
```

The relevant error was again an X11 display connection problem:

```text
ImportError: this platform is not supported: ('failed to acquire X connection: Can\'t connect to display ":0": b\'Authorization required, but no authorization protocol specified\\n\'', DisplayConnectionError(':0', b'Authorization required, but no authorization protocol specified\n'))
```

At that point we concluded that, in this particular GNOME Wayland setup, the stable path was:

- keep `aw-server`
- replace the default watchers entirely

---

## Step 7 - Install the required GNOME extension

We installed the **Focused Window D-Bus** GNOME extension, then verified that it was present.

```bash
gnome-extensions list
```

Relevant output:

```text
focused-window-dbus@flexagoon.com
```

This extension is required by `awatcher` for GNOME Wayland focused-window reporting.

---

## Step 8 - Install `aw-awatcher`

We downloaded and installed the ActivityWatch-compatible watcher replacement:

```bash
cd /tmp
wget -O aw-awatcher.zip https://github.com/2e3s/awatcher/releases/download/v0.3.3/aw-awatcher.zip
sudo unzip -o aw-awatcher.zip -d /usr/local/bin
ls -l /usr/local/bin/aw-awatcher*
```

Expected result:

```text
-rwxr-xr-x 1 root root ... /usr/local/bin/aw-awatcher
```

---

## Step 9 - Test `aw-awatcher` manually

We launched it manually first, while keeping `aw-server` running:

```bash
/usr/local/bin/aw-awatcher >/tmp/aw-awatcher.log 2>&1 &
sleep 3
ps aux | grep -E 'aw-awatcher|aw-server' | grep -v grep
```

Then we checked the log:

```bash
cat /tmp/aw-awatcher.log
```

The log was empty, and the process stayed running, which indicated a clean start.

---

## Step 10 - Update the startup scripts to use `aw-awatcher`

We then updated `start.sh` so it would:

- kill the old default watchers
- kill any previous `aw-awatcher` instance
- start `aw-server`
- wait briefly
- start `aw-awatcher`

### Final `start.sh`

```bash
cat > ~/.local/opt/activitywatch/start.sh <<'EOF2'
#!/bin/bash
cd ~/.local/opt/activitywatch
pkill -f aw-watcher-window 2>/dev/null
pkill -f aw-watcher-afk 2>/dev/null
pkill -f aw-awatcher 2>/dev/null
pkill -f '/aw-server/aw-server' 2>/dev/null
./aw-server/aw-server >/tmp/aw-server.log 2>&1 &
sleep 2
/usr/local/bin/aw-awatcher >/tmp/aw-awatcher.log 2>&1 &
EOF2

chmod +x ~/.local/opt/activitywatch/start.sh
```

### Final `kill.sh`

```bash
cat > ~/.local/opt/activitywatch/kill.sh <<'EOF2'
#!/bin/bash
pkill -f aw-watcher-window
pkill -f aw-watcher-afk
pkill -f aw-awatcher
pkill -f '/aw-server/aw-server'
EOF2

chmod +x ~/.local/opt/activitywatch/kill.sh
```

### Final test

```bash
~/.local/opt/activitywatch/kill.sh
~/.local/opt/activitywatch/start.sh
sleep 3
ps aux | grep -E 'aw-server|aw-awatcher|aw-watcher-afk|aw-watcher-window' | grep -v grep
```

Expected result:

- `aw-server` is running
- `aw-awatcher` is running
- `aw-watcher-afk` is not running
- `aw-watcher-window` is not running

---

## Step 11 - Enable autostart on GNOME

Finally, we created a desktop autostart entry:

```bash
mkdir -p ~/.config/autostart

cat > ~/.config/autostart/activitywatch-wayland.desktop <<'EOF2'
[Desktop Entry]
Type=Application
Name=ActivityWatch Wayland
Exec=/home/mateo/.local/opt/activitywatch/start.sh
X-GNOME-Autostart-enabled=true
Terminal=false
EOF2
```

After logout/login or reboot, ActivityWatch should start through `start.sh` and avoid relaunching the unsupported default watchers.

---

## Final state

The stable working configuration on this machine was:

- **ActivityWatch installed normally**
- **`aw-server` kept as backend**
- **default watchers disabled for autostart**
- **GNOME extension `focused-window-dbus@flexagoon.com` installed**
- **`aw-awatcher` installed to `/usr/local/bin`**
- **custom `start.sh` / `kill.sh` used instead of the default watcher startup flow**
- **GNOME autostart entry pointing to `start.sh`**

---

## Why this worked

The root cause appears to be that the default ActivityWatch Linux watchers depend on mechanisms that do not work reliably in this GNOME Wayland setup, while `awatcher` uses a GNOME Wayland-compatible path when the required extension is installed.

In short:

- `aw-server` itself was fine.
- the issue was with the default watchers.
- replacing them with `aw-awatcher` solved the problem.

---

## Sources consulted

- ActivityWatch docs - Getting started
https://docs.activitywatch.net/en/latest/getting-started.html
- ActivityWatch docs - Running on GNOME
https://docs.activitywatch.net/en/latest/running-on-gnome.html
- ActivityWatch docs - FAQ
https://docs.activitywatch.net/en/latest/faq.html
- ActivityWatch docs - Watchers
https://docs.activitywatch.net/en/latest/watchers.html
- ActivityWatch docs - Configuration
https://docs.activitywatch.net/en/latest/configuration.html
- Focused Window D-Bus GNOME extension
https://extensions.gnome.org/extension/5592/focused-window-d-bus/
- `awatcher` repository
https://github.com/2e3s/awatcher

---

**This was posible by the use of OpenAI ChatGPT 5.4 Thinking**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.