This is what I have done cause I can't figure out how to use the dbus library This script polls my mouse's DPI for when it gets changed by the button on the mouse and sets it to something usable then prints the current DPI to a KDE widget but I am using the subprocess library cause I can't figure out how to use the dbus library
#!/usr/bin/env python3
from openrazer.client import DeviceManager
from time import sleep
from subprocess import run as call
from sys import argv
if len(argv) == 1:
print("No DIY bar ID given!")
quit()
ID='/id_'+argv[1]
dev=DeviceManager().devices[0]
l_out=0
while True:
if not dev:
sleep(3)
if DeviceManager().devices[0]:
dev=DeviceManager().devices[0]
continue;
dpi=dev.dpi
if dpi[0] == dpi[1]:
if dpi[0] == 1800:
dev.dpi=(900,900)
elif dpi[0] == 4500:
dev.dpi=(1000,1000)
elif dpi[0] == 9000:
dev.dpi=(1100,1100)
elif dpi[0] == 16000:
dev.dpi=(1200,1200)
out=str(dev.dpi[0])
else:
out=str(dpi[0])+','+str(dpi[1])
if not l_out == out:
call(['qdbus','org.kde.plasma.doityourselfbar',ID,'org.kde.plasma.doityourselfbar.pass','|A|<img src="/usr/local/share/icons/diybar/mouse.svg" height="22"/>'+out+' DPI|'+dev.name+'||'])
l_out=out
sleep(0.7)
example shell command
qdbus org.kde.plasma.doityourselfbar /id_10 org.kde.plasma.doityourselfbar.pass '|A|<img src="/usr/local/share/icons/diybar/mouse.svg" height="22"/>900 DPI|Razer DeathAdder Elite||'
I have looked at the documentation for dbus, but i have given up trying to figure it out