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
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
import { find_icon } from "./iconUtils.js";
import { lookUpIcon, timeout } from 'resource:///com/github/Aylur/ags/utils.js';
export let clientMapWorkSpace = {};
export function substitute(str) {
const subs = [
{ from: "code-url-handler", to: "visual-studio-code" },
{ from: "Code", to: "visual-studio-code" },
{ from: "GitHub Desktop", to: "github-desktop" },
{ from: "wpsoffice", to: "wps-office2019-kprometheus" },
{ from: "gnome-tweaks", to: "org.gnome.tweaks" },
{ from: "Minecraft* 1.20.1", to: "minecraft" },
{ from: "", to: "image-missing" },
];
for (const { from, to } of subs) {
if (from === str) {
return to;
}
}
return str;
}
function titleToClient(title, className) {
const subs = [
{ from: "musicfox", to: "musicfox" },
];
for (const { from, to } of subs) {
if (title.indexOf(from) !== -1) {
return to;
}
}
return className
}
export const getClientByAdrees = function(address) {
const clients = Hyprland.clients
const client = clients.find(item => {
return item.address === address
})
return client
}
//Fullscreen client
export const getFullScreenClientAddress = function(workspace_id) {
const clients = Hyprland.clients
const client = clients.find(item => {
return item.fullscreen && item.workspace.id === workspace_id
})
return client
}
export const ignoreAppsClass = [
'image-missing',
'fcitx',
'rofi'
]
export const getClientIcon = (clientClass, title = "") => {
clientClass.toLowerCase()
clientClass = clientClass.replace(" ", "_");
if (title.length > 0) {
clientClass = titleToClient(title, clientClass)
}
const awesome_icon = find_icon(clientClass)
if (awesome_icon) {
return awesome_icon
}
if (lookUpIcon(clientClass)) {
return clientClass
}
if (find_icon('system')) {
return find_icon('system')
}
return ""
}
export const focus = (client) => {
//client
const { address } = client;
const liveClient = getClientByAdrees(address);
//special window
if (liveClient.workspace.id < 0) {
const oldWorkSpace = clientMapWorkSpace[address];
if (oldWorkSpace) {
Utils.exec(
`hyprctl dispatch movetoworkspace ${oldWorkSpace},address:${address}`,
);
Utils.exec(`hyprctl dispatch workspace ${oldWorkSpace}`);
}
}
//fullscreen
if (liveClient.fullscreen) {
Utils.exec("hyprctl dispatch focuswindow address:" + address);
return;
}
//workspace fullscreen client
const currentFullScreenAddress = getFullScreenClientAddress(
liveClient.workspace.id,
);
if (currentFullScreenAddress) {
const fullScreenAdress = currentFullScreenAddress.address;
Utils.exec("hyprctl dispatch focuswindow address:" + fullScreenAdress);
Utils.exec("hyprctl dispatch fullscreen 1");
}
Utils.exec("hyprctl dispatch focuswindow address:" + address);
// Utils.exec('hyprctl dispatch cyclenext')
Utils.exec("hyprctl dispatch alterzorder top,address:" + address);
if (currentFullScreenAddress) {
Utils.exec("hyprctl dispatch fullscreen 1");
}
};
|