Skip to content

Instantly share code, notes, and snippets.

@ervitis
Created February 24, 2018 08:51
Show Gist options
  • Save ervitis/bdcf15be4cd7aea70b9ff34a3657804e to your computer and use it in GitHub Desktop.
Save ervitis/bdcf15be4cd7aea70b9ff34a3657804e to your computer and use it in GitHub Desktop.
Script disable touchscreen
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import subprocess
import re
COMMAND_XINPUT = 'xinput'
ARG_COMMAND_XINPUT_DISABLE = 'disable'
PATTERN_TOUCHSCREEN = 'Touchscreen\s+id=\d+'
PATTERN_TOUCHSCREEN_INPUT_ID = 'id=\d+'
try:
id_xinput = re.findall(PATTERN_TOUCHSCREEN_INPUT_ID, re.findall(PATTERN_TOUCHSCREEN, subprocess.check_output(COMMAND_XINPUT))[0])[0].split('=')[1]
except Exception as e:
print(e)
exit(1)
else:
if id_xinput is None:
print('xinput id not valid')
exit(1)
exit(subprocess.call([COMMAND_XINPUT, ARG_COMMAND_XINPUT_DISABLE, id_xinput]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment