Skip to content

Execute on resize

Rmpc provides on_resize property in the config file which can be used to run a command whenever the rmpc resizes.

The usual environmental variables are available to the script with addition of:

  • $PID - intended for use with the remote command and allows it to target specific rmpc instance
  • $COLS - columns of the new size
  • $ROWS - rows of the new size

This can be used to for example change your theme on the fly when rmpc is resized.

Save the following script to for example ~/.config/rmpc/scripts/onresize.

#!/usr/bin/env bash
if [[ $COLS -gt 100 ]]; then
rmpc remote --pid "$PID" set theme ~/.config/rmpc/themes/big.ron
rmpc remote --pid "$PID" status "Big theme set"
else
rmpc remote --pid "$PID" set theme ~/.config/rmpc/themes/small.ron
rmpc remote --pid "$PID" status "Small theme set"
fi

then put following into your config:

on_resize: ["~/.config/rmpc/scripts/onresize"],