summaryrefslogtreecommitdiff
path: root/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Common/KeybindActions.js
blob: 25b1ed0769eb5bc80be3c55e0dfad024dc0c4a2f (plain)
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
.pragma library

const ACTION_TYPES = [
    { id: "dms", label: "DMS Action", icon: "widgets" },
    { id: "compositor", label: "Compositor", icon: "desktop_windows" },
    { id: "spawn", label: "Run Command", icon: "terminal" },
    { id: "shell", label: "Shell Command", icon: "code" }
];

const DMS_ACTIONS = [
    { id: "spawn dms ipc call spotlight toggle", label: "App Launcher: Toggle" },
    { id: "spawn dms ipc call spotlight open", label: "App Launcher: Open" },
    { id: "spawn dms ipc call spotlight close", label: "App Launcher: Close" },
    { id: "spawn dms ipc call clipboard toggle", label: "Clipboard: Toggle" },
    { id: "spawn dms ipc call clipboard open", label: "Clipboard: Open" },
    { id: "spawn dms ipc call clipboard close", label: "Clipboard: Close" },
    { id: "spawn dms ipc call notifications toggle", label: "Notifications: Toggle" },
    { id: "spawn dms ipc call notifications open", label: "Notifications: Open" },
    { id: "spawn dms ipc call notifications close", label: "Notifications: Close" },
    { id: "spawn dms ipc call processlist toggle", label: "Task Manager: Toggle" },
    { id: "spawn dms ipc call processlist open", label: "Task Manager: Open" },
    { id: "spawn dms ipc call processlist close", label: "Task Manager: Close" },
    { id: "spawn dms ipc call processlist focusOrToggle", label: "Task Manager: Focus or Toggle" },
    { id: "spawn dms ipc call settings toggle", label: "Settings: Toggle" },
    { id: "spawn dms ipc call settings open", label: "Settings: Open" },
    { id: "spawn dms ipc call settings close", label: "Settings: Close" },
    { id: "spawn dms ipc call settings focusOrToggle", label: "Settings: Focus or Toggle" },
    { id: "spawn dms ipc call powermenu toggle", label: "Power Menu: Toggle" },
    { id: "spawn dms ipc call powermenu open", label: "Power Menu: Open" },
    { id: "spawn dms ipc call powermenu close", label: "Power Menu: Close" },
    { id: "spawn dms ipc call control-center toggle", label: "Control Center: Toggle" },
    { id: "spawn dms ipc call control-center open", label: "Control Center: Open" },
    { id: "spawn dms ipc call control-center close", label: "Control Center: Close" },
    { id: "spawn dms ipc call notepad toggle", label: "Notepad: Toggle" },
    { id: "spawn dms ipc call notepad open", label: "Notepad: Open" },
    { id: "spawn dms ipc call notepad close", label: "Notepad: Close" },
    { id: "spawn dms ipc call dash toggle \"\"", label: "Dashboard: Toggle" },
    { id: "spawn dms ipc call dash open overview", label: "Dashboard: Overview" },
    { id: "spawn dms ipc call dash open media", label: "Dashboard: Media" },
    { id: "spawn dms ipc call dash open weather", label: "Dashboard: Weather" },
    { id: "spawn dms ipc call dankdash wallpaper", label: "Wallpaper Browser" },
    { id: "spawn dms ipc call file browse wallpaper", label: "File: Browse Wallpaper" },
    { id: "spawn dms ipc call file browse profile", label: "File: Browse Profile" },
    { id: "spawn dms ipc call keybinds toggle niri", label: "Keybinds Cheatsheet: Toggle", compositor: "niri" },
    { id: "spawn dms ipc call keybinds open niri", label: "Keybinds Cheatsheet: Open", compositor: "niri" },
    { id: "spawn dms ipc call keybinds close", label: "Keybinds Cheatsheet: Close" },
    { id: "spawn dms ipc call lock lock", label: "Lock Screen" },
    { id: "spawn dms ipc call lock demo", label: "Lock Screen: Demo" },
    { id: "spawn dms ipc call inhibit toggle", label: "Idle Inhibit: Toggle" },
    { id: "spawn dms ipc call inhibit enable", label: "Idle Inhibit: Enable" },
    { id: "spawn dms ipc call inhibit disable", label: "Idle Inhibit: Disable" },
    { id: "spawn dms ipc call audio increment 5", label: "Volume Up" },
    { id: "spawn dms ipc call audio increment 1", label: "Volume Up (1%)" },
    { id: "spawn dms ipc call audio increment 5", label: "Volume Up (5%)" },
    { id: "spawn dms ipc call audio increment 10", label: "Volume Up (10%)" },
    { id: "spawn dms ipc call audio decrement 5", label: "Volume Down" },
    { id: "spawn dms ipc call audio decrement 1", label: "Volume Down (1%)" },
    { id: "spawn dms ipc call audio decrement 5", label: "Volume Down (5%)" },
    { id: "spawn dms ipc call audio decrement 10", label: "Volume Down (10%)" },
    { id: "spawn dms ipc call mpris increment 5", label: "Player Volume Up (5%)" },
    { id: "spawn dms ipc call mpris decrement 5", label: "Player Volume Down (5%)" },
    { id: "spawn dms ipc call audio mute", label: "Volume Mute Toggle" },
    { id: "spawn dms ipc call audio micmute", label: "Microphone Mute Toggle" },
    { id: "spawn dms ipc call audio cycleoutput", label: "Audio Output: Cycle" },
    { id: "spawn dms ipc call brightness increment 5 \"\"", label: "Brightness Up" },
    { id: "spawn dms ipc call brightness increment 1 \"\"", label: "Brightness Up (1%)" },
    { id: "spawn dms ipc call brightness increment 5 \"\"", label: "Brightness Up (5%)" },
    { id: "spawn dms ipc call brightness increment 10 \"\"", label: "Brightness Up (10%)" },
    { id: "spawn dms ipc call brightness decrement 5 \"\"", label: "Brightness Down" },
    { id: "spawn dms ipc call brightness decrement 1 \"\"", label: "Brightness Down (1%)" },
    { id: "spawn dms ipc call brightness decrement 5 \"\"", label: "Brightness Down (5%)" },
    { id: "spawn dms ipc call brightness decrement 10 \"\"", label: "Brightness Down (10%)" },
    { id: "spawn dms ipc call brightness toggleExponential \"\"", label: "Brightness: Toggle Exponential" },
    { id: "spawn dms ipc call theme toggle", label: "Theme: Toggle Light/Dark" },
    { id: "spawn dms ipc call theme light", label: "Theme: Light Mode" },
    { id: "spawn dms ipc call theme dark", label: "Theme: Dark Mode" },
    { id: "spawn dms ipc call night toggle", label: "Night Mode: Toggle" },
    { id: "spawn dms ipc call night enable", label: "Night Mode: Enable" },
    { id: "spawn dms ipc call night disable", label: "Night Mode: Disable" },
    { id: "spawn dms ipc call bar toggle index 0", label: "Bar: Toggle (Primary)" },
    { id: "spawn dms ipc call bar reveal index 0", label: "Bar: Reveal (Primary)" },
    { id: "spawn dms ipc call bar hide index 0", label: "Bar: Hide (Primary)" },
    { id: "spawn dms ipc call bar toggleAutoHide index 0", label: "Bar: Toggle Auto-Hide (Primary)" },
    { id: "spawn dms ipc call bar autoHide index 0", label: "Bar: Enable Auto-Hide (Primary)" },
    { id: "spawn dms ipc call bar manualHide index 0", label: "Bar: Disable Auto-Hide (Primary)" },
    { id: "spawn dms ipc call dock toggle", label: "Dock: Toggle" },
    { id: "spawn dms ipc call dock reveal", label: "Dock: Reveal" },
    { id: "spawn dms ipc call dock hide", label: "Dock: Hide" },
    { id: "spawn dms ipc call dock toggleAutoHide", label: "Dock: Toggle Auto-Hide" },
    { id: "spawn dms ipc call dock autoHide", label: "Dock: Enable Auto-Hide" },
    { id: "spawn dms ipc call dock manualHide", label: "Dock: Disable Auto-Hide" },
    { id: "spawn dms ipc call mpris playPause", label: "Media: Play/Pause" },
    { id: "spawn dms ipc call mpris play", label: "Media: Play" },
    { id: "spawn dms ipc call mpris pause", label: "Media: Pause" },
    { id: "spawn dms ipc call mpris previous", label: "Media: Previous Track" },
    { id: "spawn dms ipc call mpris next", label: "Media: Next Track" },
    { id: "spawn dms ipc call mpris stop", label: "Media: Stop" },
    { id: "spawn dms ipc call niri screenshot", label: "Screenshot: Interactive", compositor: "niri" },
    { id: "spawn dms ipc call niri screenshotScreen", label: "Screenshot: Full Screen", compositor: "niri" },
    { id: "spawn dms ipc call niri screenshotWindow", label: "Screenshot: Window", compositor: "niri" },
    { id: "spawn dms ipc call hypr toggleOverview", label: "Hyprland: Toggle Overview", compositor: "hyprland" },
    { id: "spawn dms ipc call hypr openOverview", label: "Hyprland: Open Overview", compositor: "hyprland" },
    { id: "spawn dms ipc call hypr closeOverview", label: "Hyprland: Close Overview", compositor: "hyprland" },
    { id: "spawn dms ipc call wallpaper next", label: "Wallpaper: Next" },
    { id: "spawn dms ipc call wallpaper prev", label: "Wallpaper: Previous" },
    { id: "spawn dms ipc call workspace-rename open", label: "Workspace: Rename" }
];

