feat: Ghost Shell v2 — AGS v3 statusbar + violet-chaton v2 palette
- AGS v3.1.0 (Astal/GTK3) Ghost Shell avec ghost mode (heartbeat + hover reveal) - Modules : clock, battery, volume (interactif), network, MPRIS, CPU/RAM, systray - Brain Power panel (Super + B) — lecture live focus/todos/session - tetardtek_ prompt avec curseur clignotant - Palette violet-chaton v2 documentée (Mitsuri Kanroji gradient magenta → green) - Autostart COSMIC via .desktop - Archive AGS v1 conservée pour référence
This commit is contained in:
228
ags-v1/widgets/Bar.js
Normal file
228
ags-v1/widgets/Bar.js
Normal file
@@ -0,0 +1,228 @@
|
||||
// ── violet-chaton v2 — Bar widget ───────────────────────────────────────────
|
||||
// 3 pills glassmorphism — modulaire selon compositor
|
||||
|
||||
const audio = Service.import("audio");
|
||||
const battery = Service.import("battery");
|
||||
const network = Service.import("network");
|
||||
const systemtray = Service.import("systemtray");
|
||||
const mpris = Service.import("mpris");
|
||||
|
||||
// ── Helpers ─────────────────────────────────────────────────────────────────
|
||||
|
||||
const Separator = () => Widget.Label({ className: "separator", label: "│" });
|
||||
|
||||
const Clock = () => Widget.Label({
|
||||
className: "clock",
|
||||
connections: [[1000, (self) => {
|
||||
self.label = Utils.exec("date +%H:%M");
|
||||
}]],
|
||||
});
|
||||
|
||||
const DateWidget = () => Widget.Label({
|
||||
className: "date",
|
||||
connections: [[60000, (self) => {
|
||||
self.label = Utils.exec("date '+%a %d %b'");
|
||||
}]],
|
||||
});
|
||||
|
||||
// ── System ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const CPU = () => Widget.Label({
|
||||
className: "cpu",
|
||||
connections: [[2000, (self) => {
|
||||
const usage = Math.round(
|
||||
Number(Utils.exec(`bash -c "top -bn1 | awk '/^%Cpu/ {print 100-$8}'"`)
|
||||
));
|
||||
self.label = ` ${usage}%`;
|
||||
self.toggleClassName("warning", usage > 70);
|
||||
self.toggleClassName("critical", usage > 90);
|
||||
}]],
|
||||
});
|
||||
|
||||
const RAM = () => Widget.Label({
|
||||
className: "ram",
|
||||
connections: [[2000, (self) => {
|
||||
const used = Utils.exec(`bash -c "free -m | awk '/^Mem:/ {printf \"%.1f\", $3/1024}'"`)
|
||||
const total = Utils.exec(`bash -c "free -m | awk '/^Mem:/ {printf \"%.1f\", $2/1024}'"`)
|
||||
const pct = Math.round((parseFloat(used) / parseFloat(total)) * 100);
|
||||
self.label = ` ${used}G`;
|
||||
self.toggleClassName("warning", pct > 70);
|
||||
self.toggleClassName("critical", pct > 90);
|
||||
}]],
|
||||
});
|
||||
|
||||
// ── Network ─────────────────────────────────────────────────────────────────
|
||||
|
||||
const Network = () => Widget.Label({
|
||||
className: "network",
|
||||
connections: [[network, (self) => {
|
||||
if (network.primary === "wifi") {
|
||||
const wifi = network.wifi;
|
||||
self.label = ` ${wifi?.ssid || ""}`;
|
||||
self.toggleClassName("wifi", true);
|
||||
self.toggleClassName("disconnected", false);
|
||||
} else if (network.primary === "wired") {
|
||||
self.label = " Eth";
|
||||
self.toggleClassName("wifi", false);
|
||||
self.toggleClassName("disconnected", false);
|
||||
} else {
|
||||
self.label = " ";
|
||||
self.toggleClassName("disconnected", true);
|
||||
}
|
||||
}]],
|
||||
});
|
||||
|
||||
// ── Volume ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const Volume = () => Widget.Button({
|
||||
className: "volume",
|
||||
onClicked: () => { audio.speaker.isMuted = !audio.speaker.isMuted; },
|
||||
child: Widget.Label({
|
||||
connections: [[audio, (self) => {
|
||||
const vol = Math.round((audio.speaker?.volume || 0) * 100);
|
||||
const muted = audio.speaker?.isMuted;
|
||||
const icon = muted ? "" : vol > 66 ? "" : vol > 33 ? "" : "";
|
||||
self.label = `${icon} ${vol}%`;
|
||||
self.parent?.toggleClassName("muted", muted);
|
||||
}, "speaker-changed"]],
|
||||
}),
|
||||
});
|
||||
|
||||
// ── Battery ─────────────────────────────────────────────────────────────────
|
||||
|
||||
const Battery = () => Widget.Label({
|
||||
className: "battery",
|
||||
visible: battery.bind("available"),
|
||||
connections: [[battery, (self) => {
|
||||
const pct = battery.percent;
|
||||
const charging = battery.charging;
|
||||
const icon = charging ? "" : pct > 80 ? "" : pct > 60 ? "" :
|
||||
pct > 40 ? "" : pct > 20 ? "" : "";
|
||||
self.label = `${icon} ${pct}%`;
|
||||
self.toggleClassName("charging", charging);
|
||||
self.toggleClassName("low", pct <= 20 && !charging);
|
||||
self.toggleClassName("warning", pct <= 30 && !charging);
|
||||
}]],
|
||||
});
|
||||
|
||||
// ── Media ───────────────────────────────────────────────────────────────────
|
||||
|
||||
const Media = () => Widget.Label({
|
||||
className: "media",
|
||||
connections: [[mpris, (self) => {
|
||||
const player = mpris.players[0];
|
||||
if (!player) {
|
||||
self.visible = false;
|
||||
return;
|
||||
}
|
||||
self.visible = true;
|
||||
const artist = player.trackArtists?.join(", ") || "";
|
||||
const title = player.trackTitle || "";
|
||||
const icon = player.playBackStatus === "Playing" ? " " : " ";
|
||||
self.label = `${icon}${artist ? artist + " — " : ""}${title}`.slice(0, 50);
|
||||
self.toggleClassName("paused", player.playBackStatus !== "Playing");
|
||||
}]],
|
||||
});
|
||||
|
||||
// ── Systray ─────────────────────────────────────────────────────────────────
|
||||
|
||||
const SysTray = () => Widget.Box({
|
||||
className: "systray",
|
||||
children: systemtray.bind("items").transform((items) =>
|
||||
items.map((item) =>
|
||||
Widget.Button({
|
||||
child: Widget.Icon({ icon: item.bind("icon"), size: 16 }),
|
||||
tooltipMarkup: item.bind("tooltip-markup"),
|
||||
onPrimaryClick: (_, event) => item.activate(event),
|
||||
onSecondaryClick: (_, event) => item.openMenu(event),
|
||||
})
|
||||
)
|
||||
),
|
||||
});
|
||||
|
||||
// ── Launcher button ─────────────────────────────────────────────────────────
|
||||
|
||||
const LauncherBtn = () => Widget.Button({
|
||||
className: "launcher-btn",
|
||||
label: "",
|
||||
onClicked: () => App.toggleWindow("launcher"),
|
||||
});
|
||||
|
||||
// ── Power button ────────────────────────────────────────────────────────────
|
||||
|
||||
const PowerBtn = () => Widget.Button({
|
||||
className: "power-btn",
|
||||
label: "⏻",
|
||||
onClicked: () => Utils.exec("bash -c 'systemctl poweroff'"),
|
||||
});
|
||||
|
||||
// ── Workspaces (Hyprland only) ──────────────────────────────────────────────
|
||||
|
||||
const Workspaces = (compositor) => {
|
||||
if (compositor !== "hyprland") return Widget.Box({});
|
||||
|
||||
const hyprland = Service.import("hyprland");
|
||||
return Widget.Box({
|
||||
className: "workspaces",
|
||||
children: hyprland.bind("workspaces").transform((ws) =>
|
||||
ws.sort((a, b) => a.id - b.id)
|
||||
.filter((w) => w.id > 0)
|
||||
.map((w) =>
|
||||
Widget.Button({
|
||||
onClicked: () => hyprland.messageAsync(`dispatch workspace ${w.id}`),
|
||||
child: Widget.Label({ label: `${w.id}` }),
|
||||
className: hyprland.active.workspace.bind("id").transform(
|
||||
(id) => id === w.id ? "active" : w.windows > 0 ? "occupied" : ""
|
||||
),
|
||||
})
|
||||
)
|
||||
),
|
||||
});
|
||||
};
|
||||
|
||||
// ── Bar assembly ────────────────────────────────────────────────────────────
|
||||
|
||||
export const Bar = (monitor, compositor) => Widget.Window({
|
||||
name: `bar-${monitor}`,
|
||||
monitor,
|
||||
anchor: ["top", "left", "right"],
|
||||
exclusivity: "exclusive",
|
||||
className: "bar",
|
||||
child: Widget.CenterBox({
|
||||
startWidget: Widget.Box({
|
||||
className: "modules-left",
|
||||
children: [
|
||||
LauncherBtn(),
|
||||
Separator(),
|
||||
Workspaces(compositor),
|
||||
Separator(),
|
||||
CPU(),
|
||||
RAM(),
|
||||
],
|
||||
}),
|
||||
centerWidget: Widget.Box({
|
||||
className: "modules-center",
|
||||
children: [
|
||||
Media(),
|
||||
],
|
||||
}),
|
||||
endWidget: Widget.Box({
|
||||
className: "modules-right",
|
||||
hpack: "end",
|
||||
children: [
|
||||
Network(),
|
||||
Separator(),
|
||||
Volume(),
|
||||
Separator(),
|
||||
Battery(),
|
||||
Separator(),
|
||||
DateWidget(),
|
||||
Clock(),
|
||||
Separator(),
|
||||
SysTray(),
|
||||
Separator(),
|
||||
PowerBtn(),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
});
|
||||
99
ags-v1/widgets/Launcher.js
Normal file
99
ags-v1/widgets/Launcher.js
Normal file
@@ -0,0 +1,99 @@
|
||||
// ── violet-chaton v2 — Launcher widget ──────────────────────────────────────
|
||||
// App launcher avec recherche fuzzy
|
||||
|
||||
const applications = Service.import("applications");
|
||||
|
||||
const AppItem = (app) => Widget.Button({
|
||||
className: "app-item",
|
||||
onClicked: () => {
|
||||
app.launch();
|
||||
App.closeWindow("launcher");
|
||||
},
|
||||
child: Widget.Box({
|
||||
children: [
|
||||
Widget.Icon({ icon: app.iconName || "application-x-executable", size: 24 }),
|
||||
Widget.Box({
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Label({
|
||||
label: app.name,
|
||||
xalign: 0,
|
||||
truncate: "end",
|
||||
}),
|
||||
Widget.Label({
|
||||
label: app.description || "",
|
||||
xalign: 0,
|
||||
truncate: "end",
|
||||
className: "description",
|
||||
css: "color: #716686; font-size: 11px; font-weight: normal;",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
export const Launcher = (monitor) => {
|
||||
let apps = applications.list;
|
||||
|
||||
const list = Widget.Box({
|
||||
vertical: true,
|
||||
spacing: 2,
|
||||
});
|
||||
|
||||
const entry = Widget.Entry({
|
||||
className: "search",
|
||||
placeholderText: "Rechercher...",
|
||||
onAccept: () => {
|
||||
const first = apps[0];
|
||||
if (first) {
|
||||
first.launch();
|
||||
App.closeWindow("launcher");
|
||||
}
|
||||
},
|
||||
onChange: ({ text }) => {
|
||||
apps = applications.query(text || "");
|
||||
list.children = apps.slice(0, 12).map(AppItem);
|
||||
|
||||
if (apps.length === 0) {
|
||||
list.children = [Widget.Label({
|
||||
className: "no-results",
|
||||
label: "Aucun resultat",
|
||||
})];
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return Widget.Window({
|
||||
name: "launcher",
|
||||
monitor,
|
||||
anchor: ["top"],
|
||||
layer: "overlay",
|
||||
visible: false,
|
||||
keymode: "exclusive",
|
||||
setup: (self) => {
|
||||
self.keybind("Escape", () => App.closeWindow("launcher"));
|
||||
self.hook(App, (_, name, visible) => {
|
||||
if (name === "launcher" && visible) {
|
||||
entry.text = "";
|
||||
apps = applications.list;
|
||||
list.children = apps.slice(0, 12).map(AppItem);
|
||||
entry.grab_focus();
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Widget.Box({
|
||||
className: "launcher",
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Scrollable({
|
||||
hscroll: "never",
|
||||
vscroll: "automatic",
|
||||
css: "min-height: 400px;",
|
||||
child: list,
|
||||
}),
|
||||
entry,
|
||||
],
|
||||
}),
|
||||
});
|
||||
};
|
||||
105
ags-v1/widgets/Notifications.js
Normal file
105
ags-v1/widgets/Notifications.js
Normal file
@@ -0,0 +1,105 @@
|
||||
// ── violet-chaton v2 — Notifications widget ─────────────────────────────────
|
||||
// Popup notifications stylees — urgency-aware
|
||||
|
||||
const notifications = Service.import("notifications");
|
||||
|
||||
// Ne pas déranger
|
||||
notifications.popupTimeout = 5000;
|
||||
notifications.cacheActions = true;
|
||||
|
||||
const NotificationIcon = (notif) => {
|
||||
if (notif.image) {
|
||||
return Widget.Box({
|
||||
css: `
|
||||
min-width: 48px; min-height: 48px;
|
||||
background-image: url("${notif.image}");
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
border-radius: 8px;
|
||||
margin-right: 10px;
|
||||
`,
|
||||
});
|
||||
}
|
||||
return Widget.Icon({
|
||||
icon: notif.appIcon || notif.appEntry || "dialog-information",
|
||||
size: 36,
|
||||
css: "margin-right: 10px;",
|
||||
});
|
||||
};
|
||||
|
||||
const Notification = (notif) => Widget.Box({
|
||||
className: `notification ${notif.urgency}`,
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Box({
|
||||
children: [
|
||||
NotificationIcon(notif),
|
||||
Widget.Box({
|
||||
vertical: true,
|
||||
hexpand: true,
|
||||
children: [
|
||||
Widget.Box({
|
||||
children: [
|
||||
Widget.Label({
|
||||
className: "title",
|
||||
label: notif.summary,
|
||||
xalign: 0,
|
||||
hexpand: true,
|
||||
truncate: "end",
|
||||
}),
|
||||
Widget.Label({
|
||||
className: "time",
|
||||
label: new Date(notif.time * 1000)
|
||||
.toLocaleTimeString("fr-FR", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
}),
|
||||
}),
|
||||
Widget.Button({
|
||||
className: "close-btn",
|
||||
label: "✕",
|
||||
onClicked: () => notif.close(),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
Widget.Label({
|
||||
className: "app-name",
|
||||
label: notif.appName || "",
|
||||
xalign: 0,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
...(notif.body ? [Widget.Label({
|
||||
className: "body",
|
||||
label: notif.body,
|
||||
xalign: 0,
|
||||
wrap: true,
|
||||
useMarkup: true,
|
||||
})] : []),
|
||||
...(notif.actions.length > 0 ? [Widget.Box({
|
||||
className: "actions",
|
||||
children: notif.actions.map((action) =>
|
||||
Widget.Button({
|
||||
label: action.label,
|
||||
onClicked: () => notif.invoke(action.id),
|
||||
})
|
||||
),
|
||||
})] : []),
|
||||
],
|
||||
});
|
||||
|
||||
export const Notifications = (monitor) => Widget.Window({
|
||||
name: `notifications-${monitor}`,
|
||||
monitor,
|
||||
anchor: ["top", "right"],
|
||||
layer: "overlay",
|
||||
child: Widget.Box({
|
||||
vertical: true,
|
||||
css: "min-width: 350px;",
|
||||
children: notifications.bind("popups").transform((popups) =>
|
||||
popups.map(Notification)
|
||||
),
|
||||
}),
|
||||
});
|
||||
95
ags-v1/widgets/OSD.js
Normal file
95
ags-v1/widgets/OSD.js
Normal file
@@ -0,0 +1,95 @@
|
||||
// ── violet-chaton v2 — OSD widget ───────────────────────────────────────────
|
||||
// Overlay volume / brightness avec gradient Mitsuri
|
||||
|
||||
const audio = Service.import("audio");
|
||||
|
||||
// ── OSD reveal timer ────────────────────────────────────────────────────────
|
||||
|
||||
let osdTimeout = null;
|
||||
|
||||
const showOSD = (window) => {
|
||||
window.visible = true;
|
||||
if (osdTimeout) clearTimeout(osdTimeout);
|
||||
osdTimeout = setTimeout(() => {
|
||||
window.visible = false;
|
||||
}, 1500);
|
||||
};
|
||||
|
||||
// ── Volume OSD ──────────────────────────────────────────────────────────────
|
||||
|
||||
const VolumeOSD = () => {
|
||||
const icon = Widget.Label({ className: "icon" });
|
||||
const progress = Widget.ProgressBar();
|
||||
const label = Widget.Label({ className: "label" });
|
||||
|
||||
const box = Widget.Box({
|
||||
className: "osd",
|
||||
children: [icon, progress, label],
|
||||
connections: [[audio, (self) => {
|
||||
const vol = audio.speaker?.volume || 0;
|
||||
const muted = audio.speaker?.isMuted;
|
||||
icon.label = muted ? "" : vol > 0.66 ? "" : vol > 0.33 ? "" : "";
|
||||
progress.value = vol;
|
||||
label.label = `${Math.round(vol * 100)}%`;
|
||||
}, "speaker-changed"]],
|
||||
});
|
||||
|
||||
return box;
|
||||
};
|
||||
|
||||
// ── Brightness OSD ──────────────────────────────────────────────────────────
|
||||
|
||||
const BrightnessOSD = () => {
|
||||
const icon = Widget.Label({ className: "icon", label: "" });
|
||||
const progress = Widget.ProgressBar();
|
||||
const label = Widget.Label({ className: "label" });
|
||||
|
||||
const getBrightness = () => {
|
||||
try {
|
||||
const max = Number(Utils.exec("brightnessctl max"));
|
||||
const cur = Number(Utils.exec("brightnessctl get"));
|
||||
return max > 0 ? cur / max : 0;
|
||||
} catch {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
const box = Widget.Box({
|
||||
className: "osd",
|
||||
children: [icon, progress, label],
|
||||
connections: [[500, (self) => {
|
||||
const val = getBrightness();
|
||||
progress.value = val;
|
||||
label.label = `${Math.round(val * 100)}%`;
|
||||
}]],
|
||||
});
|
||||
|
||||
return box;
|
||||
};
|
||||
|
||||
// ── OSD windows ─────────────────────────────────────────────────────────────
|
||||
|
||||
export const OSD = (monitor) => {
|
||||
const volumeWin = Widget.Window({
|
||||
name: `osd-volume-${monitor}`,
|
||||
monitor,
|
||||
anchor: ["bottom"],
|
||||
layer: "overlay",
|
||||
visible: false,
|
||||
child: VolumeOSD(),
|
||||
});
|
||||
|
||||
const brightnessWin = Widget.Window({
|
||||
name: `osd-brightness-${monitor}`,
|
||||
monitor,
|
||||
anchor: ["bottom"],
|
||||
layer: "overlay",
|
||||
visible: false,
|
||||
child: BrightnessOSD(),
|
||||
});
|
||||
|
||||
// Auto-show on volume change
|
||||
Utils.merge([audio.speaker?.bind("volume")], () => showOSD(volumeWin));
|
||||
|
||||
return [volumeWin, brightnessWin];
|
||||
};
|
||||
Reference in New Issue
Block a user