Skip to content

Instantly share code, notes, and snippets.

@enpinzolas
Last active April 23, 2026 19:29
Show Gist options
  • Select an option

  • Save enpinzolas/7a32ca2765a69f4d96e81eef711f78bc to your computer and use it in GitHub Desktop.

Select an option

Save enpinzolas/7a32ca2765a69f4d96e81eef711f78bc to your computer and use it in GitHub Desktop.
KDE configuration to run alacritty in drop-down mode

This idea is absed on the following snippet for wezterm: https://gitlab.com/-/snippets/4798512

This should work with most terminals, as long as they allow for custom titles or if you don't mind using them only in dropdown mode.

The idea is to create a down rule that forces the window to stay in the position you want, and to create a script using kdotool to execute the terminal if it's not running, and minimize/show it if it's running. The current script is a slightly altered version of @despian's improved version due to personal preference.

This should also work in x11 with minimal changes. I personally like for the terminal to stay on top always, and for the keybind to hide/show it, regardless of my current focus since I work with two monitors and the first press gaining focus when I want to hide it is annoying. In any case, here is the script excerpt in case the snippet link is deleted and that interaction is preferred, this should also work with xdotool:

toggle() {
  WINDOW_ID=$(kdotool search --name "${NAME_WINDOW_SEARCH}")
  ACTIVE_ID=$(kdotool getactivewindow)

  case "${WINDOW_ID}" in
    "")
      dbus-launch ${TERMINAL_BIN} ${ADDITIONAL_ARGS}
      ;;
    "${ACTIVE_ID}")
      echo "Focused->Hidden"
      kdotool windowminimize "${WINDOW_ID}"
      ;;
    *)
      echo "Hidden/Unfocused->Focused"
      kdotool windowactivate "${WINDOW_ID}"
      ;;
  esac
}

We will create several window rules to enforce the positioning of the terminal, ths can be changed to the preference of the user. The only important part is where we define the window title, it must be the same as the one defined in the script. image

Now we only need a keybind that launches the script and it will work. Remember making the script executable too. image

#!/usr/bin/env bash
window_title="AlacrittyDrop"
window_is_minimized() {
local target="$1"
[[ -z "$target" ]] && return 1
kdotool windowstate --is MINIMIZED "$target" >/dev/null 2>&1
}
launch_alacritty() {
# setsid --fork detaches cleanly so the script can exit immediately
setsid -f alacritty --config-file $HOME/.config/alacritty/alacritty_drop.toml -T $window_title >/dev/null 2>&1
local wid=""
# Wait briefly for the new window so we can ensure full width (window rule seemed unreliable here)
for _ in {1..40}; do
wid=$(kdotool search --name "$window_title" 2>/dev/null | head -n1)
if [[ -n "$wid" ]]; then
kdotool windowsize "$wid" 100% y >/dev/null 2>&1
break
fi
sleep 0.05
done
}
toggle() {
window_id=$(kdotool search --name "${window_title}" 2>/dev/null | head -n1)
focused_window=$(kdotool getactivewindow 2>/dev/null | head -n1)
echo $window_id
case "${window_id}" in
"")
# Window not found, launch.
launch_alacritty
;;
*)
if window_is_minimized "${window_id}"; then
# Window minimized, show and focus
kdotool windowactivate "${window_id}"
else
if [[ -n "${focused_window}" && "${window_id}" == "${focused_window}" ]]; then
# Window active and focused, minimize
kdotool windowminimize "${window_id}"
else
# Window active but unfocused, just focus it
kdotool windowactivate "${window_id}"
fi
fi
;;
esac
}
toggle
@despian
Copy link
Copy Markdown

despian commented Nov 23, 2025

Thanks! This was really useful. Though, I ended up writing something different based on your idea.

This supports returning focus if already open and doesn't need the flag file.

#!/usr/bin/env bash

window_class="AlacrittyDrop"

window_is_minimized() {
  local target="$1"
  [[ -z "$target" ]] && return 1
  kdotool windowstate --is MINIMIZED "$target" >/dev/null 2>&1
}

launch_alacritty() {
  # setsid --fork detaches cleanly so the script can exit immediately
  setsid -f alacritty --class "$window_class" >/dev/null 2>&1

  local wid=""
  # Wait briefly for the new window so we can ensure full width (window rule seemed unreliable here)
  for _ in {1..40}; do
    wid=$(kdotool search --class "$window_class" 2>/dev/null | head -n1)
    if [[ -n "$wid" ]]; then
      kdotool windowsize "$wid" 100% y >/dev/null 2>&1
      break
    fi
    sleep 0.05
  done
}

toggle() {
  window_id=$(kdotool search --class "${window_class}" 2>/dev/null | head -n1)
  focused_window=$(kdotool getactivewindow 2>/dev/null | head -n1)

  case "${window_id}" in
    "")
      # Window not found, launch.
      launch_alacritty
      ;;
    *)
      if window_is_minimized "${window_id}"; then
        # Window minimized, show and focus
        kdotool windowactivate "${window_id}"
      else
        if [[ -n "${focused_window}" && "${window_id}" == "${focused_window}" ]]; then
          # Window active and focused, minimize
          kdotool windowminimize "${window_id}"
        else
          # Window active but unfocused, just focus it
          kdotool windowactivate "${window_id}"
        fi
      fi
      ;;
  esac
}

toggle
image

@edouard-lopez
Copy link
Copy Markdown

edouard-lopez commented Feb 16, 2026

Thanks for the script!

I had to explicitly invoke the script with bash /path/to/alacritty-dropdown.bash for it to work on Fedora 43

[Custom Commands][net.local.alacritty-dropdown.bash.desktop]
Exec=bash /path/to/alacritty-dropdown.bash
Name=alacritty-dropdown

Here are the rules for Kde / Kwin (without window decoration):

[Settings for AlacrittyDrop]
Description=Settings for AlacrittyDrop
desktops=\\0
desktopsrule=2
maximizehoriz=true
maximizehorizrule=2
maximizevert=true
maximizevertrule=2
noborder=true
noborderrule=3
position=1829,0
positionrule=2
size=1920,1080
sizerule=2
skippager=true
skippagerrule=2
skipswitcher=true
skipswitcherrule=2
wmclass=AlacrittyDrop
wmclassmatch=1

@enpinzolas
Copy link
Copy Markdown
Author

@despian nice upgrade to avoid the flag file, although I still prefer matching via the window title just because having a proper window class gives the terminal a proper icon on the window overview. I know I know, it's too gnome-y, still like it :P

I've updated the dist code thanks.

@edouard-lopez, invoking the script via shortcut didn't work? My keybind is also "explicitly" invoking the script, technically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment