forked from Shinonome/dots-hyprland
layout indicator in top right
This commit is contained in:
@@ -416,6 +416,13 @@ Scope {
|
|||||||
color: rightSidebarButton.colText
|
color: rightSidebarButton.colText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Label {
|
||||||
|
Layout.rightMargin: indicatorsRowLayout.realSpacing
|
||||||
|
text: LayoutService.currentLayout
|
||||||
|
visible: LayoutService.currentLayout !== ""
|
||||||
|
font.pixelSize: Appearance.font.pixelSize.larger - 3
|
||||||
|
color: rightSidebarButton.colText
|
||||||
|
}
|
||||||
MaterialSymbol {
|
MaterialSymbol {
|
||||||
Layout.rightMargin: indicatorsRowLayout.realSpacing
|
Layout.rightMargin: indicatorsRowLayout.realSpacing
|
||||||
text: Network.materialSymbol
|
text: Network.materialSymbol
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell.Hyprland
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: layoutService
|
||||||
|
|
||||||
|
property string currentLayout: "" // This is empty on startup. We could default it to "en", but we don't know the user's configured layout order (e.g. "en,ru" vs "ru,en").
|
||||||
|
// I haven't found a way to query the initial layout from QML without external bash scripts, so this is the safest compromise for now.
|
||||||
|
|
||||||
|
function parseLayout(fullLayoutName) {
|
||||||
|
if (!fullLayoutName) return;
|
||||||
|
|
||||||
|
const shortName = fullLayoutName.substring(0, 2).toLowerCase();
|
||||||
|
|
||||||
|
if (currentLayout !== shortName) {
|
||||||
|
currentLayout = shortName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleRawEvent(event) {
|
||||||
|
if (event.name === "activelayout") {
|
||||||
|
const dataString = event.data;
|
||||||
|
const layoutInfo = dataString.split(",");
|
||||||
|
const fullLayoutName = layoutInfo[layoutInfo.length - 1];
|
||||||
|
|
||||||
|
parseLayout(fullLayoutName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
Hyprland.rawEvent.connect(handleRawEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user