Skip to content

Instantly share code, notes, and snippets.

@cmj
Created October 25, 2026 20:36
Show Gist options
  • Select an option

  • Save cmj/8f3f0dec464fa4fe7bdc43b5376834ab to your computer and use it in GitHub Desktop.

Select an option

Save cmj/8f3f0dec464fa4fe7bdc43b5376834ab to your computer and use it in GitHub Desktop.
window shading/stretching script, bind to a shortcut
#!/bin/bash
# KDE6 unshade hack.
# Stretch stuck unshaded window to 3/4 of the current screen height, preserve width
win=$(xdotool getactivewindow 2>/dev/null) || exit 0
[ -z "$win" ] && exit 0
# Bail if the "active window" is the root window
root=$(xwininfo -root | awk '/Window id:/{print $4}')
[ "$(printf '0x%x' "$win")" = "$root" ] && exit 0
# Bail if it's the desktop, a panel/dock, etc.
type=$(xprop -id "$win" _NET_WM_WINDOW_TYPE 2>/dev/null)
case "$type" in
*_DESKTOP*|*_DOCK*|*_SPLASH*|*_NOTIFICATION*) exit 0 ;;
esac
resY=$(xdpyinfo | awk '/dimensions/{print $2}' | cut -dx -f2)
newY=$((resY / 4 * 3))
resX=$(xwininfo -id "$win" | sed -En 's/^ *Width: (.*)/\1/p')
[ -z "$resX" ] && exit 0
xdotool windowsize "$win" "$resX" "$newY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment