Skip to content

Instantly share code, notes, and snippets.

@hu553in
Created February 10, 2025 08:31
Show Gist options
  • Save hu553in/70f4a1ccef773c849ea8e64339be0224 to your computer and use it in GitHub Desktop.
Save hu553in/70f4a1ccef773c849ea8e64339be0224 to your computer and use it in GitHub Desktop.
Guakify any app on Cinnamon (Linux Mint default)
#!/bin/bash
# This script checks if the given application is already running by looking for its window.
# If it is running (even if minimized), it brings that window to the front.
# Otherwise, it launches a new instance of the application.
#
# Requirements:
# wmctrl (install via: sudo apt-get install wmctrl)
#
# Customize these variables to match your application.
#
# You can find WM class using:
#
# ❯ xprop | grep WM_CLASS
# WM_CLASS(STRING) = "ghostty", "com.mitchellh.ghostty"
APP="ghostty"
WM_CLASS="ghostty.com.mitchellh.ghostty"
# Look for a window with the specified WM_CLASS.
# The -lx option to wmctrl lists windows with extra info including the WM_CLASS.
WIN_ID=$(wmctrl -lx | awk -v wc="$WM_CLASS" '$3 == wc {print $1; exit}')
if [ -n "$WIN_ID" ]; then
# Found a window; bring it to the foreground.
wmctrl -ia "$WIN_ID"
else
# No window found; launch the application.
$APP &
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment