Created
August 29, 2016 00:23
-
-
Save BrettMayson/76fbb73863eccc25eae6e1a6b4873bf8 to your computer and use it in GitHub Desktop.
CAUTION: USE XINPUT TO FIND YOUR DEVICE'S IDS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use "xinput" to find your device's ids | |
My output looks like this | |
Virtual core pointer id=2 [master pointer (3)] | |
↳ Virtual core XTEST pointer id=4 [slave pointer (2)] | |
↳ ELAN1200:00 04F3:301A Touchpad id=10 [slave pointer (2)] | |
↳ FTSC1000:00 2808:5112 id=11 [slave pointer (2)] | |
Virtual core keyboard id=3 [master keyboard (2)] | |
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)] | |
↳ Power Button id=6 [slave keyboard (3)] | |
↳ Video Bus id=7 [slave keyboard (3)] | |
↳ Sleep Button id=8 [slave keyboard (3)] | |
↳ USB2.0 HD UVC WebCam id=9 [slave keyboard (3)] | |
↳ Asus WMI hotkeys id=12 [slave keyboard (3)] | |
↳ AT Translated Set 2 keyboard id=13 [slave keyboard (3)] | |
I added "python3 convertible.py" to my startup programs to have it run when I log in. Rebooting will enable your trackpad and keyboard again. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gi.repository import Gtk | |
import os | |
KEYBOARD = 13 | |
MASTERKEY = 3 | |
TRACKPAD = 10 | |
MASTERTRACK = 2 | |
def disableKeyboard(): | |
os.system("xinput float "+str(KEYBOARD)) | |
os.system("xinput float "+str(TRACKPAD)) | |
def enableKeyboard(): | |
os.system("xinput reattach "+str(KEYBOARD)+" "+str(MASTERKEY)) | |
os.system("xinput reattach "+str(TRACKPAD)+" "+str(MASTERTRACK)) | |
DISPLAY = "eDP1" | |
def rotate(direction): | |
os.system("xrandr --output "+DISPLAY+" --rotate "+direction) | |
class IconoTray: | |
def __init__(self, iconname): | |
self.menu = Gtk.Menu() | |
APPIND_SUPPORT = 1 | |
try: from gi.repository import AppIndicator3 | |
except: APPIND_SUPPORT = 0 | |
if APPIND_SUPPORT == 1: | |
self.ind = AppIndicator3.Indicator.new("2in1", iconname, AppIndicator3.IndicatorCategory.APPLICATION_STATUS) | |
self.ind.set_status (AppIndicator3.IndicatorStatus.ACTIVE) | |
self.ind.set_menu(self.menu) | |
else: | |
self.myStatusIcon = Gtk.StatusIcon() | |
self.myStatusIcon.set_from_icon_name(iconname) | |
self.myStatusIcon.connect('popup-menu', self.right_click_event_statusicon) | |
def add_menu_item(self, command, title): | |
aMenuitem = Gtk.MenuItem() | |
aMenuitem.set_label(title) | |
aMenuitem.connect("activate", command) | |
self.menu.append(aMenuitem) | |
self.menu.show_all() | |
def add_seperator(self): | |
aMenuitem = Gtk.SeparatorMenuItem() | |
self.menu.append(aMenuitem) | |
self.menu.show_all() | |
def get_tray_menu(self): | |
return self.menu | |
#test/debug stuff below here | |
def main(): | |
app = IconoTray("input-keyboard") | |
app.add_menu_item(lambda x: disableKeyboard(), "Tablet Mode") | |
app.add_menu_item(lambda x: enableKeyboard(), "Laptop Mode") | |
app.add_seperator() | |
app.add_menu_item(lambda x: rotate("normal"),"Normal") | |
app.add_menu_item(lambda x: rotate("inverted"),"Inverted") | |
app.add_menu_item(lambda x: rotate("left"),"Left") | |
app.add_menu_item(lambda x: rotate("right"),"Right") | |
if __name__ == '__main__': | |
Gtk.main() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment