Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions WayOSK/Indicator.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import Quickshell
import QtQuick

PopupWindow {
id: indicator

anchor.window: root
implicitWidth: 50
implicitHeight: 50
color: "transparent"
visible: true

MouseArea {
anchors.fill: parent
drag.target: null

property real dragOffsetX: 0
property real dragOffsetY: 0
property real startX: 0
property real startY: 0

onPressed: {
startX = indicator.anchor.rect.x
startY = indicator.anchor.rect.y
dragOffsetX = mouse.x
dragOffsetY = mouse.y
}
onPositionChanged: {
indicator.anchor.rect.x = startX + (mouse.x - dragOffsetX)
indicator.anchor.rect.y = startY + (mouse.y - dragOffsetY)
}
onReleased: {
if (startX === indicator.anchor.rect.x && startY === indicator.anchor.rect.y) {
keyboard.visible = !keyboard.visible
}
}
}

Rectangle {
anchors.fill: parent
color: "gray"
radius: 50
opacity: 0.5
}
}
52 changes: 52 additions & 0 deletions WayOSK/Keyboard.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Quickshell
import Quickshell.Io
import QtQuick

PanelWindow {
id: keyboard
exclusionMode: ExclusionMode.Ignore
color: "transparent"
implicitHeight: 400

anchors {
bottom: true
left: true
right: true
}

property var keyRows: [
["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"],
["A", "S", "D", "F", "G", "H", "J", "K", "L"],
["Z", "X", "C", "V", "B", "N", "M"]
]

Socket {
id: keyboardSocket
path: "/tmp/wayosk.sock"
}

Rectangle {
anchors.fill: parent
color: "gray"
opacity: 0.75

Column {
anchors.centerIn: parent
spacing: 8

Repeater {
model: keyRows
delegate: Row {
spacing: 8
Repeater {
model: modelData
delegate: KeyboardKey {
keyValue: modelData
socketConnection: keyboardSocket
}
}
}
}
}
}
}
29 changes: 29 additions & 0 deletions WayOSK/KeyboardKey.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Quickshell.Io
import QtQuick
import QtQuick.Controls

Button {
id: keyButton
property string keyValue: ""
property Socket socketConnection: null

text: keyValue
width: 40
height: 40
font.pixelSize: 20
background: Rectangle {
color: keyButton.down ? "gray" : "lightgray"
border.color: "gray"
radius: 5
}

onClicked: {
if (socketConnection) {
socketConnection.connected = true
socketConnection.write(keyValue)
socketConnection.flush()
} else {
console.error("Socket is not connected")
}
}
}
38 changes: 38 additions & 0 deletions WayOSK/keyboard_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import WayKey as wk
import threading
import socket
import os

class KeyboardServer:
def __init__(self, socket_path: str):
self.socket_path = socket_path
self.server = None
self.thread = None
self.start_server()

def start_server(self):
if os.path.exists(self.socket_path):
os.unlink(self.socket_path)

self.server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.server.bind(self.socket_path)
self.server.listen(1)

self.thread = threading.Thread(target=self.listen_for_keys, daemon=True)
self.thread.start()

def listen_for_keys(self):
while True:
conn, _ = self.server.accept()
with conn:
data = conn.recv(1024).decode("utf-8")
if not data:
continue

wk.click(f"KEY_{data}")

def cleanup(self):
if self.server:
self.server.close()
if os.path.exists(self.socket_path):
os.unlink(self.socket_path)
17 changes: 17 additions & 0 deletions WayOSK/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from keyboard_server import KeyboardServer
import subprocess
import shutil
import sys
import os

SOCKET_PATH = "/tmp/wayosk.sock"

if shutil.which("quickshell") is None:
sys.exit("Error: 'quickshell' is not installed. Please install it: 'https://quickshell.org/'")

server = KeyboardServer(SOCKET_PATH)

try:
subprocess.run(["quickshell", "-p", f"{os.path.dirname(os.path.abspath(__file__))}/main.qml"])
finally:
server.cleanup()
26 changes: 26 additions & 0 deletions WayOSK/main.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Quickshell

Scope {
PanelWindow {
id: root
exclusionMode: ExclusionMode.Ignore
aboveWindows: false
color: "transparent"

anchors {
top: true
bottom: true
left: true
right: true
}

Indicator {
id: indicator
}

Keyboard {
id: keyboard
visible: false
}
}
}
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ classifiers = [
"Operating System :: POSIX :: Linux",
"Intended Audience :: End Users/Desktop"
]
dependencies = []
dependencies = [
"waykey>=0.1.0",
]
[project.urls]
Source = "https://github.com/Nmstr/WayOsk"
Issues = "https://github.com/Nmstr/WayOsk/issues"
78 changes: 78 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.