Lesson 17 of 19 ↓
- 1.Fedora + Distrobox + Arch + AUR Setup Guide
- 2.Enabling Hibernate on Linux
- 3.A Practical Git Workflow
- 4.Useful Linux Commands & Tips
- 5.Mirroring Your Android Screen with Scrcpy
- 6.Downloading Media with Yt-dlp
- 7.Consistent C/c++ Style with Clang-format
- 8.Auto-mounting Drives at Boot
- 9.Customizing Grub
- 10.Linux Swap Files Explained
- 11.Zram: Compressed Swap in Ram
- 12.Custom App Launch Behavior Via .desktop Files
- 13.Custom Mime Icons in Gnome
- 14.Fixing Missing Dock Icons (startupwmclass)
- 15.Installing Questasim for Hdl Simulation
- 16.Building Python 2 From Source
- 17.Auto-Starting WhatsApp and Telegram (Minimized or Tray)
- 18.Custom Neovim Configuration Guide
- 19.Running Windows Applications on Linux Seamlessly with WinBoat (Docker)
2 min read
Auto-Starting WhatsApp and Telegram (Minimized or Tray)
Many daily applications don't natively support starting minimized to the system tray on Linux desktop startup. This guide shows how to set up autostart for the Flatpak versions of WhatsApp and Telegram, detailing how to script window closing with wmctrl and utilize native start-hidden flags.
Since WhatsApp's Flatpak does not have a native --start-in-tray or --minimized flag, we can work around this by launching it normally and using wmctrl to programmatically close the window immediately after launch. In most desktop environments, closing the main window of a messaging app keeps it running in the background/system tray.
Step 1: Install wmctrl
wmctrl is a CLI tool that interacts with an EWMH/NetWM compatible X Window Manager. Install it using your package manager:
sudo apt update && sudo apt install -y wmctrlStep 2: Create a Launch Script
Create a simple shell script to launch WhatsApp, wait for it to start, and then tell the window manager to close its window.
nvim ~/.local/bin/whatsapp-hidden.shAdd the following content:
#!/bin/bash
# Launch WhatsApp Desktop via Flatpak in the background
flatpak run io.github.mimbrero.WhatsAppDesktop &
# Wait a couple of seconds for the window to render
sleep 2
# Close the window gracefully (keeps it in the tray)
wmctrl -c "WhatsApp"Make the script executable:
chmod +x ~/.local/bin/whatsapp-hidden.shStep 3: Create an Autostart Entry
To run this script automatically when you log in, create a .desktop file in your user's autostart directory:
nvim ~/.config/autostart/whatsapp.desktopAdd the following configuration:
[Desktop Entry]
Type=Application
Name=WhatsApp (Hidden)
Exec=/home/abdallah-shehawey/.local/bin/whatsapp-hidden.sh
X-GNOME-Autostart-enabled=true
Hidden=false
NoDisplay=false
X-GNOME-Autostart-Delay=2Make the desktop entry executable:
chmod +x ~/.config/autostart/whatsapp.desktopAlternative: Using Native Flags (if supported)
If the Flatpak wrapper or electron client updates to support hidden startup, you can skip the helper script entirely and edit your whatsapp.desktop directly:
[Desktop Entry]
Type=Application
Name=WhatsApp (Hidden)
Exec=flatpak run io.github.mimbrero.WhatsAppDesktop --start-hidden
X-GNOME-Autostart-enabled=true
Hidden=false
NoDisplay=false
X-GNOME-Autostart-Delay=2🔵 Telegram
Unlike WhatsApp, Telegram has built-in support for starting minimized in the system tray, making it much easier to configure.
Step 1: Create the Telegram Autostart Entry
Create a desktop entry directly in the autostart folder:
nvim ~/.config/autostart/telegram.desktopStep 2: Configure with the -startintray Flag
Add the configuration, using the -startintray parameter in the execution line:
[Desktop Entry]
Type=Application
Name=Telegram (Flatpak)
Exec=flatpak run org.telegram.desktop -startintray
X-GNOME-Autostart-enabled=true
Hidden=false
NoDisplay=falseMake the file executable:
chmod +x ~/.config/autostart/telegram.desktop
Comments
Loading the discussion…