Jun 12, 2020

My cat Lenora is constantly blocking my screen. I swear it’s a game to her. She’s exceptionally skilled at moving in front of whichever monitor I’m trying to look at, even if I move windows to different monitors.

To get around this I use a couple of very simple bash scripts I’ve linked to keyboard shortcuts. One rolls the active window up to a narrow band on my monitor that’s higher up than she can block, and the other rolls it back down again once she gives up.

cat blocking the screen

If you have Linux and cats in your life, you can do the same! I’ll gloss over the Ubuntu way here, but it’s almost the same with any distro.

The Scripts

First, install wmctrl with sudo apt install wmctrl, then create the following scripts somewhere. Edit HEIGHT to equal the approximate pixels between the top of your monitor and the top of your cat.

#!/bin/bash
HEIGHT=500

# remove active window's vertical maximization property
wmctrl -r :ACTIVE: -b remove,maximized_vert
# resize active window, ignoring everything but height
wmctrl -r :ACTIVE: -e 0,-1,-1,-1,$HEIGHT
#!/bin/bash

# restore active window's vertical maximization
wmctrl -r :ACTIVE: -b add,maximized_vert

Next, with those scripts saved, make them each executable with chmod +x <path to script>.

Last, add two custom keyboard shortcuts under your operating system’s settings. Name them anything and point them at the scripts you saved as their action. For the shortcuts themselves, I like to use Alt+Page Up and Alt+Page Down, but you can use anything.

keyboard shortcuts dialog window

Now if only there could be a Bash script to make my headset look less like a chew toy.

Lenora chewing on a microphone
Fork me on GitHub