summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-13 23:11:12 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-13 23:11:12 +1000
commit80017cbeb91c37865f02b160c91f54d4b4fba39c (patch)
tree0e35b2bf6da65825f3faf89f901cb50788275bac /src
parentfeat: add music visualiser (diff)
downloadcaelestia-shell-80017cbeb91c37865f02b160c91f54d4b4fba39c.tar.gz
caelestia-shell-80017cbeb91c37865f02b160c91f54d4b4fba39c.tar.bz2
caelestia-shell-80017cbeb91c37865f02b160c91f54d4b4fba39c.zip
navbar: add mediadisplay toggle
Also better error message for visualiser
Diffstat (limited to 'src')
-rw-r--r--src/modules/mediadisplay/visualiser.tsx2
-rw-r--r--src/modules/navbar.tsx42
2 files changed, 42 insertions, 2 deletions
diff --git a/src/modules/mediadisplay/visualiser.tsx b/src/modules/mediadisplay/visualiser.tsx
index fa1adc6..9eacd44 100644
--- a/src/modules/mediadisplay/visualiser.tsx
+++ b/src/modules/mediadisplay/visualiser.tsx
@@ -33,7 +33,7 @@ export default () => (
// Show error text if cava unavailable
const fg = self.get_style_context().get_color(Gtk.StateFlags.NORMAL);
cr.setSourceRGBA(fg.red, fg.green, fg.blue, fg.alpha);
- const layout = self.create_pango_layout("Visualiser unavailable");
+ const layout = self.create_pango_layout("Visualiser module requires Cava");
const [w, h] = layout.get_pixel_size();
cr.moveTo((width - w) / 2, (height - h) / 2);
cr.setAntialias(cairo.Antialias.BEST);
diff --git a/src/modules/navbar.tsx b/src/modules/navbar.tsx
index 3e2b1c9..35d3900 100644
--- a/src/modules/navbar.tsx
+++ b/src/modules/navbar.tsx
@@ -2,12 +2,15 @@ import type { Monitor } from "@/services/monitors";
import { capitalize } from "@/utils/strings";
import type { AstalWidget } from "@/utils/types";
import { bind, execAsync, Variable } from "astal";
-import { Astal, Gtk } from "astal/gtk3";
+import { App, Astal, Gtk } from "astal/gtk3";
import { navbar as config } from "config";
import AstalHyprland from "gi://AstalHyprland";
import Pango from "gi://Pango";
import SideBar, { awaitSidebar, paneNames, switchPane, type PaneName } from "./sidebar";
+const layerNames = ["mediadisplay"] as const;
+type LayerName = `${(typeof layerNames)[number]}${number}`;
+
const specialWsNames = ["sysmon", "communication", "music", "todo"] as const;
type SpecialWsName = (typeof specialWsNames)[number];
@@ -20,6 +23,10 @@ const getPaneIcon = (name: PaneName) => {
return "date_range";
};
+const getLayerIcon = (name: LayerName) => {
+ return "graphic_eq";
+};
+
const getSpecialWsIcon = (name: SpecialWsName) => {
if (name === "sysmon") return "speed";
if (name === "communication") return "communication";
@@ -76,6 +83,36 @@ const PaneButton = ({
</button>
);
+const LayerButton = ({ name }: { name: LayerName }) => (
+ <button
+ cursor="pointer"
+ onClicked={() => App.toggle_window(name)}
+ setup={self =>
+ self.hook(App, "window-toggled", (_, window) => {
+ if (window.name === name) self.toggleClassName("current", window.visible);
+ })
+ }
+ >
+ <box vertical className="nav-button">
+ <label className="icon" label={getLayerIcon(name)} />
+ <revealer
+ transitionType={Gtk.RevealerTransitionType.SLIDE_DOWN}
+ transitionDuration={150}
+ setup={self => {
+ let visible = false;
+ self.hook(config.showLabels, (_, v) => self.toggleClassName(v && visible));
+ self.hook(App, "window-toggled", (_, window) => {
+ if (window.name === name)
+ self.toggleClassName("current", config.showLabels.get() && window.visible);
+ });
+ }}
+ >
+ <label truncate wrapMode={Pango.WrapMode.WORD_CHAR} className="label" label={capitalize(name)} />
+ </revealer>
+ </box>
+ </button>
+);
+
const SpecialWsButton = ({ name }: { name: SpecialWsName }) => {
const revealChild = Variable.derive(
[config.showLabels, bind(AstalHyprland.get_default(), "focusedClient")],
@@ -152,6 +189,9 @@ export default ({ monitor }: { monitor: Monitor }) => {
{paneNames.map(n => (
<PaneButton monitor={monitor} name={n} sidebar={sidebar} />
))}
+ {layerNames.map(n => (
+ <LayerButton name={`${n}${monitor.id}`} />
+ ))}
<box vexpand />
{specialWsNames.map(n => (
<SpecialWsButton name={n} />