mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-12-14 19:12:04 +08:00
调整目录
This commit is contained in:
59
helper/tools/add_hotkeys
Executable file
59
helper/tools/add_hotkeys
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python3
|
||||
# vim: set ts=4 sw=4 fileencoding=utf-8:
|
||||
# Luomio <nohappiness@gmail.com>
|
||||
# Filename: dde-first-run.py
|
||||
# Create Date: 27-03, 13
|
||||
|
||||
from os import path, rename, remove
|
||||
import locale
|
||||
import subprocess
|
||||
import os
|
||||
import shutil
|
||||
import json
|
||||
import math
|
||||
import dbus
|
||||
|
||||
_action = "/opt/deepinwine/tools/sendkeys.sh"
|
||||
|
||||
def system_screenshot_isA():
|
||||
bus = dbus.SessionBus()
|
||||
keybinding = bus.get_object("com.deepin.daemon.Keybinding", "/com/deepin/daemon/Keybinding")
|
||||
keybinding_iface = dbus.Interface(keybinding, dbus_interface='com.deepin.daemon.Keybinding')
|
||||
|
||||
obj = json.loads(keybinding_iface.List())
|
||||
for i in range(len(obj)):
|
||||
if obj[i]['Id'] == "screenshot":
|
||||
if '<Control><Alt>A' in obj[i]['Accels']:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def add_qq_shortcut(_name, _key, _short_cut):
|
||||
if path.exists(_action):
|
||||
bus = dbus.SessionBus()
|
||||
keybinding = bus.get_object("com.deepin.daemon.Keybinding", "/com/deepin/daemon/Keybinding")
|
||||
keybinding_iface = dbus.Interface(keybinding, dbus_interface='com.deepin.daemon.Keybinding')
|
||||
|
||||
obj = json.loads(keybinding_iface.List())
|
||||
for i in range(len(obj)):
|
||||
if obj[i]['Name'] == _name:
|
||||
keybinding_iface.Delete(obj[i]['Id'], obj[i]['Type'])
|
||||
|
||||
_, ok = keybinding_iface.Add(_name, _action+_key, _short_cut)
|
||||
if ok == False:
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
_action = os.path.realpath(os.path.dirname(sys.argv[0]))
|
||||
_action = os.path.join(_action, "sendkeys.sh")
|
||||
|
||||
if len(sys.argv) < 4:
|
||||
add_qq_shortcut(u"提取QQ消息", " z", "<Control><Alt>Z")
|
||||
if system_screenshot_isA():
|
||||
add_qq_shortcut(u"QQ截图", " a", "<Control><Alt>S")
|
||||
else:
|
||||
add_qq_shortcut(u"QQ截图", " a", "<Control><Alt>A")
|
||||
sys.exit(0)
|
||||
|
||||
add_qq_shortcut(str(sys.argv[1]), sys.argv[2], sys.argv[3])
|
||||
Reference in New Issue
Block a user