const NIRI_ACTIONS = {
    "Window": [
        { id: "close-window", label: "Close Window" },
        { id: "fullscreen-window", label: "Fullscreen" },
        { id: "maximize-column", label: "Maximize Column" },
        { id: "center-column", label: "Center Column" },
        { id: "center-visible-columns", label: "Center Visible Columns" },
        { id: "toggle-window-floating", label: "Toggle Floating" },
        { id: "switch-focus-between-floating-and-tiling", label: "Switch Floating/Tiling Focus" },
        { id: "switch-preset-column-width", label: "Cycle Column Width" },
        { id: "switch-preset-window-height", label: "Cycle Window Height" },
        { id: "set-column-width", label: "Set Column Width" },
        { id: "set-window-height", label: "Set Window Height" },
        { id: "reset-window-height", label: "Reset Window Height" },
        { id: "expand-column-to-available-width", label: "Expand to Available Width" },
        { id: "consume-or-expel-window-left", label: "Consume/Expel Left" },
        { id: "consume-or-expel-window-right", label: "Consume/Expel Right" },
        { id: "toggle-column-tabbed-display", label: "Toggle Tabbed" },
        { id: "toggle-window-rule-opacity", label: "Toggle Window Opacity" }
    ],
    "Focus": [
        { id: "focus-column-left", label: "Focus Left" },
        { id: "focus-column-right", label: "Focus Right" },
        { id: "focus-window-down", label: "Focus Down" },
        { id: "focus-window-up", label: "Focus Up" },
        { id: "focus-column-first", label: "Focus First Column" },
        { id: "focus-column-last", label: "Focus Last Column" }
    ],
    "Move": [
        { id: "move-column-left", label: "Move Left" },
        { id: "move-column-right", label: "Move Right" },
        { id: "move-window-down", label: "Move Down" },
        { id: "move-window-up", label: "Move Up" },
        { id: "move-column-to-first", label: "Move to First" },
        { id: "move-column-to-last", label: "Move to Last" }
    ],
    "Workspace": [
        { id: "focus-workspace-down", label: "Focus Workspace Down" },
        { id: "focus-workspace-up", label: "Focus Workspace Up" },
        { id: "focus-workspace-previous", label: "Focus Previous Workspace" },
        { id: "focus-workspace", label: "Focus Workspace (by index)" },
        { id: "move-column-to-workspace-down", label: "Move to Workspace Down" },
        { id: "move-column-to-workspace-up", label: "Move to Workspace Up" },
        { id: "move-column-to-workspace", label: "Move to Workspace (by index)" },
        { id: "move-workspace-down", label: "Move Workspace Down" },
        { id: "move-workspace-up", label: "Move Workspace Up" }
    ],
    "Monitor": [
        { id: "focus-monitor-left", label: "Focus Monitor Left" },
        { id: "focus-monitor-right", label: "Focus Monitor Right" },
        { id: "focus-monitor-down", label: "Focus Monitor Down" },
        { id: "focus-monitor-up", label: "Focus Monitor Up" },
        { id: "move-column-to-monitor-left", label: "Move to Monitor Left" },
        { id: "move-column-to-monitor-right", label: "Move to Monitor Right" },
        { id: "move-column-to-monitor-down", label: "Move to Monitor Down" },
        { id: "move-column-to-monitor-up", label: "Move to Monitor Up" }
    ],
    "Screenshot": [
        { id: "screenshot", label: "Screenshot (Interactive)" },
        { id: "screenshot-screen", label: "Screenshot Screen" },
        { id: "screenshot-window", label: "Screenshot Window" }
    ],
    "System": [
        { id: "toggle-overview", label: "Toggle Overview" },
        { id: "show-hotkey-overlay", label: "Show Hotkey Overlay" },
        { id: "do-screen-transition", label: "Screen Transition" },
        { id: "power-off-monitors", label: "Power Off Monitors" },
        { id: "power-on-monitors", label: "Power On Monitors" },
        { id: "toggle-keyboard-shortcuts-inhibit", label: "Toggle Shortcuts Inhibit" },
        { id: "quit", label: "Quit Niri" },
        { id: "suspend", label: "Suspend" }
    ],
    "Alt-Tab": [
        { id: "next-window", label: "Next Window" },
        { id: "previous-window", label: "Previous Window" }
    ]
};

