File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ # Focus following panel
2+
3+ This is a hyprland specific panel that follows monitor focus using the hyprland
4+ unix socket for events. To run it you will need to be using hyprland.
5+
6+ You can run the panel with ` quickshell -p shell.qml ` .
Original file line number Diff line number Diff line change 1+ import QtQuick
2+ import Quickshell
3+ import Quickshell.Io
4+
5+ ShellRoot {
6+ Socket {
7+ // Create and connect a Socket to the hyprland event socket.
8+ // https://wiki.hyprland.org/IPC/
9+ path: ` /tmp/hypr/${ Quickshell .env (" HYPRLAND_INSTANCE_SIGNATURE" )} /.socket2.sock`
10+ connected: true
11+
12+ parser: SplitParser {
13+ // Regex that will return the newly focused monitor when it changes.
14+ property var regex: new RegExp (" focusedmon>>(.+),.*" );
15+
16+ // Sent for every line read from the socket
17+ onRead : msg => {
18+ const match = regex .exec (msg);
19+
20+ if (match != null ) {
21+ // Filter out the right screen from the list and update the panel.
22+ // match[1] will always be the monitor name captured by the regex.
23+ panel .screen = Quickshell .screens .filter (screen => screen .name == match[1 ])[0 ];
24+ }
25+ }
26+ }
27+ }
28+
29+ // The default screen a panel will be created on under hyprland is the currently
30+ // focused one. We use this since we don't get a focusedmon event on connect.
31+ PanelWindow {
32+ id: panel
33+
34+ anchors {
35+ left: true
36+ top: true
37+ bottom: true
38+ }
39+
40+ Text {
41+ anchors .centerIn : parent
42+ text: " todo"
43+ }
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments