diff options
Diffstat (limited to 'desktop/island')
| -rw-r--r-- | desktop/island/Keyboard.qml | 61 | ||||
| -rw-r--r-- | desktop/island/assets/burger.svg | 10 | ||||
| -rw-r--r-- | desktop/island/assets/flag-it.svg | 7 |
3 files changed, 78 insertions, 0 deletions
diff --git a/desktop/island/Keyboard.qml b/desktop/island/Keyboard.qml new file mode 100644 index 0000000..1cbe9bc --- /dev/null +++ b/desktop/island/Keyboard.qml @@ -0,0 +1,61 @@ +// Copyright (C) 2026 Danilo M. <danix@danix.xyz> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +pragma Singleton + +import Quickshell +import Quickshell.Io +import Quickshell.Hyprland +import QtQuick +import "Logic.js" as Logic + +// The layout of whichever keyboard Hyprland marks main. Resolved per event, +// never cached: the same keyboard is a different device over USB and over +// its dongle, which is what broke wb-lang's hardcoded device name. +Singleton { + id: root + + property string keymap: "" + readonly property string flag: Logic.flagFor(keymap) + + readonly property string mainKeyboard: + "hyprctl devices -j | jq -r '.keyboards[] | select(.main) | .name'" + + Process { + id: query + running: true + command: ["sh", "-c", + "hyprctl devices -j | jq -r '.keyboards[] | select(.main) | .active_keymap'"] + stdout: StdioCollector { onStreamFinished: root.keymap = text.trim() } + } + + Process { id: switcher } + + function refresh() { + query.running = false; + query.running = true; + } + + // dir is "next" or "prev", from the caller's own literal, never user text. + function cycle(dir) { + switcher.command = ["sh", "-c", + `hyprctl switchxkblayout "$(${root.mainKeyboard})" ${dir}`]; + switcher.running = false; + switcher.running = true; + } + + Connections { + target: Hyprland + function onRawEvent(event) { + if (event.name === "activelayout") root.refresh(); + } + } +} diff --git a/desktop/island/assets/burger.svg b/desktop/island/assets/burger.svg new file mode 100644 index 0000000..a424979 --- /dev/null +++ b/desktop/island/assets/burger.svg @@ -0,0 +1,10 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"> + <!-- Hamburger, from Twemoji (CC-BY 4.0, twitter/twemoji). + Stands in for the English keyboard layout, restoring the emoji the + stock bar used. It is an image rather than an emoji glyph because the + language module takes a path, not text. + + The root <svg> stays the FIRST thing in this file: gdk-pixbuf sniffs + the opening bytes for "<svg" to pick its loader, so a comment before + the root tag makes every consumer report an unrecognised format on + perfectly valid XML. --><path fill="#D99E82" d="M18 20.411c-9.371 0-16.967-.225-16.967 6.427C1.033 33.487 8.629 35 18 35c9.371 0 16.967-1.513 16.967-8.162 0-6.651-7.596-6.427-16.967-6.427z"/><path fill="#662113" d="M34.47 20.916S26.251 19.932 18 19.89c-8.251.042-16.47 1.026-16.47 1.026C.717 27.39 7.467 30.057 18 30.057s17.283-2.667 16.47-9.141z"/><path fill="#FFCC4D" d="m33.886 18.328-31.855.646c-1.1 0-2.021 2.229-.854 2.812 8.708 2.708 15.708 5.448 15.708 5.448.962.532 1.287.534 2.25.003 0 0 9.666-3.868 15.875-5.493.881-.23-.025-3.416-1.124-3.416z"/><path fill="#77B255" d="M34.725 18.412c-1.9-1.751-1.79-.819-3.246-1.23-.553-.156-4.51-5.271-13.529-5.271h-.02c-9.019 0-12.976 5.115-13.529 5.271-1.456.411-1.346-.521-3.246 1.23-.872.804-1.108 1.222-.188 1.43 1.386.313 1.26 1.152 2.253 1.444 1.202.353 1.696-.292 3.634-.028 1.653.225 1.761 2.369 3.429 2.369s1.668-.8 3.335-.8 2.653 2.146 4.321 2.146 2.653-2.146 4.321-2.146c1.668 0 1.668.8 3.335.8 1.668 0 1.776-2.144 3.429-2.369 1.938-.263 2.433.381 3.634.028.993-.292.867-1.13 2.253-1.444.922-.207.687-.626-.186-1.43z"/><path fill="#DD2E44" d="M34.077 16.52c0 2.984-7.198 4.393-16.077 4.393S1.923 19.504 1.923 16.52c0-5.403.966-5.403 16.077-5.403s16.077.001 16.077 5.403z"/><path fill="#D99E82" d="M18 .524C8.629.524 1.033 4.915 1.033 11.566c0 6.125 7.596 6.375 16.967 6.375s16.967-.25 16.967-6.375C34.967 4.914 27.371.524 18 .524z"/><path fill="#FFE8B6" d="M10.784 3.695a1.069 1.069 0 1 0-1.152 1.802c.498.319 1.76.557 2.079.059.318-.498-.429-1.543-.927-1.861zm9.734-1.035c-.562.182-1.549 1.006-1.366 1.568.183.562 1.464.648 2.026.466a1.069 1.069 0 0 0-.66-2.034zm10.909 7.035c-.452-.38-1.585.225-1.966.677a1.07 1.07 0 0 0 1.638 1.376c.381-.453.781-1.673.328-2.053zm-3.643-5a1.07 1.07 0 0 0-1.152 1.803c.498.319 1.76.557 2.078.059.319-.499-.428-1.544-.926-1.862zm-15 7a1.07 1.07 0 0 0-1.478.326 1.068 1.068 0 0 0 .326 1.476c.498.319 1.76.558 2.078.059.319-.498-.428-1.543-.926-1.861zm3.046-4.808c-.336.486-.62 1.739-.133 2.075.486.336 1.557-.374 1.893-.86a1.07 1.07 0 0 0-1.76-1.215zm7.954 4.808a1.07 1.07 0 0 0-1.478.326 1.068 1.068 0 0 0 .326 1.476c.498.319 1.76.558 2.078.059.319-.498-.428-1.543-.926-1.861zM4.948 7.808c-.394.441-.833 1.648-.392 2.042.439.394 1.591-.174 1.985-.615a1.07 1.07 0 1 0-1.593-1.427z"/></svg> diff --git a/desktop/island/assets/flag-it.svg b/desktop/island/assets/flag-it.svg new file mode 100644 index 0000000..20a8bfd --- /dev/null +++ b/desktop/island/assets/flag-it.svg @@ -0,0 +1,7 @@ +<svg xmlns="http://www.w3.org/2000/svg" id="flag-icons-it" viewBox="0 0 640 480"> + <g fill-rule="evenodd" stroke-width="1pt"> + <path fill="#fff" d="M0 0h640v480H0z"/> + <path fill="#009246" d="M0 0h213.3v480H0z"/> + <path fill="#ce2b37" d="M426.7 0H640v480H426.7z"/> + </g> +</svg> |