const MANGOWC_ACTIONS = {
    "Window": [
        { id: "killclient", label: "Close Window" },
        { id: "focuslast", label: "Focus Last Window" },
        { id: "focusstack next", label: "Focus Next in Stack" },
        { id: "focusstack prev", label: "Focus Previous in Stack" },
        { id: "focusdir left", label: "Focus Left" },
        { id: "focusdir right", label: "Focus Right" },
        { id: "focusdir up", label: "Focus Up" },
        { id: "focusdir down", label: "Focus Down" },
        { id: "exchange_client left", label: "Swap Left" },
        { id: "exchange_client right", label: "Swap Right" },
        { id: "exchange_client up", label: "Swap Up" },
        { id: "exchange_client down", label: "Swap Down" },
        { id: "exchange_stack_client next", label: "Swap Next in Stack" },
        { id: "exchange_stack_client prev", label: "Swap Previous in Stack" },
        { id: "togglefloating", label: "Toggle Floating" },
        { id: "togglefullscreen", label: "Toggle Fullscreen" },
        { id: "togglefakefullscreen", label: "Toggle Fake Fullscreen" },
        { id: "togglemaximizescreen", label: "Toggle Maximize" },
        { id: "toggleglobal", label: "Toggle Global (Sticky)" },
        { id: "toggleoverlay", label: "Toggle Overlay" },
        { id: "minimized", label: "Minimize Window" },
        { id: "restore_minimized", label: "Restore Minimized" },
        { id: "toggle_render_border", label: "Toggle Border" },
        { id: "centerwin", label: "Center Window" },
        { id: "zoom", label: "Swap with Master" }
    ],
    "Move/Resize": [
        { id: "smartmovewin left", label: "Smart Move Left" },
        { id: "smartmovewin right", label: "Smart Move Right" },
        { id: "smartmovewin up", label: "Smart Move Up" },
        { id: "smartmovewin down", label: "Smart Move Down" },
        { id: "smartresizewin left", label: "Smart Resize Left" },
        { id: "smartresizewin right", label: "Smart Resize Right" },
        { id: "smartresizewin up", label: "Smart Resize Up" },
        { id: "smartresizewin down", label: "Smart Resize Down" },
        { id: "movewin", label: "Move Window (x,y)" },
        { id: "resizewin", label: "Resize Window (w,h)" }
    ],
    "Tags": [
        { id: "view", label: "View Tag" },
        { id: "viewtoleft", label: "View Left Tag" },
        { id: "viewtoright", label: "View Right Tag" },
        { id: "viewtoleft_have_client", label: "View Left (with client)" },
        { id: "viewtoright_have_client", label: "View Right (with client)" },
        { id: "viewcrossmon", label: "View Cross-Monitor" },
        { id: "tag", label: "Move to Tag" },
        { id: "tagsilent", label: "Move to Tag (silent)" },
        { id: "tagtoleft", label: "Move to Left Tag" },
        { id: "tagtoright", label: "Move to Right Tag" },
        { id: "tagcrossmon", label: "Move Cross-Monitor" },
        { id: "toggletag", label: "Toggle Tag on Window" },
        { id: "toggleview", label: "Toggle Tag View" },
        { id: "comboview", label: "Combo View Tags" }
    ],
    "Layout": [
        { id: "setlayout", label: "Set Layout" },
        { id: "switch_layout", label: "Cycle Layouts" },
        { id: "set_proportion", label: "Set Proportion" },
        { id: "switch_proportion_preset", label: "Cycle Proportion Presets" },
        { id: "incnmaster +1", label: "Increase Masters" },
        { id: "incnmaster -1", label: "Decrease Masters" },
        { id: "setmfact", label: "Set Master Factor" },
        { id: "incgaps", label: "Adjust Gaps" },
        { id: "togglegaps", label: "Toggle Gaps" }
    ],
    "Monitor": [
        { id: "focusmon left", label: "Focus Monitor Left" },
        { id: "focusmon right", label: "Focus Monitor Right" },
        { id: "focusmon up", label: "Focus Monitor Up" },
        { id: "focusmon down", label: "Focus Monitor Down" },
        { id: "tagmon left", label: "Move to Monitor Left" },
        { id: "tagmon right", label: "Move to Monitor Right" },
        { id: "tagmon up", label: "Move to Monitor Up" },
        { id: "tagmon down", label: "Move to Monitor Down" },
        { id: "disable_monitor", label: "Disable Monitor" },
        { id: "enable_monitor", label: "Enable Monitor" },
        { id: "toggle_monitor", label: "Toggle Monitor" },
        { id: "create_virtual_output", label: "Create Virtual Output" },
        { id: "destroy_all_virtual_output", label: "Destroy Virtual Outputs" }
    ],
    "Scratchpad": [
        { id: "toggle_scratchpad", label: "Toggle Scratchpad" },
        { id: "toggle_name_scratchpad", label: "Toggle Named Scratchpad" }
    ],
    "Overview": [
        { id: "toggleoverview", label: "Toggle Overview" }
    ],
    "System": [
        { id: "reload_config", label: "Reload Config" },
        { id: "quit", label: "Quit MangoWC" },
        { id: "setkeymode", label: "Set Keymode" },
        { id: "switch_keyboard_layout", label: "Switch Keyboard Layout" },
        { id: "setoption", label: "Set Option" },
        { id: "toggle_trackpad_enable", label: "Toggle Trackpad" }
    ]
};

