Created
May 26, 2022 14:49
-
-
Save ShikiOkasaka/d4ffc20332bb61fc2b342a81a3978678 to your computer and use it in GitHub Desktop.
This code doen't work on Wayland for getting Capslock state.
This file contains hidden or 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/python3 | |
import gi | |
gi.require_version('Gdk', '4.0') | |
gi.require_version('Gtk', '4.0') | |
from gi.repository import Gtk, Gdk, GLib, GObject | |
def on_keyboard_notify(keyboard, data): | |
print(keyboard.get_caps_lock_state()) | |
def main(): | |
display = Gdk.Display.get_default() | |
seat = display.get_default_seat() | |
keyboard = seat.get_keyboard() | |
print(keyboard.get_caps_lock_state()) | |
keyboard.connect('notify::caps-lock-state', on_keyboard_notify) | |
loop = GLib.MainLoop() | |
loop.run() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment