#!/bin/sh active_window="$(xdotool getwindowfocus)" active_class=$(xprop -id "$active_window" WM_CLASS | awk '{print $4}') if [ "$active_class" = '"firefox"' ]; then xdotool windowclose "$active_window" else kill -15 "$(xdotool getwindowfocus getwindowpid)" fi