swadhinbiswas Initial de-omarchy: Omarchy UI layer for Arch-based distros · 8/22/2026
9f393b2
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
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value))
}
// The widest glyph `iconFor` can return. The progress OSD sizes its icon
// column to it so the bar keeps its place as the icon changes.
var widestIcon = ""
function iconFor(name, percent) {
var n = String(name || "").toLowerCase()
if (n === "volume-muted" || n === "volume-mute" || n === "muted" || n === "mute") return ""
if (n === "volume-low") return ""
if (n === "volume-medium") return ""
if (n === "volume-high" || n === "volume") return ""
if (n === "microphone-muted" || n === "microphone-off" || n === "mic-muted" || n === "mic-off") return ""
if (n === "microphone" || n === "mic") return ""
if (n === "keyboard") return ""
if (n === "brightness" || n === "display") return ""
if (n === "touchpad") return ""
if (n === "touch" || n === "touchscreen") return ""
if (n === "reboot" || n === "restart") return ""
if (n === "shutdown" || n === "power" || n === "poweroff") return ""
if (n === "logout" || n === "sign-out" || n === "leave") return ""
if (n === "media" || n === "player") return ""
if (n === "media-source" || n === "player-source") return ""
if (n === "media-play" || n === "player-play") return ""
if (n === "media-pause" || n === "player-pause") return ""
if (n === "media-next" || n === "player-next") return ""
if (n === "media-previous" || n === "player-previous") return ""
if (n.length > 0) return name
if (percent <= 0) return ""
if (percent <= 33) return ""
if (percent <= 66) return ""
return ""
}
function stateForShow(iconName, rawMessage, rawValue, rawMax, rawProgressText, rawDuration) {
var maxValue = Math.max(1, parseInt(rawMax || "100", 10))
var parsedValue = parseInt(rawValue || "0", 10)
var hasProgress = rawValue !== "" && !isNaN(parsedValue) && rawMessage === ""
var value = hasProgress ? clamp(parsedValue, 0, maxValue) : 0
var percent = hasProgress ? Math.round(value * 100 / maxValue) : -1
var parsedDuration = parseInt(rawDuration || "1200", 10)
return {
iconKey: String(iconName || "").toLowerCase(),
maxValue: maxValue,
hasProgress: hasProgress,
value: value,
message: String(rawMessage || (hasProgress ? (rawProgressText || percent + "%") : "")),
icon: iconFor(iconName, percent),
duration: isNaN(parsedDuration) ? 1200 : Math.max(0, parsedDuration)
}
}
if (typeof module !== "undefined") {
module.exports = {
widestIcon: widestIcon,
iconFor: iconFor,
stateForShow: stateForShow
}
}