Skip to content

Commit

Permalink
- Added proof of concept script and function for wayland and Gnome3
Browse files Browse the repository at this point in the history
  • Loading branch information
rbreaves committed Oct 29, 2020
1 parent c3083ff commit 2a8dd0e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 10 additions & 0 deletions monitor-win.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

while sleep 1
do
gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\)[`gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\).findIndex\(a\=\>a.meta_window.has_focus\(\)===true\) | cut -d"'" -f 2`].get_meta_window\(\).get_wm_class\(\) | cut -d'"' -f 2 > /tmp/active_win
done

# gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\).findIndex\(a\=\>a.meta_window.has_focus\(\)===true\) | cut -d"'" -f 2

# gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.freedesktop.DBus.Properties.Get org.gnome.Shell ShellVersion
2 changes: 2 additions & 0 deletions xkeysnail/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from evdev import ecodes
from evdev.uinput import UInput
from .key import Action, Combo, Modifier
import time

__author__ = 'zh'

Expand Down Expand Up @@ -66,6 +67,7 @@ def send_event(event):
def send_key_action(key, action):
update_modifier_key_pressed(key, action)
update_pressed_keys(key, action)
time.sleep(0.04)
_uinput.write(ecodes.EV_KEY, key, action)
send_sync()

Expand Down
5 changes: 3 additions & 2 deletions xkeysnail/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import Xlib.display


# def get_active_window_wm_class(display=Xlib.display.Display()):
# """Get active window's WM_CLASS"""
# current_window = display.get_input_focus().focus
Expand All @@ -24,7 +23,9 @@
# return ""

def get_active_window_wm_class():
return "Sublime_text"
with open('/tmp/active_win', 'r') as file:
title = file.read().replace('\n', '')
return title

def get_class_name(window):
"""Get window's class name (recursively checks parents)"""
Expand Down

0 comments on commit 2a8dd0e

Please sign in to comment.