Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Configure a Wacom tablet for use with a single screen and Touch disabled
#!/usr/bin/env python3
"""Configure a Wacom tablet for use with a single screen and Touch disabled"""
import subprocess
def main():
screens = [s for s in get_selector_next(
# Choose screen to focus on
selection = ""
while not selection.isdigit():
for i in range(len(screens)):
print(f"[{i}]: {screens[i]}")
selection = input("Select a focus screen: ")
# Set settings
for id in get_selector_next(
subprocess.check_output(["xsetwacom", "--list"]).decode("UTF8"),
):["xsetwacom", "set", id, "touch", "off"])["xsetwacom", "set", id, "MapToOutput", screens[int(selection)]])
def get_selector_next(p_str, sel, skip=None):
"""Returns the value following a selector in a process output string
@param p_str String to search within; intended for subprocess output but not exclusive
@param sel String to search for, returning the item that follows
@param skip List of strings to skip before the item to return
@return The item in a string following sel
next_index = False
for x in p_str.split():
if x == sel:
next_index = True
if next_index is True:
if skip is not None and x in skip:
next_index = False
yield x
next_index = False
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment