kbtogglr

Toggle keyboard on and off.

kbtogglr.main() int[source]

Capture slave and master keyboard IDs.

Determine whether lock-file exists. Create cache directory and lock-file if it does not to signal to program that keyboard is off, otherwise assume that the keyboard is on.

If the keyboard is off then the lock should be acquired.

Toggle on:

  • Run xinput to reattach the keyboard IDs.

  • Send notification to desktop indicating keyboard is enabled.

If the keyboard is on then the lock should not be acquired, either because the keyboard has been toggled on, or the system has been rebooted.

Toggle off:

  • Run xinput to detach the slave ID.

  • Send notification, including off image.

Raises:
  • CommandNotFoundError – Requirement is not installed.

  • RuntimeError – No ID has been returned and the script cannot continue.

Returns:

Exit status.