const HYPRLAND_ACTIONS = {
    "Window": [
        { id: "killactive", label: "Close Window" },
        { id: "forcekillactive", label: "Force Kill Window" },
        { id: "closewindow", label: "Close Window (by selector)" },
        { id: "killwindow", label: "Kill Window (by selector)" },
        { id: "togglefloating", label: "Toggle Floating" },
        { id: "setfloating", label: "Set Floating" },
        { id: "settiled", label: "Set Tiled" },
        { id: "fullscreen", label: "Toggle Fullscreen" },
        { id: "fullscreenstate", label: "Set Fullscreen State" },
        { id: "pin", label: "Pin Window" },
        { id: "centerwindow", label: "Center Window" },
        { id: "resizeactive", label: "Resize Active Window" },
        { id: "moveactive", label: "Move Active Window" },
        { id: "resizewindowpixel", label: "Resize Window (pixels)" },
        { id: "movewindowpixel", label: "Move Window (pixels)" },
        { id: "alterzorder", label: "Change Z-Order" },
        { id: "bringactivetotop", label: "Bring to Top" },
        { id: "setprop", label: "Set Window Property" },
        { id: "toggleswallow", label: "Toggle Swallow" }
    ],
    "Focus": [
        { id: "movefocus l", label: "Focus Left" },
        { id: "movefocus r", label: "Focus Right" },
        { id: "movefocus u", label: "Focus Up" },
        { id: "movefocus d", label: "Focus Down" },
        { id: "movefocus", label: "Move Focus (direction)" },
        { id: "cyclenext", label: "Cycle Next Window" },
        { id: "cyclenext prev", label: "Cycle Previous Window" },
        { id: "focuswindow", label: "Focus Window (by selector)" },
        { id: "focuscurrentorlast", label: "Focus Current or Last" },
        { id: "focusurgentorlast", label: "Focus Urgent or Last" }
    ],
    "Move": [
        { id: "movewindow l", label: "Move Window Left" },
        { id: "movewindow r", label: "Move Window Right" },
        { id: "movewindow u", label: "Move Window Up" },
        { id: "movewindow d", label: "Move Window Down" },
        { id: "movewindow", label: "Move Window (direction)" },
        { id: "swapwindow l", label: "Swap Left" },
        { id: "swapwindow r", label: "Swap Right" },
        { id: "swapwindow u", label: "Swap Up" },
        { id: "swapwindow d", label: "Swap Down" },
        { id: "swapwindow", label: "Swap Window (direction)" },
        { id: "swapnext", label: "Swap with Next" },
        { id: "swapnext prev", label: "Swap with Previous" },
        { id: "movecursortocorner", label: "Move Cursor to Corner" },
        { id: "movecursor", label: "Move Cursor (x,y)" }
    ],
    "Workspace": [
        { id: "workspace", label: "Focus Workspace" },
        { id: "workspace +1", label: "Next Workspace" },
        { id: "workspace -1", label: "Previous Workspace" },
        { id: "workspace e+1", label: "Next Open Workspace" },
        { id: "workspace e-1", label: "Previous Open Workspace" },
        { id: "workspace previous", label: "Previous Visited Workspace" },
        { id: "workspace previous_per_monitor", label: "Previous on Monitor" },
        { id: "workspace empty", label: "First Empty Workspace" },
        { id: "movetoworkspace", label: "Move to Workspace" },
        { id: "movetoworkspace +1", label: "Move to Next Workspace" },
        { id: "movetoworkspace -1", label: "Move to Previous Workspace" },
        { id: "movetoworkspacesilent", label: "Move to Workspace (silent)" },
        { id: "movetoworkspacesilent +1", label: "Move to Next (silent)" },
        { id: "movetoworkspacesilent -1", label: "Move to Previous (silent)" },
        { id: "togglespecialworkspace", label: "Toggle Special Workspace" },
        { id: "focusworkspaceoncurrentmonitor", label: "Focus Workspace on Current Monitor" },
        { id: "renameworkspace", label: "Rename Workspace" }
    ],
    "Monitor": [
        { id: "focusmonitor l", label: "Focus Monitor Left" },
        { id: "focusmonitor r", label: "Focus Monitor Right" },
        { id: "focusmonitor u", label: "Focus Monitor Up" },
        { id: "focusmonitor d", label: "Focus Monitor Down" },
        { id: "focusmonitor +1", label: "Focus Next Monitor" },
        { id: "focusmonitor -1", label: "Focus Previous Monitor" },
        { id: "focusmonitor", label: "Focus Monitor (by selector)" },
        { id: "movecurrentworkspacetomonitor", label: "Move Workspace to Monitor" },
        { id: "moveworkspacetomonitor", label: "Move Specific Workspace to Monitor" },
        { id: "swapactiveworkspaces", label: "Swap Active Workspaces" }
    ],
    "Groups": [
        { id: "togglegroup", label: "Toggle Group" },
        { id: "changegroupactive f", label: "Next in Group" },
        { id: "changegroupactive b", label: "Previous in Group" },
        { id: "changegroupactive", label: "Change Active in Group" },
        { id: "moveintogroup l", label: "Move into Group Left" },
        { id: "moveintogroup r", label: "Move into Group Right" },
        { id: "moveintogroup u", label: "Move into Group Up" },
        { id: "moveintogroup d", label: "Move into Group Down" },
        { id: "moveoutofgroup", label: "Move out of Group" },
        { id: "movewindoworgroup l", label: "Move Window/Group Left" },
        { id: "movewindoworgroup r", label: "Move Window/Group Right" },
        { id: "movewindoworgroup u", label: "Move Window/Group Up" },
        { id: "movewindoworgroup d", label: "Move Window/Group Down" },
        { id: "movegroupwindow f", label: "Swap Forward in Group" },
        { id: "movegroupwindow b", label: "Swap Backward in Group" },
        { id: "lockgroups lock", label: "Lock All Groups" },
        { id: "lockgroups unlock", label: "Unlock All Groups" },
        { id: "lockgroups toggle", label: "Toggle Groups Lock" },
        { id: "lockactivegroup lock", label: "Lock Active Group" },
        { id: "lockactivegroup unlock", label: "Unlock Active Group" },
        { id: "lockactivegroup toggle", label: "Toggle Active Group Lock" },
        { id: "denywindowfromgroup on", label: "Deny Window from Group" },
        { id: "denywindowfromgroup off", label: "Allow Window in Group" },
        { id: "denywindowfromgroup toggle", label: "Toggle Deny from Group" },
        { id: "setignoregrouplock on", label: "Ignore Group Lock" },
        { id: "setignoregrouplock off", label: "Respect Group Lock" },
        { id: "setignoregrouplock toggle", label: "Toggle Ignore Group Lock" }
    ],
    "Layout": [
        { id: "splitratio", label: "Adjust Split Ratio" }
    ],
    "System": [
        { id: "exit", label: "Exit Hyprland" },
        { id: "forcerendererreload", label: "Force Renderer Reload" },
        { id: "dpms on", label: "DPMS On" },
        { id: "dpms off", label: "DPMS Off" },
        { id: "dpms toggle", label: "DPMS Toggle" },
        { id: "forceidle", label: "Force Idle" },
        { id: "submap", label: "Enter Submap" },
        { id: "submap reset", label: "Reset Submap" },
        { id: "global", label: "Global Shortcut" },
        { id: "event", label: "Emit Custom Event" }
    ],
    "Pass-through": [
        { id: "pass", label: "Pass Key to Window" },
        { id: "sendshortcut", label: "Send Shortcut to Window" },
        { id: "sendkeystate", label: "Send Key State" }
    ]
};

const COMPOSITOR_ACTIONS = {
    niri: NIRI_ACTIONS,
    mangowc: MANGOWC_ACTIONS,
    hyprland: HYPRLAND_ACTIONS
};

const CATEGORY_ORDER = ["DMS", "Execute", "Workspace", "Tags", "Window", "Move/Resize", "Focus", "Move", "Layout", "Groups", "Monitor", "Scratchpad", "Screenshot", "System", "Pass-through", "Overview", "Alt-Tab", "Other"];

const NIRI_ACTION_ARGS = {
    "quit": {
        args: [{ name: "skip-confirmation", type: "bool", label: "Skip confirmation" }]
    },
    "do-screen-transition": {
        args: [{ name: "delay-ms", type: "number", label: "Delay (ms)", placeholder: "250" }]
    },
    "set-column-width": {
        args: [{ name: "value", type: "text", label: "Width", placeholder: "+10%, -10%, 50%" }]
    },
    "set-window-height": {
        args: [{ name: "value", type: "text", label: "Height", placeholder: "+10%, -10%, 50%" }]
    },
    "focus-workspace": {
        args: [{ name: "index", type: "number", label: "Workspace", placeholder: "1, 2, 3..." }]
    },
    "move-column-to-workspace": {
        args: [
            { name: "index", type: "number", label: "Workspace", placeholder: "1, 2, 3..." },
            { name: "focus", type: "bool", label: "Follow focus", default: false }
        ]
    },
    "move-column-to-workspace-down": {
        args: [{ name: "focus", type: "bool", label: "Follow focus", default: false }]
    },
    "move-column-to-workspace-up": {
        args: [{ name: "focus", type: "bool", label: "Follow focus", default: false }]
    },
    "screenshot": {
        args: [{ name: "show-pointer", type: "bool", label: "Show pointer" }]
    },
    "screenshot-screen": {
        args: [
            { name: "show-pointer", type: "bool", label: "Show pointer" },
            { name: "write-to-disk", type: "bool", label: "Save to disk" }
        ]
    },
    "screenshot-window": {
        args: [{ name: "write-to-disk", type: "bool", label: "Save to disk" }]
    }
};

