#!/bin/sh

# Since the lock key is Mod4+L, and 'show desktop' is just Mod4, if we just
# issue a lock, we'll both show the desktop and lock.  So here we issue a
# show desktop and lock, thereby showing the desktop twice (or rather, toggling
# 'show desktop' twice to get back to original state).
SHOWING_LINE=$(env LANG=C wmctrl -m | grep "showing the desktop")
if echo "$SHOWING_LINE" | grep OFF; then
  wmctrl -k on
else
  wmctrl -k off
fi

gnome-screensaver-command -l

