swadhinbiswas Add bar style presets: 10 themes, live set/cycle over shell IPC, omarchy bar style CLI · 8/24/2026
fe09911
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
import Quickshell
import Quickshell.Hyprland
import Quickshell.Io
import Quickshell.Wayland
import QtQuick
import QtQuick.Layouts
import qs.Commons
import qs.Ui
import "BarModel.js" as BarModel
import "BarStyles.js" as BarStyles
Item {
id: root
// The omarchy-shell host injects omarchyPath from OMARCHY_PATH.
required property string omarchyPath
// Injected by the host shell so bar slots can resolve enabled widgets.
required property var barWidgetRegistry
// Injected by the host shell every time shell.json is reloaded. Holds the
// `bar:` subtree: position, centerAnchor, layout. The host owns file IO;
// the bar just renders whatever it's handed. The bar font follows the
// OS-level fontconfig monospace binding — it is not stored in shell.json.
required property var barConfig
readonly property var barStyle: BarStyles.resolve(barStyleConfig)
readonly property var barStyleConfig: root.barConfig || {}
// Injected by the host shell. Used for shell-wide actions such as opening
// settings and persisting inline widget state.
property var shell: null
// Manifest for the active bar option. Present for custom bars and useful for
// diagnostics; the built-in bar does not otherwise need it.
property var manifest: null
// Mirrors the on-disk `bar-off` flag so the user can hide the bar without
// killing the entire shell. Hidden panels stay mapped but park off-screen
// without an exclusion zone; updated by the FileView watcher further down.
property bool barHidden: false
property string home: Quickshell.env("HOME")
property string stateHome: home + "/.local/state"
property string omarchyConfigDir: home + "/.config/omarchy"
property var fallbackBarConfig: ({
position: "top",
transparent: false,
centerAnchor: "omarchy.clock",
layout: { left: [], center: [], right: [] }
})
property var layoutConfig: fallbackBarConfig.layout
property string centerAnchor: ""
property bool requestedTransparent: false
property bool useTransparentForeground: false
property bool transparent: false
property bool centerSectionHovered: false
// One bar surface exists per monitor and each reports into this count, so a
// pointer crossing from one monitor's bar to another's stays counted however
// the enter and leave interleave. A single shared bool would be left false by
// whichever event landed last.
property int barHoverCount: 0
// True while the pointer is over any bar, widgets included.
readonly property bool barHovered: barHoverCount > 0
property bool centerSectionRevealHeld: false
property bool centerHoverRevealSuppressed: false
property int barConfigSerial: 0
property string position: "top"
// Resolves through fontconfig at paint time (Style.font.family defaults
// to "monospace"), so changing the system font (via `omarchy-font-set`)
// updates the bar without a reload.
property string fontFamily: Style.font.family
// Bound to the central Color singleton so the bar tracks shell.toml's
// [bar] section. Property names kept for the rest of this file's bindings.
property color themeForeground: Color.bar.text
property color themeContrastForeground: Color.background
property color transparentForeground: Color.bar.text
property color foreground: themeForeground
property color barForeground: useTransparentForeground ? transparentForeground : themeForeground
property bool foregroundAnimationEnabled: true
property color background: Color.bar.background
// ---- Bar style system (presets from BarStyles.js) ----
function styleColorToken(name) {
if (!name || name === "none") return "transparent"
switch (name) {
case "accent": return Color.accent
case "foreground": return root.foreground
case "background": return Color.background
case "barBackground": return Color.bar.background
case "barText": return Color.bar.text
case "selection": return Color.selection
case "muted": return Color.muted
default: return name
}
}
readonly property var style: ({
floatM: root.barStyle.float ? root.barStyle.margin : 0,
radius: root.barStyle.radius || 0,
bgAlpha: root.barStyle.bgAlpha,
gradient: root.barStyle.gradient,
islands: root.barStyle.islands,
islandGap: root.barStyle.islandGap,
islandPad: root.barStyle.islandPadding,
borderWidth: root.barStyle.borderWidth,
borderColor: styleColorToken(root.barStyle.borderColor),
underline: root.barStyle.underline
})
readonly property color surfaceColor: {
var base = root.background
var a = root.style.bgAlpha === null ? Color.bar.background.a : root.style.bgAlpha
return Qt.rgba(base.r, base.g, base.b, a)
}
property color urgent: Color.bar.active
Behavior on barForeground { enabled: root.foregroundAnimationEnabled; ColorAnimation { duration: 420; easing.type: Easing.InOutCubic } }
Behavior on background { ColorAnimation { duration: 420; easing.type: Easing.InOutCubic } }
Behavior on urgent { ColorAnimation { duration: 420; easing.type: Easing.InOutCubic } }
property var tooltipTarget: null
property var pendingTooltipTarget: null
property string tooltipText: ""
property string pendingTooltipText: ""
property bool tooltipShown: false
property int tooltipRequest: 0
property var activePopout: null
property var barDragSource: null
property var barDragTarget: null
property var barDragTargetGeometry: null
property bool barDragAfter: false
property var barDragWindow: null
property var barDragScreen: null
property url barDragImageUrl: ""
property real barDragSceneX: 0
property real barDragSceneY: 0
property real barDragScreenX: 0
property real barDragScreenY: 0
property real barDragOffsetX: 0
property real barDragOffsetY: 0
property bool barMoveActive: false
property string barMoveCandidate: ""
property var barMoveWindow: null
property var barMoveScreen: null
property var clickTargets: []
property var moduleSlots: []
function registerClickTarget(target) {
if (!target || clickTargets.indexOf(target) !== -1) return
var next = clickTargets.slice()
next.push(target)
clickTargets = next
}
function unregisterClickTarget(target) {
var next = clickTargets.filter(function(item) { return item !== target })
clickTargets = next
}
function registerModuleSlot(slot) {
if (!slot || moduleSlots.indexOf(slot) !== -1) return
var next = moduleSlots.slice()
next.push(slot)
moduleSlots = next
}
function unregisterModuleSlot(slot) {
var next = moduleSlots.filter(function(item) { return item !== slot })
moduleSlots = next
}
function debugBarGeometry() {
var out = []
for (var i = 0; i < moduleSlots.length; i++) {
var slot = moduleSlots[i]
if (!slot || !slot.activeItem) continue
var point = { x: slot.x, y: slot.y }
try {
point = slot.mapToItem(null, 0, 0)
} catch (e) {
}
out.push({
id: slot.moduleName,
section: slot.region,
x: Math.round(point.x),
y: Math.round(point.y),
width: Math.round(slot.width),
height: Math.round(slot.height),
visible: slot.visible === true && slot.width > 0 && slot.height > 0,
itemVisible: slot.activeItem.visible === true,
itemWidth: Math.round(slot.activeItem.implicitWidth || 0),
itemHeight: Math.round(slot.activeItem.implicitHeight || 0)
})
}
return out
}
function targetWindow(target) {
return target && target.QsWindow ? target.QsWindow.window : null
}
function targetBelongsToWindow(target, window) {
return !!target && !!window && targetWindow(target) === window
}
function slotWindow(slot) {
if (!slot) return null
return targetWindow(slot.activeItem) || targetWindow(slot)
}
function sameWindow(left, right) {
if (!left || !right) return false
if (left === right) return true
return !!left.screen && !!right.screen && !!left.screen.name && !!right.screen.name && left.screen.name === right.screen.name
}
function targetTooltipHovered(target) {
return !!target && target.visible !== false && target.opacity !== 0 && target.tooltipHovered === true
}
function clearTooltip() {
tooltipTimer.stop()
pendingTooltipTarget = null
pendingTooltipText = ""
tooltipTarget = null
tooltipText = ""
tooltipShown = false
}
function clearBarDrag() {
barDragSource = null
barDragWindow = null
barDragScreen = null
barDragImageUrl = ""
barDragTarget = null
barDragTargetGeometry = null
barDragAfter = false
barDragSceneX = 0
barDragSceneY = 0
barDragScreenX = 0
barDragScreenY = 0
barDragOffsetX = 0
barDragOffsetY = 0
}
function windowScreenPoint(scenePoint, window) {
var x = scenePoint ? scenePoint.x : 0
var y = scenePoint ? scenePoint.y : 0
if (!window || !window.screen) return { x: x, y: y }
if (root.position === "bottom")
y += Math.max(0, window.screen.height - window.height)
else if (root.position === "right")
x += Math.max(0, window.screen.width - window.width)
return { x: x, y: y }
}
function barDragScreenPoint(scenePoint) {
return windowScreenPoint(scenePoint, barDragWindow)
}
function dropMarkerRect(slot, after) {
if (!slot) return null
try {
var slotPoint = slot.mapToItem(null, 0, 0)
var screenPoint = barDragScreenPoint(slotPoint)
var thickness = Style.spacing.xs
if (vertical) {
return {
x: screenPoint.x,
y: screenPoint.y + (after ? slot.height : 0) - thickness / 2,
width: slot.width,
height: thickness
}
}
return {
x: screenPoint.x + (after ? slot.width : 0) - thickness / 2,
y: screenPoint.y,
width: thickness,
height: slot.height
}
} catch (e) {
return null
}
}
// Split the screen along its diagonals (in normalized space, so widescreens
// don't bias toward left/right): whichever triangle holds the cursor names
// the candidate edge.
function nearestScreenEdge(point, screen) {
var nx = screen.width > 0 ? Util.clamp(point.x / screen.width, 0, 1) : 0.5
var ny = screen.height > 0 ? Util.clamp(point.y / screen.height, 0, 1) : 0.5
var edge = "top"
var best = ny
if (1 - ny < best) { edge = "bottom"; best = 1 - ny }
if (nx < best) { edge = "left"; best = nx }
if (1 - nx < best) { edge = "right"; best = 1 - nx }
return edge
}
function beginBarMove(window) {
barMoveWindow = window
barMoveScreen = window ? window.screen : null
barMoveCandidate = position
barMoveActive = true
}
function updateBarMove(screenPoint) {
if (!barMoveActive || !barMoveScreen) return
barMoveCandidate = nearestScreenEdge(screenPoint, barMoveScreen)
}
function clearBarMove() {
barMoveActive = false
barMoveCandidate = ""
barMoveWindow = null
barMoveScreen = null
}
function finishBarMove() {
var edge = barMoveCandidate
if (!barMoveActive || !edge || edge === position) {
clearBarMove()
return
}
clearBarMove()
setBarPosition(edge)
}
function setBarPosition(value) {
var next = normalizePosition(value)
if (root.shell && typeof root.shell.mutateShellConfig === "function") {
root.shell.mutateShellConfig(function(config) {
if (!Util.isPlainObject(config.bar)) config.bar = {}
config.bar.position = next
})
} else {
root.position = next
}
}
function captureBarDragGhost(slot) {
var item = slot && slot.activeItem ? slot.activeItem : null
barDragImageUrl = ""
if (!item || typeof item.grabToImage !== "function") return
var grabWidth = Math.max(1, Math.ceil(item.width || item.implicitWidth || slot.width || 1))
var grabHeight = Math.max(1, Math.ceil(item.height || item.implicitHeight || slot.height || 1))
item.grabToImage(function(result) {
if (root.barDragSource !== slot || !result || !result.url) return
root.barDragImageUrl = result.url
}, Qt.size(grabWidth, grabHeight))
}
function requestPopout(owner) {
if (activePopout === owner) return
if (activePopout) {
if ("closeForPopoutSwitch" in activePopout) activePopout.closeForPopoutSwitch()
else if ("close" in activePopout) activePopout.close()
}
activePopout = owner
}
function releasePopout(owner) {
if (activePopout === owner) activePopout = null
}
readonly property bool vertical: position === "left" || position === "right"
readonly property int barSize: vertical ? Style.bar.sizeVertical : Style.bar.sizeHorizontal
function normalizePosition(value) {
return BarModel.normalizePosition(value)
}
// Apply tray-pinning on top of the shared layout normalization so the
// bar host and scriptable config helpers can't drift on entry shape.
function normalizeLayout(layout) {
var normalized = Util.normalizeLayout(Util.isPlainObject(layout) ? layout : fallbackBarConfig.layout)
return {
left: pinTrayToInner(normalized.left, "left"),
center: pinTrayToInner(normalized.center, "center"),
right: pinTrayToInner(normalized.right, "right")
}
}
// The tray drawer reveals inward (away from the bar edge). Place it at the
// section's inner edge: start of the right section, end of the left/center
// sections. The drawer's reserved space then sits next to the bar center,
// not stranded mid-section.
function pinTrayToInner(entries, section) {
return BarModel.pinTrayToInner(entries, section)
}
function applyBarConfig() {
var config = Util.isPlainObject(barConfig) ? barConfig : fallbackBarConfig
position = normalizePosition(config.position)
setRequestedTransparency(config.transparent === true)
centerAnchor = Util.canonicalWidgetId(config.centerAnchor || "")
// layoutEntries feeds plain JS arrays to the module Repeaters, and QML
// cannot diff those: reassigning layoutConfig rebuilds every widget on
// every monitor. When a shell.json write only changed inline widget
// settings, patch the live layout and running widgets in place instead.
var next = normalizeLayout(config.layout)
var delta = BarModel.inlineSettingsDelta(layoutConfig, next)
if (delta) {
applySettingsDelta(delta)
return
}
layoutConfig = next
barConfigSerial++
}
function applySettingsDelta(delta) {
for (var i = 0; i < delta.length; i++) {
var change = delta[i]
layoutConfig[change.region][change.index] = change.entry
var settings = entrySettings(change.entry)
for (var s = 0; s < moduleSlots.length; s++) {
var slot = moduleSlots[s]
if (!slot || slot.region !== change.region || slot.moduleName !== entryId(change.entry)) continue
var item = slot.activeItem
if (item && "settings" in item) item.settings = settings
}
}
}
onBarConfigChanged: applyBarConfig()
function layoutEntries(region) {
var serial = barConfigSerial
var entries = layoutConfig ? layoutConfig[region] : null
return Array.isArray(entries) ? entries : []
}
// Tab order for the panels in one bar region. Scoped to a single bar surface
// so tabbing walks the bar the open panel belongs to instead of hopping the
// panel to another monitor's copy of the same widget.
function panelNavigationSlots(region, window) {
var entries = layoutEntries(region)
var slots = []
for (var i = 0; i < entries.length; i++) {
var id = entryId(entries[i])
for (var j = 0; j < moduleSlots.length; j++) {
var slot = moduleSlots[j]
if (!slot || slot.region !== region || slot.moduleName !== id) continue
if (window && !sameWindow(slotWindow(slot), window)) continue
var item = slot.activeItem
if (!item || item.visible !== true || slot.visible !== true || slot.width <= 0 || slot.height <= 0) continue
if (typeof item.open !== "function" || typeof item.close !== "function" || item.opened === undefined) continue
slots.push(slot)
break
}
}
return slots
}
// The Nth panel in a bar region, counted the way the bar reads: layout order,
// and only the panels actually on screen. A widget with no panel (the tray)
// and one that is hiding itself are passed over, so the number lands on the
// Nth panel icon the user can see rather than the Nth layout entry.
// One-based, because it exists for hotkeys; anything else lands on no slot.
//
// Counting any bar surface is enough: every monitor lays its bar out from the
// one layout, and summoning the id routes through pickPanelSlot, which opens
// the focused monitor's copy whichever surface was counted.
function panelWidgetIdAt(region, index) {
var slots = panelNavigationSlots(String(region || ""), null)
var slot = slots[Math.round(Number(index)) - 1]
return slot ? String(slot.moduleName || "") : ""
}
function switchPanelFrom(owner, direction) {
if (!owner) return false
var currentSlot = null
for (var i = 0; i < moduleSlots.length; i++) {
var slot = moduleSlots[i]
if (slot && slot.activeItem === owner) {
currentSlot = slot
break
}
}
if (!currentSlot) return false
var slots = panelNavigationSlots(currentSlot.region, slotWindow(currentSlot))
if (slots.length < 2) return false
var currentIndex = -1
for (var j = 0; j < slots.length; j++) {
if (slots[j] === currentSlot) {
currentIndex = j
break
}
}
if (currentIndex < 0) return false
var step = direction < 0 ? -1 : 1
var nextSlot = slots[(currentIndex + step + slots.length) % slots.length]
if (!nextSlot || !nextSlot.activeItem || nextSlot.activeItem === owner) return false
nextSlot.activeItem.open()
return true
}
// Every live instance of a widget id. A bar surface is built per monitor, so
// a widget that appears once in the layout is still live once per screen.
function moduleWidgets(pluginId) {
var id = String(pluginId || "")
var items = []
if (!id) return items
for (var i = 0; i < moduleSlots.length; i++) {
var slot = moduleSlots[i]
if (!slot || !slot.activeItem || slot.moduleName !== id) continue
items.push(slot.activeItem)
}
return items
}
function slotScreenName(slot) {
var window = slotWindow(slot)
return window && window.screen ? String(window.screen.name || "") : ""
}
// The output Hyprland has focused, which is where a keyboard-summoned panel
// belongs. Empty until Hyprland reports one, which leaves panel routing on
// its per-monitor fallback rather than guessing at an output.
function focusedScreenName() {
var monitor = Hyprland.focusedMonitor
return monitor ? String(monitor.name || "") : ""
}
// Resolve the live bar-widget instance for a plugin id (e.g. "omarchy.bluetooth").
// Only widgets that expose popup open/close methods count; plain indicators
// (clock, workspaces, tray) return null. Used by shell.summon/toggle so
// panel hotkeys route through the bar instead of a per-target IPC handler
// that only reaches whichever per-monitor instance claimed the target.
function findPanelWidget(pluginId) {
var id = String(pluginId || "")
if (!id) return null
var candidates = []
for (var i = 0; i < moduleSlots.length; i++) {
var slot = moduleSlots[i]
if (!slot || !slot.activeItem) continue
if (slot.moduleName !== id) continue
var item = slot.activeItem
if (typeof item.open !== "function" || typeof item.close !== "function" || item.opened === undefined) continue
candidates.push({ slot: slot, screenName: slotScreenName(slot), opened: item.opened === true })
}
// One copy per monitor, plus a zero-size placeholder for anchored center
// modules. See BarModel.pickPanelSlot for which one a hotkey acts on.
var chosen = BarModel.pickPanelSlot(candidates, focusedScreenName())
return chosen ? chosen.activeItem : null
}
function summonBarWidget(pluginId) {
var item = findPanelWidget(pluginId)
if (!item || typeof item.open !== "function") return false
item.open()
return true
}
function hideBarWidget(pluginId) {
var item = findPanelWidget(pluginId)
if (!item || typeof item.close !== "function") return false
item.close()
return true
}
function isBarWidgetOpen(pluginId) {
var item = findPanelWidget(pluginId)
return !!item && item.opened === true
}
function entrySettings(entry) {
return BarModel.entrySettings(entry)
}
function entryId(entry) {
return BarModel.entryId(entry)
}
function moduleString(entry, key, fallback) {
return BarModel.moduleString(entry, key, fallback)
}
function entryIndex(entries, name) {
return BarModel.entryIndex(entries, name)
}
function entriesBefore(entries, name) {
return BarModel.entriesBefore(entries, name)
}
function entriesAfter(entries, name) {
return BarModel.entriesAfter(entries, name)
}
function canonicalWidgetId(name) {
return Util.canonicalWidgetId(name)
}
function expandPath(path) {
return BarModel.expandPath(path, home)
}
function customModuleSafeName(name) {
return BarModel.customModuleSafeName(name)
}
function customModuleType(entry) {
return BarModel.customModuleType(entry)
}
function customModuleSource(entry) {
var source = BarModel.customModulePath(entry, home, omarchyConfigDir)
return source ? Util.fileUrl(source) : ""
}
Component.onCompleted: applyBarConfig()
// Revealing the indicators widens their section, which can slide a neighbour
// under a stationary pointer. Collapsing on that un-hover would move it back
// out and re-open the peek, so hold until the pointer leaves the bar.
function setCenterSectionHovered(hovered) {
centerSectionHovered = hovered
if (hovered) {
centerSectionRevealTimer.stop()
centerSectionRevealHeld = true
} else {
centerSectionRevealTimer.restart()
}
}
function setBarHovered(hovered) {
barHoverCount = Math.max(0, barHoverCount + (hovered ? 1 : -1))
if (barHoverCount === 0) centerSectionRevealTimer.restart()
}
Timer {
id: centerSectionRevealTimer
interval: 120
// Collapse only. Opening the peek is the center section's own gesture, done
// in setCenterSectionHovered, so a timer left pending by a pointer that dipped
// off the bar and came back cannot reveal indicators it never pointed at.
onTriggered: if (!root.centerSectionHovered && !root.barHovered) root.centerSectionRevealHeld = false
}
function run(command) {
if (!command) return
Util.execDetached(command)
}
function toggleTransparency() {
var nextTransparent = !(root.requestedTransparent === true)
if (root.shell && typeof root.shell.mutateShellConfig === "function") {
root.shell.mutateShellConfig(function(config) {
if (!Util.isPlainObject(config.bar)) config.bar = {}
config.bar.transparent = nextTransparent
})
} else {
root.setRequestedTransparency(nextTransparent)
}
}
function rawLayoutSection(config, region) {
if (!Util.isPlainObject(config.bar)) config.bar = {}
if (!Util.isPlainObject(config.bar.layout)) config.bar.layout = {}
if (!Array.isArray(config.bar.layout[region])) config.bar.layout[region] = []
return config.bar.layout[region]
}
function rawEntryIndex(entries, name) {
for (var i = 0; i < entries.length; i++) {
if (root.entryId(entries[i]) === name) return i
}
return -1
}
function moveModuleInConfig(config, fromRegion, fromName, toRegion, beforeName) {
var fromEntries = rawLayoutSection(config, fromRegion)
var toEntries = rawLayoutSection(config, toRegion)
var fromIndex = rawEntryIndex(fromEntries, fromName)
if (fromIndex < 0) return false
var toIndex = beforeName ? rawEntryIndex(toEntries, beforeName) : toEntries.length
if (toIndex < 0) toIndex = toEntries.length
if (fromRegion === toRegion && fromIndex === toIndex) return false
var movedEntry = fromEntries[fromIndex]
fromEntries.splice(fromIndex, 1)
if (fromRegion === toRegion && fromIndex < toIndex) toIndex -= 1
if (toIndex < 0) toIndex = 0
if (toIndex > toEntries.length) toIndex = toEntries.length
if (fromRegion === toRegion && fromIndex === toIndex) {
fromEntries.splice(fromIndex, 0, movedEntry)
return false
}
toEntries.splice(toIndex, 0, movedEntry)
return true
}
function dropBarModule(source, toRegion, beforeName) {
if (!source || !source.region || !source.moduleName || !toRegion) return false
if (source.region === toRegion && source.moduleName === beforeName) return false
if (!root.shell || typeof root.shell.mutateShellConfig !== "function") return false
var changed = false
root.shell.mutateShellConfig(function(config) {
changed = moveModuleInConfig(config, source.region, source.moduleName, toRegion, beforeName)
})
return changed
}
function moduleDropAtScene(scenePoint, sourceSlot) {
var sourceWindow = root.slotWindow(sourceSlot) || root.barDragWindow
if (sourceWindow && sourceWindow.contentItem) {
var barPoint = sourceWindow.contentItem.mapFromItem(null, scenePoint.x, scenePoint.y)
if (barPoint.x < 0 || barPoint.x > sourceWindow.contentItem.width ||
barPoint.y < 0 || barPoint.y > sourceWindow.contentItem.height)
return null
}
var candidates = []
for (var i = 0; i < moduleSlots.length; i++) {
var slot = moduleSlots[i]
if (!slot || slot === sourceSlot || !slot.visible || slot.width <= 0 || slot.height <= 0) continue
if (sourceWindow && !root.sameWindow(root.slotWindow(slot), sourceWindow)) continue
var slotPoint = { x: slot.x, y: slot.y }
try {
slotPoint = slot.mapToItem(null, 0, 0)
} catch (e) {
}
candidates.push({
slot: slot,
x: slotPoint.x,
y: slotPoint.y,
width: slot.width,
height: slot.height
})
}
return BarModel.nearestDropTarget(candidates, scenePoint, root.vertical)
}
function visibleModuleSlot(region, name, sourceSlot) {
var sourceWindow = root.slotWindow(sourceSlot) || root.barDragWindow
for (var i = 0; i < moduleSlots.length; i++) {
var slot = moduleSlots[i]
if (!slot || slot === sourceSlot || slot.region !== region || slot.moduleName !== name ||
!slot.visible || slot.width <= 0 || slot.height <= 0) continue
if (sourceWindow && !root.sameWindow(root.slotWindow(slot), sourceWindow)) continue
return slot
}
return null
}
function nextVisibleModuleName(region, afterName, sourceSlot) {
var entries = layoutEntries(region)
var found = false
for (var i = 0; i < entries.length; i++) {
var name = entryId(entries[i])
if (!found) {
found = name === afterName
continue
}
if (visibleModuleSlot(region, name, sourceSlot)) return name
}
return ""
}
function dropBarModuleAtTarget(sourceSlot, targetSlot, afterTarget) {
if (!sourceSlot || !targetSlot) return false
var beforeName = afterTarget ? nextVisibleModuleName(targetSlot.region, targetSlot.moduleName, sourceSlot) : targetSlot.moduleName
return dropBarModule(sourceSlot, targetSlot.region, beforeName)
}
function moduleTargetClickable(target) {
return target
&& target.visible !== false
&& target.opacity !== 0
&& target.interactive !== false
&& target.pressable !== false
&& target.concealed !== true
&& typeof target.triggerPress === "function"
}
function moduleClickTargetAt(slot, localX, localY) {
for (var i = clickTargets.length - 1; i >= 0; i--) {
var target = clickTargets[i]
if (!moduleTargetClickable(target)) continue
var targetPoint = { x: localX, y: localY }
try {
targetPoint = slot.mapToItem(target, localX, localY)
} catch (e) {
continue
}
if (targetPoint.x >= 0 && targetPoint.x <= target.width &&
targetPoint.y >= 0 && targetPoint.y <= target.height) {
return target
}
}
if (moduleTargetClickable(slot.activeItem)) return slot.activeItem
return null
}
function pressModuleClickTarget(slot, button, localX, localY) {
var target = moduleClickTargetAt(slot, localX, localY)
if (!target) return false
target.triggerPress(button)
return true
}
function colorHex(colorValue) {
var c = colorValue
if (typeof c === "string") c = Qt.color(c)
function hexChannel(value) {
var s = Math.round(Util.clamp(value, 0, 1) * 255).toString(16)
return s.length < 2 ? "0" + s : s
}
return "#" + hexChannel(c.r) + hexChannel(c.g) + hexChannel(c.b)
}
function setRequestedTransparency(value) {
var nextTransparent = value === true
requestedTransparent = nextTransparent
if (!nextTransparent) {
foregroundAnimationEnabled = false
useTransparentForeground = false
transparent = false
transparentForeground = themeForeground
restoreForegroundAnimation()
return
}
scheduleTransparentForegroundRefresh()
}
function restoreForegroundAnimation() {
Qt.callLater(function() {
Qt.callLater(function() { root.foregroundAnimationEnabled = true })
})
}
function scheduleTransparentForegroundRefresh() {
if (!requestedTransparent) {
transparentForeground = themeForeground
return
}
transparentForegroundTimer.restart()
}
function refreshTransparentForeground() {
if (!requestedTransparent || transparentForegroundProc.running) return
transparentForegroundProc.command = [
"omarchy-bar-text-color",
root.position,
String(root.barSize),
colorHex(root.themeForeground),
colorHex(root.themeContrastForeground)
]
transparentForegroundProc.running = true
}
onRequestedTransparentChanged: scheduleTransparentForegroundRefresh()
onPositionChanged: scheduleTransparentForegroundRefresh()
onThemeForegroundChanged: scheduleTransparentForegroundRefresh()
onThemeContrastForegroundChanged: scheduleTransparentForegroundRefresh()
Timer {
id: transparentForegroundTimer
interval: 120
repeat: false
onTriggered: root.refreshTransparentForeground()
}
Process {
id: transparentForegroundProc
stdout: SplitParser {
onRead: function(line) {
var value = String(line || "").trim()
if (!/^#[0-9A-Fa-f]{6}$/.test(value)) return
root.foregroundAnimationEnabled = false
root.transparentForeground = value
if (root.requestedTransparent) {
root.useTransparentForeground = true
root.transparent = true
}
root.restoreForegroundAnimation()
}
}
}
FileView {
path: root.stateHome + "/omarchy/current"
watchChanges: true
printErrors: false
onFileChanged: root.scheduleTransparentForegroundRefresh()
}
function runProcess(process) {
if (!process.running)
process.running = true
}
function showTooltip(target, text) {
clearTooltip()
if (!targetTooltipHovered(target) || !text) {
tooltipRequest += 1
return
}
var request = tooltipRequest + 1
tooltipRequest = request
pendingTooltipTarget = target
pendingTooltipText = text
Qt.callLater(function() {
if (request !== tooltipRequest) return
if (!targetTooltipHovered(pendingTooltipTarget)) {
clearTooltip()
return
}
tooltipTarget = pendingTooltipTarget
tooltipText = pendingTooltipText
pendingTooltipTarget = null
pendingTooltipText = ""
tooltipTimer.restart()
})
}
function hideTooltip(target) {
if (tooltipTarget !== target && pendingTooltipTarget !== target) return
tooltipRequest += 1
clearTooltip()
}
Timer {
id: tooltipTimer
interval: 400
onTriggered: {
if (root.targetTooltipHovered(root.tooltipTarget)) root.tooltipShown = true
else root.clearTooltip()
}
}
Timer {
interval: 100
running: root.tooltipShown
repeat: true
onTriggered: if (!root.targetTooltipHovered(root.tooltipTarget)) root.hideTooltip(root.tooltipTarget)
}
// Presence of the `bar-off` flag = bar hidden. Watching the parent toggles
// directory because FileView can't observe a file that doesn't exist yet,
// and the flag is created/removed by `omarchy-toggle-bar`.
Process {
id: barHiddenProbe
running: true
command: ["bash", "-c", "[[ -f $HOME/.local/state/omarchy/toggles/bar-off ]] && echo yes || echo no"]
stdout: SplitParser { onRead: function(line) { root.barHidden = String(line).trim() === "yes" } }
}
FileView {
path: root.home + "/.local/state/omarchy/toggles"
watchChanges: true
printErrors: false
onFileChanged: barHiddenProbe.running = true
}
Variants {
model: Quickshell.screens
delegate: Component {
BarPanel {
required property var modelData
screen: modelData
}
}
}
Variants {
model: Quickshell.screens
delegate: Component {
DragGhostPanel {
required property var modelData
screen: modelData
ghostScreen: modelData
}
}
}
Variants {
model: Quickshell.screens
delegate: Component {
BarMoveGhostPanel {
required property var modelData
screen: modelData
ghostScreen: modelData
}
}
}
component BarPanel: PanelWindow {
id: barWindow
// Hiding parks the bar just past its screen edge instead of unmapping it.
// Unmapping frees the layer surface and the whole scene graph, so every
// reveal has to rebuild them — new surface, re-shaped glyphs, re-uploaded
// textures — which measures ~150ms against ~20ms to tear down. Parking
// keeps the surface alive, so showing is only a margin change.
visible: !remapGuard.remapping
exclusionMode: root.barHidden ? ExclusionMode.Ignore : ExclusionMode.Auto
ScreenMoveRemap {
id: remapGuard
window: barWindow
}
margins {
top: root.barHidden && root.position === "top" ? -root.barSize
: (root.position === "top" || root.vertical ? root.style.floatM : 0)
bottom: root.barHidden && root.position === "bottom" ? -root.barSize
: (root.position === "bottom" || root.vertical ? root.style.floatM : 0)
left: root.barHidden && root.position === "left" ? -root.barSize : root.style.floatM
right: root.barHidden && root.position === "right" ? -root.barSize : root.style.floatM
}
// Floating presets must reserve their inset, or maximized windows slide
// under the visual bar edge.
exclusiveZone: root.barHidden ? -1 : root.barSize + root.style.floatM
anchors {
top: root.position === "top" || root.vertical
bottom: root.position === "bottom" || root.vertical
left: root.position === "left" || !root.vertical
right: root.position === "right" || !root.vertical
}
implicitWidth: root.vertical ? root.barSize : 0
implicitHeight: root.vertical ? 0 : root.barSize
color: "transparent"
surfaceFormat.opaque: false
WlrLayershell.namespace: "omarchy-bar"
WlrLayershell.layer: WlrLayer.Top
Rectangle {
id: styleSurface
anchors.fill: parent
// Island presets paint their own per-section slabs below; a full-band
// backdrop would double up behind them.
readonly property bool paintsBand: !root.transparent && !root.style.islands
color: paintsBand ? root.surfaceColor : "transparent"
radius: Math.min(root.style.radius, height / 2)
border.width: paintsBand ? root.style.borderWidth : 0
border.color: root.style.borderColor
gradient: root.style.gradient && paintsBand ? gradComp : null
Component {
id: gradComp
Gradient {
orientation: root.style.gradient.vertical ? Gradient.Vertical : Gradient.Horizontal
GradientStop { position: 0.0; color: root.styleColorToken(root.style.gradient.from) }
GradientStop { position: 1.0; color: root.styleColorToken(root.style.gradient.to) }
}
}
}
Rectangle {
visible: root.style.underline && !root.transparent && !root.vertical
color: Color.accent
radius: 1
x: root.style.floatM
width: parent.width - root.style.floatM * 2
height: 2
anchors.top: parent.top
// Inner edge of the band: bottom of a top bar, top of a bottom bar.
anchors.topMargin: root.position === "top" ? parent.height - 2 : 0
}
Loader {
anchors.fill: parent
sourceComponent: root.vertical ? verticalBar : horizontalBar
// A child of the loader, not a sibling of the sections: an ancestor stays
// hovered while the pointer is over a widget, where a sibling would lose
// hover to the section the pointer entered.
HoverHandler {
onHoveredChanged: root.setBarHovered(hovered)
// Unplugging a monitor destroys its bar without a leave event, which
// would strand this surface's tally and hold the peek open for good.
Component.onDestruction: if (hovered) root.setBarHovered(false)
}
}
PopupWindow {
id: tooltipWindow
visible: root.tooltipShown && root.tooltipTarget !== null && root.tooltipText !== "" && root.targetBelongsToWindow(root.tooltipTarget, barWindow)
color: "transparent"
implicitWidth: Math.ceil(tooltipBubble.implicitWidth)
implicitHeight: Math.ceil(tooltipBubble.implicitHeight)
anchor {
id: tooltipAnchor
window: barWindow
adjustment: PopupAdjustment.Slide
edges: Edges.Top | Edges.Left
gravity: Edges.Bottom | Edges.Right
rect.width: 1
rect.height: 1
onAnchoring: {
var target = root.tooltipTarget
if (!root.targetBelongsToWindow(target, barWindow)) return
var popupWidth = tooltipWindow.implicitWidth
var popupHeight = tooltipWindow.implicitHeight
var localX = target.width / 2 - popupWidth / 2
var localY = target.height + 6
if (root.position === "bottom") {
localY = -popupHeight - 6
} else if (root.position === "left") {
localX = target.width + 6
localY = target.height / 2 - popupHeight / 2
} else if (root.position === "right") {
localX = -popupWidth - 6
localY = target.height / 2 - popupHeight / 2
}
var point = barWindow.contentItem.mapFromItem(target, localX, localY)
tooltipAnchor.rect.x = Math.round(point.x)
tooltipAnchor.rect.y = Math.round(point.y)
}
}
BorderSurface {
id: tooltipBubble
implicitWidth: tooltipLabel.implicitWidth + 20
implicitHeight: tooltipLabel.implicitHeight + 14
color: Color.tooltip.background
borderSpec: Border.surfaceSpec("tooltip", "border", Color.tooltip.border, 1)
radius: Style.cornerRadius
Text {
id: tooltipLabel
anchors.centerIn: parent
text: root.tooltipText
color: Color.tooltip.text
font.family: root.fontFamily
font.pixelSize: Style.font.body
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
}
Component {
id: horizontalBar
Item {
anchors.fill: parent
CenterModules { anchors.fill: parent }
StyleIsland {
anchors.left: parent.left
anchors.leftMargin: Style.space(8)
anchors.verticalCenter: parent.verticalCenter
LeftModules { }
}
StyleIsland {
anchors.right: parent.right
anchors.rightMargin: Style.space(8)
anchors.verticalCenter: parent.verticalCenter
RightModules { }
}
}
}
Component {
id: verticalBar
Item {
anchors.fill: parent
CenterModules { anchors.fill: parent }
StyleIsland {
horizontalSection: false
anchors.top: parent.top
anchors.topMargin: Style.space(8)
anchors.horizontalCenter: parent.horizontalCenter
LeftModules { }
}
StyleIsland {
horizontalSection: false
anchors.bottom: parent.bottom
anchors.bottomMargin: Style.space(8)
anchors.horizontalCenter: parent.horizontalCenter
RightModules { }
}
}
}
}
Component { id: emptyModuleComponent; Item { implicitWidth: 0; implicitHeight: 0; visible: false } }
component DragGhostPanel: PanelWindow {
id: ghostWindow
required property var ghostScreen
readonly property bool screenMatches: root.barDragScreen === ghostScreen ||
(root.barDragScreen && ghostScreen && root.barDragScreen.name && ghostScreen.name && root.barDragScreen.name === ghostScreen.name)
readonly property bool active: root.barDragSource && root.barDragScreen && screenMatches
readonly property var sourceItem: root.barDragSource ? root.barDragSource.activeItem : null
readonly property int ghostPadding: Style.space(1)
readonly property int ghostWidth: sourceItem ? Math.max(1, Math.ceil(sourceItem.width)) : 1
readonly property int ghostHeight: sourceItem ? Math.max(1, Math.ceil(sourceItem.height)) : 1
visible: active && sourceItem !== null
color: "transparent"
exclusionMode: ExclusionMode.Ignore
WlrLayershell.namespace: "omarchy-bar-drag-ghost"
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
anchors {
top: true
bottom: true
left: true
right: true
}
// Visual-only drag feedback. Keep the input region empty so the ghost can
// sit under the cursor without stealing the MouseArea's active pointer grab.
mask: Region {}
Item {
visible: ghostWindow.visible
x: Math.round(root.barDragScreenX - root.barDragOffsetX - ghostWindow.ghostPadding)
y: Math.round(root.barDragScreenY - root.barDragOffsetY - ghostWindow.ghostPadding)
width: ghostWindow.ghostWidth + ghostWindow.ghostPadding * 2
height: ghostWindow.ghostHeight + ghostWindow.ghostPadding * 2
BorderSurface {
anchors.fill: parent
color: root.transparent ? "transparent" : root.background
borderSpec: Border.flat(root.barForeground, 1)
radius: Math.min(Style.cornerRadius, height / 2)
opacity: root.transparent ? 0.45 : 0.94
}
Image {
anchors.fill: parent
anchors.margins: ghostWindow.ghostPadding
source: root.barDragImageUrl
fillMode: Image.Stretch
smooth: true
opacity: 0.84
}
}
Rectangle {
readonly property var targetRect: root.barDragTargetGeometry
visible: ghostWindow.active && targetRect !== null
x: targetRect ? Math.round(targetRect.x) : 0
y: targetRect ? Math.round(targetRect.y) : 0
width: targetRect ? targetRect.width : 0
height: targetRect ? targetRect.height : 0
color: Color.accent
radius: Math.min(width, height) / 2
}
}
component BarMoveGhostPanel: PanelWindow {
id: moveGhostWindow
required property var ghostScreen
readonly property bool screenMatches: root.barMoveScreen === ghostScreen ||
(root.barMoveScreen && ghostScreen && root.barMoveScreen.name && ghostScreen.name && root.barMoveScreen.name === ghostScreen.name)
visible: root.barMoveActive && screenMatches
color: "transparent"
exclusionMode: ExclusionMode.Ignore
WlrLayershell.namespace: "omarchy-bar-move-ghost"
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
anchors {
top: true
bottom: true
left: true
right: true
}
// Visual-only preview of the candidate edge. Keep the input region empty
// so the overlay never steals the gesture area's active pointer grab.
mask: Region {}
// One fixed-geometry slab per edge, crossfaded on candidate changes.
// Resizing a single slab between edges repaints mid-transition and
// flickers; fading between static ones does not.
Repeater {
model: ["top", "bottom", "left", "right"]
BorderSurface {
id: edgeSlab
required property string modelData
readonly property bool edgeVertical: modelData === "left" || modelData === "right"
readonly property int edgeSize: edgeVertical ? Style.bar.sizeVertical : Style.bar.sizeHorizontal
x: modelData === "right" ? parent.width - edgeSize : 0
y: modelData === "bottom" ? parent.height - edgeSize : 0
width: edgeVertical ? edgeSize : parent.width
height: edgeVertical ? parent.height : edgeSize
color: root.transparent ? "transparent" : root.background
borderSpec: Border.flat(root.barForeground, 1)
visible: opacity > 0
opacity: root.barMoveCandidate === modelData ? (root.transparent ? 0.45 : 0.7) : 0
Behavior on opacity {
NumberAnimation { duration: 140; easing.type: Easing.OutCubic }
}
}
}
}
function findCenterAnchorEntry() {
var entries = root.layoutEntries("center")
var idx = root.entryIndex(entries, root.centerAnchor)
return idx === -1 ? null : entries[idx]
}
// Backdrop behind one module section for island presets. When the preset
// has no islands it renders nothing and adds no padding, so classic
// layouts stay pixel-identical; with islands it draws the rounded slab and
// insets its content by islandPad along the section axis.
// (Top-level inline component: QML forbids declaring a component inside
// another component, so this lives outside BarPanel.)
component StyleIsland: Rectangle {
id: islandFrame
// true for sections sitting side-by-side along a horizontal bar; false
// for sections stacked along a vertical bar.
property bool horizontalSection: true
default property alias content: islandContent.sourceComponent
readonly property bool painted: root.style.islands && !root.transparent
color: painted ? root.surfaceColor : "transparent"
radius: Math.min(root.style.radius, height / 2)
border.width: painted ? root.style.borderWidth : 0
border.color: root.style.borderColor
implicitWidth: islandContent.implicitWidth
+ (painted && horizontalSection ? root.style.islandPad * 2 : 0)
implicitHeight: islandContent.implicitHeight
+ (painted && !horizontalSection ? root.style.islandPad * 2 : 0)
Loader {
id: islandContent
anchors.centerIn: parent
}
}
component LeftModules: ModuleList {
entries: root.layoutEntries("left")
region: "left"
}
component RightModules: ModuleList {
entries: root.layoutEntries("right")
region: "right"
}
component CenterModules: Item {
id: centerRoot
property var entries: root.layoutEntries("center")
readonly property bool hasAnchor: root.entryIndex(entries, root.centerAnchor) !== -1
readonly property var anchorEntry: root.findCenterAnchorEntry()
Loader {
anchors.fill: parent
sourceComponent: root.vertical ? verticalCenterModules : horizontalCenterModules
}
Component {
id: horizontalCenterModules
Item {
anchors.fill: parent
CenterGestureArea { anchors.fill: parent }
HoverHandler {
onHoveredChanged: root.setCenterSectionHovered(hovered)
}
ModuleList {
visible: !centerRoot.hasAnchor
entries: centerRoot.entries
region: "center"
anchors.centerIn: parent
}
ModuleList {
visible: centerRoot.hasAnchor
entries: root.entriesBefore(centerRoot.entries, root.centerAnchor)
region: "center"
anchors.right: centerAnchorModule.left
anchors.verticalCenter: centerAnchorModule.verticalCenter
}
ModuleSlot {
id: centerAnchorModule
visible: centerRoot.hasAnchor
entry: centerRoot.anchorEntry
region: "center"
anchors.centerIn: parent
}
ModuleList {
visible: centerRoot.hasAnchor
entries: root.entriesAfter(centerRoot.entries, root.centerAnchor)
region: "center"
anchors.left: centerAnchorModule.right
anchors.verticalCenter: centerAnchorModule.verticalCenter
}
}
}
Component {
id: verticalCenterModules
Item {
anchors.fill: parent
CenterGestureArea { anchors.fill: parent }
HoverHandler {
onHoveredChanged: root.setCenterSectionHovered(hovered)
}
ModuleList {
visible: !centerRoot.hasAnchor
entries: centerRoot.entries
region: "center"
anchors.centerIn: parent
}
ModuleList {
visible: centerRoot.hasAnchor
entries: root.entriesBefore(centerRoot.entries, root.centerAnchor)
region: "center"
anchors.bottom: centerAnchorModule.top
anchors.horizontalCenter: centerAnchorModule.horizontalCenter
}
ModuleSlot {
id: centerAnchorModule
visible: centerRoot.hasAnchor
entry: centerRoot.anchorEntry
region: "center"
anchors.centerIn: parent
}
ModuleList {
visible: centerRoot.hasAnchor
entries: root.entriesAfter(centerRoot.entries, root.centerAnchor)
region: "center"
anchors.top: centerAnchorModule.bottom
anchors.horizontalCenter: centerAnchorModule.horizontalCenter
}
}
}
}
component CenterGestureArea: MouseArea {
id: gestureArea
property bool dragging: false
property bool suppressClick: false
property real pressedX: 0
property real pressedY: 0
readonly property real dragThreshold: Style.space(4)
acceptedButtons: Qt.LeftButton
cursorShape: dragging ? Qt.ClosedHandCursor : Qt.ArrowCursor
pressAndHoldInterval: 200
function startDrag(x, y) {
if (dragging) return
dragging = true
root.beginBarMove(root.targetWindow(gestureArea))
var scenePoint = gestureArea.mapToItem(null, x, y)
root.updateBarMove(root.windowScreenPoint(scenePoint, root.barMoveWindow))
}
onPressed: function(mouse) {
dragging = false
suppressClick = false
pressedX = mouse.x
pressedY = mouse.y
}
onPressAndHold: function(mouse) {
// A widget above us propagates its composed press-and-hold down here without
// ever handing over the grab, so we'd get no release or cancel to end the move.
if (!gestureArea.pressed) return
startDrag(mouse.x, mouse.y)
}
onPositionChanged: function(mouse) {
if (!(mouse.buttons & Qt.LeftButton)) return
if (!dragging) {
var distance = Math.abs(mouse.x - pressedX) + Math.abs(mouse.y - pressedY)
if (distance < dragThreshold) return
startDrag(mouse.x, mouse.y)
return
}
var scenePoint = gestureArea.mapToItem(null, mouse.x, mouse.y)
root.updateBarMove(root.windowScreenPoint(scenePoint, root.barMoveWindow))
}
onReleased: function(mouse) {
if (!dragging) return
dragging = false
suppressClick = true
root.finishBarMove()
mouse.accepted = true
}
onCanceled: {
dragging = false
suppressClick = false
root.clearBarMove()
}
onClicked: function(mouse) {
if (suppressClick) {
suppressClick = false
mouse.accepted = true
}
}
onDoubleClicked: function(mouse) {
if (suppressClick) {
suppressClick = false
return
}
if (mouse.button === Qt.LeftButton) {
root.toggleTransparency()
mouse.accepted = true
}
}
}
component ModuleList: Loader {
id: moduleListRoot
property var entries: []
property string region: ""
visible: entries.length > 0
// A hidden list must not build its modules. The center section declares
// both an anchored and an unanchored arrangement and shows whichever
// fits, so leaving the other one loaded mounts every center module
// twice — two IPC handlers registered for the same target, two clocks
// ticking, two of every timer and fetch behind them.
active: visible && entries.length > 0
sourceComponent: root.vertical ? verticalModuleList : horizontalModuleList
width: item ? item.implicitWidth : 0
height: item ? item.implicitHeight : 0
Component {
id: horizontalModuleList
Row {
spacing: 0
Repeater {
model: moduleListRoot.entries
ModuleSlot {
required property var modelData
entry: modelData
region: moduleListRoot.region
}
}
}
}
Component {
id: verticalModuleList
Column {
spacing: 0
Repeater {
model: moduleListRoot.entries
ModuleSlot {
required property var modelData
entry: modelData
region: moduleListRoot.region
}
}
}
}
}
component ModuleSlot: Item {
id: slot
required property var entry
property string region: ""
readonly property string moduleName: root.entryId(entry)
readonly property var moduleSettings: root.entrySettings(entry)
readonly property string customType: root.customModuleType(entry)
// Re-evaluate when the registry mutates (Component reference changes,
// plugin enabled/disabled, etc.). Reading the `widgets` property creates
// the binding dependency — the wrapped function call alone wouldn't.
readonly property var registryComponent: {
var w = root.barWidgetRegistry.widgets
if (customType) return null
var registryName = root.canonicalWidgetId(moduleName)
return w[registryName] ? w[registryName].component : null
}
readonly property bool qmlCustom: customType === "qml"
readonly property bool commandCustom: customType === "command"
readonly property bool registered: registryComponent !== null
readonly property var activeItem: {
if (registered) return registryLoader.item
if (qmlCustom) return qmlLoader.item
return componentLoader.item
}
readonly property bool hovered: moduleHover.hovered
readonly property bool dragSource: root.barDragSource === slot
readonly property bool panelOpen: root.activePopout === slot.activeItem
// Modules bigger than the mark they want (a text label in a padded slot,
// a multi-line stack on a vertical bar) can say how long the open-panel
// dot should be along the bar, so it tracks what the module paints
// instead of a fraction of whatever slot it happens to fill.
readonly property real panelIndicatorExtent: {
var key = root.vertical ? "openPanelIndicatorHeight" : "openPanelIndicatorWidth"
var hint = activeItem && key in activeItem ? activeItem[key] : undefined
if (hint !== undefined && hint !== null && hint > 0) return Math.round(hint)
return Math.max(Style.space(10), Math.round((root.vertical ? slot.height : slot.width) * 0.55))
}
implicitWidth: activeItem && activeItem.visible ? (root.vertical ? root.barSize : activeItem.implicitWidth) : 0
implicitHeight: activeItem && activeItem.visible ? activeItem.implicitHeight : 0
width: implicitWidth
height: implicitHeight
z: modulePointer.dragging ? 100 : 0
Component.onCompleted: root.registerModuleSlot(slot)
Component.onDestruction: {
if (root.barDragSource === slot) root.clearBarDrag()
root.unregisterModuleSlot(slot)
}
HoverHandler { id: moduleHover }
BorderSurface {
visible: slot.dragSource
anchors.fill: parent
anchors.margins: Style.space(1)
color: root.transparent ? "transparent" : root.background
borderSpec: Border.flat(root.barForeground, 1)
radius: Math.min(Style.cornerRadius, height / 2)
opacity: root.transparent ? 0.22 : 0.32
}
Loader {
id: componentLoader
active: !slot.qmlCustom && !slot.registered
sourceComponent: slot.commandCustom ? customCommandModuleComponent : emptyModuleComponent
anchors.fill: parent
opacity: slot.dragSource ? 0.22 : 1.0
onLoaded: {
slot.injectProps()
Qt.callLater(slot.injectProps)
}
}
Loader {
id: registryLoader
active: slot.registered
sourceComponent: slot.registered ? slot.registryComponent : null
anchors.fill: parent
opacity: slot.dragSource ? 0.22 : 1.0
onLoaded: {
slot.injectProps()
Qt.callLater(slot.injectProps)
}
}
Loader {
id: qmlLoader
active: slot.qmlCustom
source: slot.qmlCustom ? root.customModuleSource(slot.entry) : ""
anchors.fill: parent
opacity: slot.dragSource ? 0.22 : 1.0
onLoaded: {
slot.injectProps()
Qt.callLater(slot.injectProps)
}
}
Rectangle {
id: openPanelIndicator
readonly property int inset: Style.space(2)
visible: opacity > 0
opacity: slot.panelOpen && !slot.dragSource ? 0.9 : 0
color: Color.accent
radius: Math.min(width, height) / 2
width: root.vertical ? Style.space(2) : slot.panelIndicatorExtent
height: root.vertical ? slot.panelIndicatorExtent : Style.space(2)
// The mark sits on the module's inner edge — the one facing the
// desktop — so it underlines a top bar, overlines a bottom one, and
// points inward from a left or right one. It reads as pointing at the
// panel that opens on that side.
x: root.vertical
? (root.position === "left" ? parent.width - width - inset : inset)
: Math.round((parent.width - width) / 2)
y: root.vertical
? Math.round((parent.height - height) / 2)
: (root.position === "top" ? parent.height - height - inset : inset)
z: 50
Behavior on opacity {
NumberAnimation { duration: 120; easing.type: Easing.OutCubic }
}
}
MouseArea {
id: modulePointer
property bool dragging: false
property bool suppressClick: false
property real pressedX: 0
property real pressedY: 0
readonly property bool canReorder: root.shell && typeof root.shell.mutateShellConfig === "function"
readonly property real dragThreshold: Style.space(4)
anchors.fill: parent
acceptedButtons: Qt.LeftButton
enabled: slot.visible && slot.width > 0 && slot.height > 0
propagateComposedEvents: true
cursorShape: root.moduleClickTargetAt(slot, mouseX, mouseY) ? Qt.PointingHandCursor : Qt.ArrowCursor
// Do not assign drag.target here: ModuleSlot is owned by Row/Column
// positioners, and mutating slot.x/slot.y can leave stale offsets that
// make neighboring modules overlap after a small aborted drag.
onPressed: function(mouse) {
dragging = false
suppressClick = false
pressedX = mouse.x
pressedY = mouse.y
root.clearBarDrag()
}
onPositionChanged: function(mouse) {
if (!canReorder || !(mouse.buttons & Qt.LeftButton)) return
var distance = Math.abs(mouse.x - pressedX) + Math.abs(mouse.y - pressedY)
if (distance >= dragThreshold) {
if (!dragging) {
root.barDragWindow = root.targetWindow(slot.activeItem) || root.targetWindow(slot)
root.barDragScreen = root.barDragWindow ? root.barDragWindow.screen : null
root.barDragOffsetX = pressedX
root.barDragOffsetY = pressedY
root.captureBarDragGhost(slot)
root.barDragSource = slot
}
dragging = true
root.hideTooltip(slot.activeItem)
}
if (dragging) {
var scenePoint = slot.mapToItem(null, mouse.x, mouse.y)
var screenPoint = root.barDragScreenPoint(scenePoint)
root.barDragSceneX = scenePoint.x
root.barDragSceneY = scenePoint.y
root.barDragScreenX = screenPoint.x
root.barDragScreenY = screenPoint.y
var drop = root.moduleDropAtScene(scenePoint, slot)
root.barDragTarget = drop ? drop.slot : null
root.barDragAfter = drop ? drop.after : false
root.barDragTargetGeometry = drop ? root.dropMarkerRect(drop.slot, drop.after) : null
}
}
onReleased: function(mouse) {
var wasDragging = dragging
var targetSlot = root.barDragTarget
var afterTarget = root.barDragAfter
if (wasDragging) suppressClick = true
dragging = false
root.clearBarDrag()
if (wasDragging && targetSlot) {
root.dropBarModuleAtTarget(slot, targetSlot, afterTarget)
mouse.accepted = true
} else if (!wasDragging) {
mouse.accepted = false
}
}
onCanceled: {
dragging = false
suppressClick = false
root.clearBarDrag()
}
onClicked: function(mouse) {
if (suppressClick) {
suppressClick = false
mouse.accepted = true
return
}
if (!root.pressModuleClickTarget(slot, mouse.button, mouse.x, mouse.y)) mouse.accepted = false
}
}
onActiveItemChanged: Qt.callLater(injectProps)
onModuleSettingsChanged: injectProps()
function injectProps() {
var target = activeItem
if (!target) return
if ("bar" in target) target.bar = root
if ("moduleName" in target) target.moduleName = moduleName
if ("settings" in target) target.settings = moduleSettings
}
Component {
id: customCommandModuleComponent
CustomCommandModule { entry: slot.entry }
}
}
component CustomCommandModule: WidgetButton {
id: customRoot
required property var entry
readonly property string moduleName: root.entryId(entry)
readonly property var settings: root.entrySettings(entry)
property string outputText: ""
property string outputTooltip: ""
property bool outputActive: false
function setting(name, fallback) {
var value = settings ? settings[name] : undefined
return value === undefined || value === null ? fallback : value
}
function update(raw) {
var data = Util.parseModuleJson(raw)
var klass = data.class || data.alt || ""
outputText = data.text || String(raw || "").trim()
outputTooltip = data.tooltip || String(setting("tooltip", ""))
outputActive = klass === "active" || (Array.isArray(klass) && klass.indexOf("active") !== -1)
}
bar: root
text: outputText || String(setting("text", ""))
tooltipText: outputTooltip || String(setting("tooltip", ""))
active: outputActive
keepSpace: setting("keepSpace", false) === true
horizontalMargin: Number(setting("horizontalMargin", 7.5))
verticalPadding: Number(setting("verticalPadding", 6))
fontSize: Number(setting("fontSize", 12))
onPressed: function(button) {
var command = ""
if (button === Qt.RightButton)
command = String(setting("onRightClick", ""))
else if (button === Qt.MiddleButton)
command = String(setting("onMiddleClick", ""))
else
command = String(setting("onClick", ""))
if (command) root.run(command)
}
Process {
id: customProc
command: ["bash", "-lc", String(customRoot.setting("exec", ""))]
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: customRoot.update(text)
}
}
Timer {
interval: Math.max(1, Number(customRoot.setting("interval", 5))) * 1000
running: String(customRoot.setting("exec", "")) !== ""
repeat: true
triggeredOnStart: true
onTriggered: root.runProcess(customProc)
}
}
}