const MANGOWC_ACTION_ARGS = {
    "view": {
        args: [
            { name: "tag", type: "number", label: "Tag", placeholder: "1-9" },
            { name: "monitor", type: "number", label: "Monitor", placeholder: "0", default: "0" }
        ]
    },
    "tag": {
        args: [
            { name: "tag", type: "number", label: "Tag", placeholder: "1-9" },
            { name: "monitor", type: "number", label: "Monitor", placeholder: "0", default: "0" }
        ]
    },
    "tagsilent": {
        args: [
            { name: "tag", type: "number", label: "Tag", placeholder: "1-9" },
            { name: "monitor", type: "number", label: "Monitor", placeholder: "0", default: "0" }
        ]
    },
    "toggletag": {
        args: [
            { name: "tag", type: "number", label: "Tag", placeholder: "1-9" },
            { name: "monitor", type: "number", label: "Monitor", placeholder: "0", default: "0" }
        ]
    },
    "toggleview": {
        args: [
            { name: "tag", type: "number", label: "Tag", placeholder: "1-9" },
            { name: "monitor", type: "number", label: "Monitor", placeholder: "0", default: "0" }
        ]
    },
    "comboview": {
        args: [{ name: "tags", type: "text", label: "Tags", placeholder: "1,2,3" }]
    },
    "setlayout": {
        args: [{ name: "layout", type: "text", label: "Layout", placeholder: "tile, monocle, grid, deck" }]
    },
    "set_proportion": {
        args: [{ name: "value", type: "text", label: "Proportion", placeholder: "0.5, +0.1, -0.1" }]
    },
    "setmfact": {
        args: [{ name: "value", type: "text", label: "Factor", placeholder: "+0.05, -0.05" }]
    },
    "incgaps": {
        args: [{ name: "value", type: "number", label: "Amount", placeholder: "+5, -5" }]
    },
    "movewin": {
        args: [{ name: "value", type: "text", label: "Position", placeholder: "x,y or +10,+10" }]
    },
    "resizewin": {
        args: [{ name: "value", type: "text", label: "Size", placeholder: "w,h or +10,+10" }]
    },
    "setkeymode": {
        args: [{ name: "mode", type: "text", label: "Mode", placeholder: "default, custom" }]
    },
    "setoption": {
        args: [{ name: "option", type: "text", label: "Option", placeholder: "option_name value" }]
    },
    "toggle_name_scratchpad": {
        args: [{ name: "name", type: "text", label: "Name", placeholder: "scratchpad name" }]
    },
    "incnmaster": {
        args: [{ name: "value", type: "number", label: "Amount", placeholder: "+1, -1" }]
    }
};

const HYPRLAND_ACTION_ARGS = {
    "workspace": {
        args: [{ name: "value", type: "text", label: "Workspace", placeholder: "1, +1, -1, name:..." }]
    },
    "movetoworkspace": {
        args: [
            { name: "workspace", type: "text", label: "Workspace", placeholder: "1, +1, special:name" },
            { name: "window", type: "text", label: "Window (optional)", placeholder: "class:^(app)$" }
        ]
    },
    "movetoworkspacesilent": {
        args: [
            { name: "workspace", type: "text", label: "Workspace", placeholder: "1, +1, special:name" },
            { name: "window", type: "text", label: "Window (optional)", placeholder: "class:^(app)$" }
        ]
    },
    "focusworkspaceoncurrentmonitor": {
        args: [{ name: "value", type: "text", label: "Workspace", placeholder: "1, +1, name:..." }]
    },
    "togglespecialworkspace": {
        args: [{ name: "name", type: "text", label: "Name (optional)", placeholder: "scratchpad" }]
    },
    "focusmonitor": {
        args: [{ name: "value", type: "text", label: "Monitor", placeholder: "l, r, +1, DP-1" }]
    },
    "movecurrentworkspacetomonitor": {
        args: [{ name: "monitor", type: "text", label: "Monitor", placeholder: "l, r, DP-1" }]
    },
    "moveworkspacetomonitor": {
        args: [
            { name: "workspace", type: "text", label: "Workspace", placeholder: "1, name:..." },
            { name: "monitor", type: "text", label: "Monitor", placeholder: "DP-1" }
        ]
    },
    "swapactiveworkspaces": {
        args: [
            { name: "monitor1", type: "text", label: "Monitor 1", placeholder: "DP-1" },
            { name: "monitor2", type: "text", label: "Monitor 2", placeholder: "DP-2" }
        ]
    },
    "renameworkspace": {
        args: [
            { name: "id", type: "number", label: "Workspace ID", placeholder: "1" },
            { name: "name", type: "text", label: "New Name", placeholder: "work" }
        ]
    },
    "fullscreen": {
        args: [{ name: "mode", type: "text", label: "Mode", placeholder: "0=full, 1=max, 2=fake" }]
    },
    "fullscreenstate": {
        args: [
            { name: "internal", type: "text", label: "Internal", placeholder: "-1, 0, 1, 2, 3" },
            { name: "client", type: "text", label: "Client", placeholder: "-1, 0, 1, 2, 3" }
        ]
    },
    "resizeactive": {
        args: [{ name: "value", type: "text", label: "Size", placeholder: "10 -10, 20% 0" }]
    },
    "moveactive": {
        args: [{ name: "value", type: "text", label: "Position", placeholder: "10 -10, exact 100 100" }]
    },
    "resizewindowpixel": {
        args: [
            { name: "size", type: "text", label: "Size", placeholder: "100 100" },
            { name: "window", type: "text", label: "Window", placeholder: "class:^(app)$" }
        ]
    },
    "movewindowpixel": {
        args: [
            { name: "position", type: "text", label: "Position", placeholder: "100 100" },
            { name: "window", type: "text", label: "Window", placeholder: "class:^(app)$" }
        ]
    },
    "splitratio": {
        args: [{ name: "value", type: "text", label: "Ratio", placeholder: "+0.1, -0.1, exact 0.5" }]
    },
    "closewindow": {
        args: [{ name: "window", type: "text", label: "Window", placeholder: "class:^(app)$" }]
    },
    "killwindow": {
        args: [{ name: "window", type: "text", label: "Window", placeholder: "class:^(app)$" }]
    },
    "focuswindow": {
        args: [{ name: "window", type: "text", label: "Window", placeholder: "class:^(app)$" }]
    },
    "tagwindow": {
        args: [
            { name: "tag", type: "text", label: "Tag", placeholder: "+mytag, -mytag" },
            { name: "window", type: "text", label: "Window (optional)", placeholder: "class:^(app)$" }
        ]
    },
    "alterzorder": {
        args: [
            { name: "zheight", type: "text", label: "Z-Height", placeholder: "top, bottom" },
            { name: "window", type: "text", label: "Window (optional)", placeholder: "class:^(app)$" }
        ]
    },
    "setprop": {
        args: [
            { name: "window", type: "text", label: "Window", placeholder: "class:^(app)$" },
            { name: "property", type: "text", label: "Property", placeholder: "opaque, alpha..." },
            { name: "value", type: "text", label: "Value", placeholder: "1, toggle" }
        ]
    },
    "signal": {
        args: [{ name: "signal", type: "number", label: "Signal", placeholder: "9" }]
    },
    "signalwindow": {
        args: [
            { name: "window", type: "text", label: "Window", placeholder: "class:^(app)$" },
            { name: "signal", type: "number", label: "Signal", placeholder: "9" }
        ]
    },
    "submap": {
        args: [{ name: "name", type: "text", label: "Submap Name", placeholder: "resize, reset" }]
    },
    "global": {
        args: [{ name: "name", type: "text", label: "Shortcut Name", placeholder: "app:action" }]
    },
    "event": {
        args: [{ name: "data", type: "text", label: "Event Data", placeholder: "custom data" }]
    },
    "pass": {
        args: [{ name: "window", type: "text", label: "Window", placeholder: "class:^(app)$" }]
    },
    "sendshortcut": {
        args: [
            { name: "mod", type: "text", label: "Modifier", placeholder: "SUPER, ALT" },
            { name: "key", type: "text", label: "Key", placeholder: "F4" },
            { name: "window", type: "text", label: "Window (optional)", placeholder: "class:^(app)$" }
        ]
    },
    "sendkeystate": {
        args: [
            { name: "mod", type: "text", label: "Modifier", placeholder: "SUPER" },
            { name: "key", type: "text", label: "Key", placeholder: "a" },
            { name: "state", type: "text", label: "State", placeholder: "down, repeat, up" },
            { name: "window", type: "text", label: "Window", placeholder: "class:^(app)$" }
        ]
    },
    "forceidle": {
        args: [{ name: "seconds", type: "number", label: "Seconds", placeholder: "300" }]
    },
    "movecursortocorner": {
        args: [{ name: "corner", type: "number", label: "Corner", placeholder: "0-3 (BL, BR, TR, TL)" }]
    },
    "movecursor": {
        args: [
            { name: "x", type: "number", label: "X", placeholder: "100" },
            { name: "y", type: "number", label: "Y", placeholder: "100" }
        ]
    },
    "changegroupactive": {
        args: [{ name: "direction", type: "text", label: "Direction/Index", placeholder: "f, b, or index" }]
    },
    "movefocus": {
        args: [{ name: "direction", type: "text", label: "Direction", placeholder: "l, r, u, d" }]
    },
    "movewindow": {
        args: [{ name: "direction", type: "text", label: "Direction/Monitor", placeholder: "l, r, mon:DP-1" }]
    },
    "swapwindow": {
        args: [{ name: "direction", type: "text", label: "Direction", placeholder: "l, r, u, d" }]
    },
    "moveintogroup": {
        args: [{ name: "direction", type: "text", label: "Direction", placeholder: "l, r, u, d" }]
    },
    "movewindoworgroup": {
        args: [{ name: "direction", type: "text", label: "Direction", placeholder: "l, r, u, d" }]
    },
    "cyclenext": {
        args: [{ name: "options", type: "text", label: "Options", placeholder: "prev, tiled, floating" }]
    }
};

const ACTION_ARGS = {
    niri: NIRI_ACTION_ARGS,
    mangowc: MANGOWC_ACTION_ARGS,
    hyprland: HYPRLAND_ACTION_ARGS
};

const DMS_ACTION_ARGS = {
    "audio increment": {
        base: "spawn dms ipc call audio increment",
        args: [{ name: "amount", type: "number", label: "Amount %", placeholder: "5", default: "5" }]
    },
    "audio decrement": {
        base: "spawn dms ipc call audio decrement",
        args: [{ name: "amount", type: "number", label: "Amount %", placeholder: "5", default: "5" }]
    },
    "player increment": {
        base: "spawn dms ipc call mpris increment",
        args: [{ name: "amount", type: "number", label: "Amount %", placeholder: "5", default: "5" }]
    },
    "player decrement": {
        base: "spawn dms ipc call mpris decrement",
        args: [{ name: "amount", type: "number", label: "Amount %", placeholder: "5", default: "5" }]
    },
    "brightness increment": {
        base: "spawn dms ipc call brightness increment",
        args: [
            { name: "amount", type: "number", label: "Amount %", placeholder: "5", default: "5" },
            { name: "device", type: "text", label: "Device", placeholder: "leave empty for default", default: "" }
        ]
    },
    "brightness decrement": {
        base: "spawn dms ipc call brightness decrement",
        args: [
            { name: "amount", type: "number", label: "Amount %", placeholder: "5", default: "5" },
            { name: "device", type: "text", label: "Device", placeholder: "leave empty for default", default: "" }
        ]
    },
    "brightness toggleExponential": {
        base: "spawn dms ipc call brightness toggleExponential",
        args: [
            { name: "device", type: "text", label: "Device", placeholder: "leave empty for default", default: "" }
        ]
    },
    "dash toggle": {
        base: "spawn dms ipc call dash toggle",
        args: [
            { name: "tab", type: "text", label: "Tab", placeholder: "overview, media, wallpaper, weather", default: "" }
        ]
    }
};

function getActionTypes() {
    return ACTION_TYPES;
}

function getDmsActionArgs() {
    return DMS_ACTION_ARGS;
}

function getDmsActions(isNiri, isHyprland) {
    const result = [];
    for (let i = 0; i < DMS_ACTIONS.length; i++) {
        const action = DMS_ACTIONS[i];
        if (!action.compositor) {
            result.push(action);
            continue;
        }
        switch (action.compositor) {
            case "niri":
                if (isNiri)
                    result.push(action);
                break;
            case "hyprland":
                if (isHyprland)
                    result.push(action);
                break;
        }
    }
    return result;
}

function getCompositorCategories(compositor) {
    var actions = COMPOSITOR_ACTIONS[compositor];
    if (!actions)
        return [];
    return Object.keys(actions);
}

function getCompositorActions(compositor, category) {
    var actions = COMPOSITOR_ACTIONS[compositor];
    if (!actions)
        return [];
    return actions[category] || [];
}

function getCategoryOrder() {
    return CATEGORY_ORDER;
}

function findDmsAction(actionId) {
    for (let i = 0; i < DMS_ACTIONS.length; i++) {
        if (DMS_ACTIONS[i].id === actionId)
            return DMS_ACTIONS[i];
    }
    return null;
}

function findCompositorAction(compositor, actionId) {
    var actions = COMPOSITOR_ACTIONS[compositor];
    if (!actions)
        return null;
    for (const cat in actions) {
        const acts = actions[cat];
        for (let i = 0; i < acts.length; i++) {
            if (acts[i].id === actionId)
                return acts[i];
        }
    }
    return null;
}

function getActionLabel(action, compositor) {
    if (!action)
        return "";

    var dmsAct = findDmsAction(action);
    if (dmsAct)
        return dmsAct.label;

    if (compositor) {
        var compAct = findCompositorAction(compositor, action);
        if (compAct)
            return compAct.label;
        var base = action.split(" ")[0];
        compAct = findCompositorAction(compositor, base);
        if (compAct)
            return compAct.label;
    }

    if (action.startsWith("spawn sh -c "))
        return action.slice(12).replace(/^["']|["']$/g, "");
    if (action.startsWith("spawn "))
        return action.slice(6);
    return action;
}

function getActionType(action) {
    if (!action)
        return "compositor";
    if (action.startsWith("spawn dms ipc call "))
        return "dms";
    if (/^spawn \w+ -c /.test(action) || action.startsWith("spawn_shell "))
        return "shell";
    if (action.startsWith("spawn "))
        return "spawn";
    return "compositor";
}

function isDmsAction(action) {
    if (!action)
        return false;
    return action.startsWith("spawn dms ipc call ");
}

function isValidAction(action) {
    if (!action)
        return false;
    switch (action) {
        case "spawn":
        case "spawn ":
        case "spawn sh -c \"\"":
        case "spawn sh -c ''":
        case "spawn_shell":
        case "spawn_shell ":
            return false;
    }
    return true;
}

function isKnownCompositorAction(compositor, action) {
    if (!action || !compositor)
        return false;
    var found = findCompositorAction(compositor, action);
    if (found)
        return true;
    var base = action.split(" ")[0];
    return findCompositorAction(compositor, base) !== null;
}

function buildSpawnAction(command, args) {
    if (!command)
        return "";
    let parts = [command];
    if (args && args.length > 0)
        parts = parts.concat(args.filter(function (a) { return a; }));
    return "spawn " + parts.join(" ");
}

function buildShellAction(compositor, shellCmd, shell) {
    if (!shellCmd)
        return "";
    if (compositor === "mangowc")
        return "spawn_shell " + shellCmd;
    var shellBin = shell || "sh";
    return "spawn " + shellBin + " -c \"" + shellCmd.replace(/"/g, "\\\"") + "\"";
}

function parseSpawnCommand(action) {
    if (!action || !action.startsWith("spawn "))
        return { command: "", args: [] };
    const rest = action.slice(6);
    const parts = rest.split(" ").filter(function (p) { return p; });
    return {
        command: parts[0] || "",
        args: parts.slice(1)
    };
}

function parseShellCommand(action) {
    if (!action)
        return "";
    var match = action.match(/^spawn (\w+) -c (.+)$/);
    if (match) {
        var content = match[2];
        if ((content.startsWith('"') && content.endsWith('"')) || (content.startsWith("'") && content.endsWith("'")))
            content = content.slice(1, -1);
        return content.replace(/\\"/g, "\"");
    }
    if (action.startsWith("spawn_shell "))
        return action.slice(12);
    return "";
}

function getShellFromAction(action) {
    if (!action)
        return "sh";
    var match = action.match(/^spawn (\w+) -c /);
    return match ? match[1] : "sh";
}

function getActionArgConfig(compositor, action) {
    if (!action)
        return null;

    var baseAction = action.split(" ")[0];
    var compositorArgs = ACTION_ARGS[compositor];
    if (compositorArgs && compositorArgs[baseAction])
        return { type: "compositor", base: baseAction, config: compositorArgs[baseAction] };

    for (var key in DMS_ACTION_ARGS) {
        if (action.startsWith(DMS_ACTION_ARGS[key].base))
            return { type: "dms", base: key, config: DMS_ACTION_ARGS[key] };
    }

    return null;
}

function parseCompositorActionArgs(compositor, action) {
    if (!action)
        return { base: "", args: {} };

    var parts = action.split(" ");
    var base = parts[0];
    var args = {};

    var compositorArgs = ACTION_ARGS[compositor];
    if (!compositorArgs || !compositorArgs[base])
        return { base: action, args: {} };

    var argConfig = compositorArgs[base];
    var argParts = parts.slice(1);

    switch (compositor) {
        case "niri":
            switch (base) {
                case "move-column-to-workspace":
                    for (var i = 0; i < argParts.length; i++) {
                        if (argParts[i] === "focus=true" || argParts[i] === "focus=false") {
                            args.focus = argParts[i] === "focus=true";
                        } else if (!args.index) {
                            args.index = argParts[i];
                        }
                    }
                    break;
                case "move-column-to-workspace-down":
                case "move-column-to-workspace-up":
                    for (var k = 0; k < argParts.length; k++) {
                        if (argParts[k] === "focus=true" || argParts[k] === "focus=false")
                            args.focus = argParts[k] === "focus=true";
                    }
                    break;
                default:
                    for (var j = 0; j < argParts.length; j++) {
                        var kv = argParts[j].split("=");
                        if (kv.length === 2) {
                            switch (kv[1]) {
                                case "true":
                                    args[kv[0]] = true;
                                    break;
                                case "false":
                                    args[kv[0]] = false;
                                    break;
                                default:
                                    args[kv[0]] = kv[1];
                            }
                        } else {
                            args.value = args.value ? (args.value + " " + argParts[j]) : argParts[j];
                        }
                    }
            }
            break;
        case "mangowc":
            if (argConfig.args && argConfig.args.length > 0 && argParts.length > 0) {
                var paramStr = argParts.join(" ");
                var paramValues = paramStr.split(",");
                for (var m = 0; m < argConfig.args.length && m < paramValues.length; m++) {
                    args[argConfig.args[m].name] = paramValues[m];
                }
            }
            break;
        case "hyprland":
            if (argConfig.args && argConfig.args.length > 0) {
                switch (base) {
                    case "resizewindowpixel":
                    case "movewindowpixel":
                        var commaIdx = argParts.join(" ").indexOf(",");
                        if (commaIdx !== -1) {
                            var fullStr = argParts.join(" ");
                            args[argConfig.args[0].name] = fullStr.substring(0, commaIdx);
                            args[argConfig.args[1].name] = fullStr.substring(commaIdx + 1);
                        } else if (argParts.length > 0) {
                            args[argConfig.args[0].name] = argParts.join(" ");
                        }
                        break;
                    case "movetoworkspace":
                    case "movetoworkspacesilent":
                    case "tagwindow":
                    case "alterzorder":
                        if (argParts.length >= 2) {
                            args[argConfig.args[0].name] = argParts[0];
                            args[argConfig.args[1].name] = argParts.slice(1).join(" ");
                        } else if (argParts.length === 1) {
                            args[argConfig.args[0].name] = argParts[0];
                        }
                        break;
                    case "moveworkspacetomonitor":
                    case "swapactiveworkspaces":
                    case "renameworkspace":
                    case "fullscreenstate":
                    case "movecursor":
                        if (argParts.length >= 2) {
                            args[argConfig.args[0].name] = argParts[0];
                            args[argConfig.args[1].name] = argParts[1];
                        } else if (argParts.length === 1) {
                            args[argConfig.args[0].name] = argParts[0];
                        }
                        break;
                    case "setprop":
                        if (argParts.length >= 3) {
                            args.window = argParts[0];
                            args.property = argParts[1];
                            args.value = argParts.slice(2).join(" ");
                        } else if (argParts.length === 2) {
                            args.window = argParts[0];
                            args.property = argParts[1];
                        }
                        break;
                    case "sendshortcut":
                        if (argParts.length >= 3) {
                            args.mod = argParts[0];
                            args.key = argParts[1];
                            args.window = argParts.slice(2).join(" ");
                        } else if (argParts.length >= 2) {
                            args.mod = argParts[0];
                            args.key = argParts[1];
                        }
                        break;
                    case "sendkeystate":
                        if (argParts.length >= 4) {
                            args.mod = argParts[0];
                            args.key = argParts[1];
                            args.state = argParts[2];
                            args.window = argParts.slice(3).join(" ");
                        }
                        break;
                    case "signalwindow":
                        if (argParts.length >= 2) {
                            args.window = argParts[0];
                            args.signal = argParts[1];
                        }
                        break;
                    default:
                        if (argParts.length > 0) {
                            if (argConfig.args.length === 1) {
                                args[argConfig.args[0].name] = argParts.join(" ");
                            } else {
                                args.value = argParts.join(" ");
                            }
                        }
                }
            }
            break;
        default:
            if (argParts.length > 0)
                args.value = argParts.join(" ");
    }

    return { base: base, args: args };
}

function buildCompositorAction(compositor, base, args) {
    if (!base)
        return "";

    var parts = [base];

    if (!args || Object.keys(args).length === 0)
        return base;

    switch (compositor) {
        case "niri":
            switch (base) {
                case "move-column-to-workspace":
                    if (args.index)
                        parts.push(args.index);
                    if (args.focus === false)
                        parts.push("focus=false");
                    break;
                case "move-column-to-workspace-down":
                case "move-column-to-workspace-up":
                    if (args.focus === false)
                        parts.push("focus=false");
                    break;
                default:
                    if (args.value)
                        parts.push(args.value);
                    else if (args.index)
                        parts.push(args.index);
                    for (var prop in args) {
                        switch (prop) {
                            case "value":
                            case "index":
                                continue;
                        }
                        var val = args[prop];
                        if (val === true)
                            parts.push(prop + "=true");
                        else if (val === false)
                            parts.push(prop + "=false");
                        else if (val !== undefined && val !== null && val !== "")
                            parts.push(prop + "=" + val);
                    }
            }
            break;
        case "mangowc":
            var compositorArgs = ACTION_ARGS.mangowc;
            if (compositorArgs && compositorArgs[base] && compositorArgs[base].args) {
                var argConfig = compositorArgs[base].args;
                var argValues = [];
                for (var i = 0; i < argConfig.length; i++) {
                    var argDef = argConfig[i];
                    var val = args[argDef.name];
                    if (val === undefined || val === "")
                        val = argDef.default || "";
                    if (val === "" && argValues.length === 0)
                        continue;
                    argValues.push(val);
                }
                if (argValues.length > 0)
                    parts.push(argValues.join(","));
            } else if (args.value) {
                parts.push(args.value);
            }
            break;
        case "hyprland":
            var hyprArgs = ACTION_ARGS.hyprland;
            if (hyprArgs && hyprArgs[base] && hyprArgs[base].args) {
                var hyprConfig = hyprArgs[base].args;
                switch (base) {
                    case "resizewindowpixel":
                    case "movewindowpixel":
                        if (args[hyprConfig[0].name])
                            parts.push(args[hyprConfig[0].name]);
                        if (args[hyprConfig[1].name])
                            parts[parts.length - 1] += "," + args[hyprConfig[1].name];
                        break;
                    case "setprop":
                        if (args.window)
                            parts.push(args.window);
                        if (args.property)
                            parts.push(args.property);
                        if (args.value)
                            parts.push(args.value);
                        break;
                    case "sendshortcut":
                        if (args.mod)
                            parts.push(args.mod);
                        if (args.key)
                            parts.push(args.key);
                        if (args.window)
                            parts.push(args.window);
                        break;
                    case "sendkeystate":
                        if (args.mod)
                            parts.push(args.mod);
                        if (args.key)
                            parts.push(args.key);
                        if (args.state)
                            parts.push(args.state);
                        if (args.window)
                            parts.push(args.window);
                        break;
                    case "signalwindow":
                        if (args.window)
                            parts.push(args.window);
                        if (args.signal)
                            parts.push(args.signal);
                        break;
                    default:
                        for (var j = 0; j < hyprConfig.length; j++) {
                            var hVal = args[hyprConfig[j].name];
                            if (hVal !== undefined && hVal !== "")
                                parts.push(hVal);
                        }
                }
            } else if (args.value) {
                parts.push(args.value);
            }
            break;
        default:
            if (args.value)
                parts.push(args.value);
    }

    return parts.join(" ");
}

function parseDmsActionArgs(action) {
    if (!action)
        return { base: "", args: {} };

    for (var key in DMS_ACTION_ARGS) {
        var config = DMS_ACTION_ARGS[key];
        if (!action.startsWith(config.base))
            continue;

        var rest = action.slice(config.base.length).trim();
        var result = { base: key, args: {} };

        if (!rest)
            return result;

        var tokens = [];
        var current = "";
        var inQuotes = false;
        var hadQuotes = false;
        for (var i = 0; i < rest.length; i++) {
            var c = rest[i];
            switch (c) {
                case '"':
                    inQuotes = !inQuotes;
                    hadQuotes = true;
                    break;
                case ' ':
                    if (inQuotes) {
                        current += c;
                    } else if (current || hadQuotes) {
                        tokens.push(current);
                        current = "";
                        hadQuotes = false;
                    }
                    break;
                default:
                    current += c;
                    break;
            }
        }
        if (current || hadQuotes)
            tokens.push(current);

        for (var j = 0; j < config.args.length && j < tokens.length; j++) {
            result.args[config.args[j].name] = tokens[j];
        }

        return result;
    }

    return { base: action, args: {} };
}

function buildDmsAction(baseKey, args) {
    var config = DMS_ACTION_ARGS[baseKey];
    if (!config)
        return "";

    var parts = [config.base];

    for (var i = 0; i < config.args.length; i++) {
        var argDef = config.args[i];
        var value = args?.[argDef.name];
        if (value === undefined || value === null)
            value = argDef.default ?? "";

        if (argDef.type === "text" && value === "") {
            parts.push('""');
        } else if (value !== "") {
            parts.push(value);
        } else {
            break;
        }
    }

    return parts.join(" ");
}

function getScreenshotOptions() {
    return [
        { id: "write-to-disk", label: "Save to disk", type: "bool" },
        { id: "show-pointer", label: "Show pointer", type: "bool" }
    ];
}