summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-01-16 12:14:22 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-01-16 12:14:22 +1100
commitf2945d0715fd9999805660e326e5eb848d8596ce (patch)
treed014e1bbfa502e9e5dacc715cdc12c1b7c355d7d
parentosds: volume mute colour and show on mute (diff)
downloadcaelestia-shell-f2945d0715fd9999805660e326e5eb848d8596ce.tar.gz
caelestia-shell-f2945d0715fd9999805660e326e5eb848d8596ce.tar.bz2
caelestia-shell-f2945d0715fd9999805660e326e5eb848d8596ce.zip
osds: config show value
-rw-r--r--config.ts2
-rw-r--r--modules/osds.tsx41
2 files changed, 25 insertions, 18 deletions
diff --git a/config.ts b/config.ts
index 597a9f7..3c22905 100644
--- a/config.ts
+++ b/config.ts
@@ -28,11 +28,13 @@ export const osds = {
position: Astal.WindowAnchor.RIGHT,
margin: 20,
hideDelay: 1500,
+ showValue: true,
},
brightness: {
position: Astal.WindowAnchor.LEFT,
margin: 20,
hideDelay: 1500,
+ showValue: true,
},
};
diff --git a/modules/osds.tsx b/modules/osds.tsx
index 5b6af8f..e8299b2 100644
--- a/modules/osds.tsx
+++ b/modules/osds.tsx
@@ -131,26 +131,30 @@ const SliderOsd = ({
cr.setAntialias(cairo.Antialias.BEST);
// Progress number, at top/right
- const numLayout = parent.create_pango_layout(String(Math.round(progressValue * 100)));
- const [nw, nh] = numLayout.get_pixel_size();
- let diff;
- if (vertical) {
- diff = ((1 - progressValue) * height) / nh;
- cr.moveTo((width - nw) / 2, radius / 2);
- } else {
- diff = ((1 - progressValue) * width) / nw;
- cr.moveTo(width - nw - radius, (height - nh) / 2);
- }
- diff = Math.max(0, Math.min(1, diff));
+ let nw = 0;
+ let nh = 0;
+ if (config[type].showValue) {
+ const numLayout = parent.create_pango_layout(String(Math.round(progressValue * 100)));
+ [nw, nh] = numLayout.get_pixel_size();
+ let diff;
+ if (vertical) {
+ diff = ((1 - progressValue) * height) / nh;
+ cr.moveTo((width - nw) / 2, radius / 2);
+ } else {
+ diff = ((1 - progressValue) * width) / nw;
+ cr.moveTo(width - nw - radius, (height - nh) / 2);
+ }
+ diff = Math.max(0, Math.min(1, diff));
- cr.setSourceRGBA(
- mix(bg.red, fg.red, diff),
- mix(bg.green, fg.green, diff),
- mix(bg.blue, fg.blue, diff),
- mix(bg.alpha, fg.alpha, diff)
- );
+ cr.setSourceRGBA(
+ mix(bg.red, fg.red, diff),
+ mix(bg.green, fg.green, diff),
+ mix(bg.blue, fg.blue, diff),
+ mix(bg.alpha, fg.alpha, diff)
+ );
- PangoCairo.show_layout(cr, numLayout);
+ PangoCairo.show_layout(cr, numLayout);
+ }
// Progress icon, follows progress
if (fontDesc === null) {
@@ -168,6 +172,7 @@ const SliderOsd = ({
iconLayout.set_text(icon.get(), -1);
const [iw, ih] = iconLayout.get_pixel_size();
+ let diff;
if (vertical) {
diff = (progressValue * height) / ih;
cr.moveTo(