Last active
February 16, 2016 17:02
-
-
Save fernandotakai/dc14096f8d4f706b3f42 to your computer and use it in GitHub Desktop.
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
echo "set_wallpaper()" | awesome-client |
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
[Unit] | |
Description=Display monitor | |
[Service] | |
ExecStart=/home/ftakai/bin/monitor-display | |
[Install] | |
WantedBy=default.target |
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
#!/usr/bin/python2 | |
import glib | |
from pyudev import Context, Monitor | |
from pyudev.glib import GUDevMonitorObserver as MonitorObserver | |
def device_event(observer, action, device): | |
command = "/usr/bin/xrandr -d :0 --output DP1 --auto --left-of LVDS1 --primary".split(" ") | |
glib.spawn_async(command) | |
command = "/home/ftakai/bin/change_wallpaper".split(" ") | |
glib.spawn_async(command) | |
context = Context() | |
monitor = Monitor.from_netlink(context) | |
monitor.filter_by(subsystem='drm') | |
observer = MonitorObserver(monitor) | |
observer.connect('device-event', device_event) | |
monitor.start() | |
glib.MainLoop().run() |
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
#!/usr/bin/python2 | |
import glib | |
from pyudev import Context, Monitor | |
from pyudev.glib import GUDevMonitorObserver as MonitorObserver | |
DEVICE_MODEL =u'Realforce_87' | |
def swapcaps(action): | |
command = ['/usr/bin/setxkbmap', '-display', ':0', 'us', 'mac'] | |
if action == 'remove': | |
command.append('-option') | |
command.append('ctrl:swapcaps') | |
glib.spawn_async(command) | |
def device_event(observer, action, device): | |
if device['ID_MODEL'] != DEVICE_MODEL: | |
return | |
swapcaps(device.action) | |
context = Context() | |
monitor = Monitor.from_netlink(context) | |
monitor.filter_by(subsystem='usb', device_type='usb_device') | |
observer = MonitorObserver(monitor) | |
observer.connect('device-event', device_event) | |
monitor.start() | |
if not list(context.list_devices(ID_MODEL=DEVICE_MODEL, device_type='usb_device')): | |
swapcaps('remove') | |
else: | |
swapcaps('add') | |
glib.MainLoop().run() |
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
[Unit] | |
Description=USB keyboard monitor | |
[Service] | |
ExecStart=/home/ftakai/bin/monitor-usb | |
[Install] | |
WantedBy=default.target |
Author
fernandotakai
commented
Feb 16, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment