mirror of
https://github.com/zoriya/flake.git
synced 2026-06-04 03:06:54 +00:00
Move window manager exclusive to wm module
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
import { Clock } from "../modules/clock.js";
|
||||
import * as audio from "../modules/audio.js";
|
||||
import * as network from "../modules/network.js";
|
||||
import * as bluetooth from "../modules/bluetooth.js";
|
||||
import * as battery from "../modules/battery.js";
|
||||
import * as notifications from "../modules/notifications.js";
|
||||
|
||||
/**
|
||||
*@param {number} monitor
|
||||
*/
|
||||
export const Bar = (monitor) =>
|
||||
Widget.Window({
|
||||
monitor,
|
||||
name: `bar${monitor}`,
|
||||
className: "transparent",
|
||||
exclusivity: "exclusive",
|
||||
anchor: ["top", "left", "right"],
|
||||
layer: "bottom",
|
||||
child: Widget.CenterBox({
|
||||
startWidget: Widget.Box({
|
||||
children: [
|
||||
// dwl.Tags({
|
||||
// mon: monId,
|
||||
// labels: ["一", "二", "三", "四", "五", "六", "七", "八", "九"],
|
||||
// }),
|
||||
// dwl.Layout({
|
||||
// mon: monId,
|
||||
// }),
|
||||
// dwl.ClientLabel({ mon: monId }),
|
||||
],
|
||||
}),
|
||||
centerWidget: Widget.Box({
|
||||
hpack: "center",
|
||||
children: [
|
||||
Widget.Button({
|
||||
css: "min-width: 200px;",
|
||||
onClicked: () => App.toggleWindow("notifications"),
|
||||
child: notifications.Indicator({
|
||||
hexpand: true,
|
||||
hpack: "center",
|
||||
}),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
endWidget: Widget.Box({
|
||||
hpack: "end",
|
||||
children: [
|
||||
Widget.Button({
|
||||
onClicked: () => App.toggleWindow("quicksettings"),
|
||||
className: "module quicksettings",
|
||||
child: Widget.Box({
|
||||
children: [
|
||||
audio.MicrophoneIndicator({
|
||||
className: "qs-item",
|
||||
}),
|
||||
notifications.DNDIndicator({
|
||||
className: "qs-item",
|
||||
}),
|
||||
network.Indicator({ className: "qs-item" }),
|
||||
audio.VolumeIndicator({ className: "qs-item" }),
|
||||
bluetooth.Indicator({
|
||||
hideIfDisabled: true,
|
||||
className: "qs-item",
|
||||
}),
|
||||
battery.Indicator({ className: "qs-item" }),
|
||||
],
|
||||
}),
|
||||
}).hook(App, (self, win, visible) => {
|
||||
self.toggleClassName("active", win === "quicksettings" && visible);
|
||||
}),
|
||||
Clock({ format: "%a %d %b", className: "module bold" }),
|
||||
Clock({
|
||||
format: "%H:%M",
|
||||
className: "module accent bold",
|
||||
css: "margin-right: 0px",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
import PopupWindow from "../misc/popup.js";
|
||||
import * as notifications from "../modules/notifications.js";
|
||||
|
||||
const notificationsService = await Service.import("notifications");
|
||||
|
||||
const Header = () =>
|
||||
Widget.Box({
|
||||
hexpand: true,
|
||||
css: "margin-bottom: 40px",
|
||||
children: [
|
||||
notifications.DNDToggle({
|
||||
className: "surface p10 round",
|
||||
css: `
|
||||
min-width: 24px;
|
||||
min-height: 24px;
|
||||
`,
|
||||
hpack: "start",
|
||||
hexpand: true,
|
||||
}),
|
||||
notifications.ClearButton({
|
||||
hpack: "end",
|
||||
hexpand: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
export const Notifications = () =>
|
||||
PopupWindow({
|
||||
name: "notifications",
|
||||
exclusivity: "exclusive",
|
||||
transition: "slide_down",
|
||||
layout: "top-center",
|
||||
duration: 300,
|
||||
child: Widget.Box({
|
||||
vertical: true,
|
||||
className: "bgcont",
|
||||
css: `
|
||||
min-width: 600px;
|
||||
margin: 10px;
|
||||
padding: 12px;
|
||||
border-radius: 20px;
|
||||
`,
|
||||
children:
|
||||
/** @type {any} */
|
||||
(
|
||||
notificationsService
|
||||
.bind("notifications")
|
||||
.as((x) =>
|
||||
x.length > 0
|
||||
? [Header(), notifications.List({})]
|
||||
: [Header(), notifications.Placeholder({})],
|
||||
)
|
||||
),
|
||||
}),
|
||||
});
|
||||
@@ -0,0 +1,85 @@
|
||||
import { getIcon } from "../modules/audio.js";
|
||||
import brightness from "../services/brightness.js";
|
||||
|
||||
const audio = await Service.import("audio");
|
||||
|
||||
const DELAY = 1000;
|
||||
|
||||
function OnScreenProgress() {
|
||||
const indicator = Widget.Icon({
|
||||
vpack: "start",
|
||||
hpack: "center",
|
||||
size: 30,
|
||||
css: "padding-right: 12px;",
|
||||
});
|
||||
const progress = Widget.Slider({
|
||||
drawValue: false,
|
||||
hexpand: true,
|
||||
});
|
||||
const revealer = Widget.Revealer({
|
||||
transition: "crossfade",
|
||||
css: "opacity: 0",
|
||||
revealChild: true,
|
||||
vpack: "center",
|
||||
hpack: "center",
|
||||
child: Widget.Box({
|
||||
vpack: "center",
|
||||
hpack: "center",
|
||||
className: "osd bgcount",
|
||||
css: "padding: 20px;",
|
||||
children: [indicator, progress],
|
||||
}),
|
||||
});
|
||||
// Prevent OSD to be shown when starting ags.
|
||||
Utils.timeout(DELAY * 2, () => {
|
||||
revealer.css = "opacity: 1";
|
||||
});
|
||||
|
||||
let count = 0;
|
||||
/**
|
||||
* @param {number} value
|
||||
* @param {string} icon
|
||||
*/
|
||||
function show(value, icon) {
|
||||
revealer.reveal_child = true;
|
||||
indicator.icon = icon;
|
||||
progress.value = value;
|
||||
count++;
|
||||
Utils.timeout(DELAY, () => {
|
||||
count--;
|
||||
if (count === 0) revealer.reveal_child = false;
|
||||
});
|
||||
}
|
||||
return revealer
|
||||
.hook(
|
||||
brightness,
|
||||
() => show(brightness.screen, "display-brightness-symbolic"),
|
||||
"notify::screen",
|
||||
)
|
||||
.hook(
|
||||
audio.speaker,
|
||||
() => show(audio.speaker.volume, getIcon(audio.speaker.volume * 100)),
|
||||
"notify::volume",
|
||||
)
|
||||
.hook(
|
||||
audio.speaker,
|
||||
() =>
|
||||
show(
|
||||
audio.speaker.is_muted ? 0 : audio.speaker.volume,
|
||||
audio.speaker.is_muted
|
||||
? "audio-volume-muted-symbolic"
|
||||
: getIcon(audio.speaker.volume * 100),
|
||||
),
|
||||
"notify::is-muted",
|
||||
);
|
||||
}
|
||||
|
||||
export const OSD = () =>
|
||||
Widget.Window({
|
||||
name: "osd",
|
||||
className: "indicator",
|
||||
layer: "overlay",
|
||||
clickThrough: true,
|
||||
anchor: ["bottom"],
|
||||
child: OnScreenProgress(),
|
||||
});
|
||||
@@ -0,0 +1,159 @@
|
||||
import Gtk from "gi://Gtk?version=3.0";
|
||||
import * as audio from "../modules/audio.js";
|
||||
import * as brightness from "../modules/brightness.js";
|
||||
import * as network from "../modules/network.js";
|
||||
import * as bluetooth from "../modules/bluetooth.js";
|
||||
import * as darkmode from "../modules/darkmode.js";
|
||||
import * as powerprofile from "../modules/powerprofile.js";
|
||||
// import * as nightmode from "../modules/nightmode.js";
|
||||
import * as mpris from "../modules/mpris.js";
|
||||
import * as systray from "../modules/systray.js";
|
||||
import PopupWindow from "../misc/popup.js";
|
||||
import { opened, Menu } from "../misc/menu.js";
|
||||
|
||||
const mprisService = await Service.import("mpris");
|
||||
|
||||
/**
|
||||
* @param {Array<Gtk.Widget>} toggles
|
||||
* @param {Array<Gtk.Widget>} menus
|
||||
*/
|
||||
const Row = (toggles = [], menus = []) =>
|
||||
Widget.Box({
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Box({
|
||||
homogeneous: true,
|
||||
children: toggles,
|
||||
}),
|
||||
...menus,
|
||||
],
|
||||
});
|
||||
|
||||
const Header = () =>
|
||||
Widget.Box({
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Box({
|
||||
css: "margin-bottom: 12px",
|
||||
children: [
|
||||
Widget.Box({
|
||||
className: "avatar",
|
||||
css: `background-image: url("/home/${Utils.USER}/.face");`,
|
||||
}),
|
||||
Widget.Box({ hexpand: true }),
|
||||
Widget.Button({
|
||||
child: Widget.Icon("emblem-system-symbolic"),
|
||||
onClicked: () => {
|
||||
Utils.execAsync("gnome-control-center");
|
||||
App.closeWindow("quicksettings");
|
||||
},
|
||||
vpack: "center",
|
||||
className: "surface sys-button",
|
||||
}),
|
||||
Widget.Button({
|
||||
child: Widget.Icon("system-log-out-symbolic"),
|
||||
onClicked: () => {
|
||||
opened.value = opened.value === "sleep" ? "" : "sleep";
|
||||
},
|
||||
vpack: "center",
|
||||
css: "margin: 12px",
|
||||
className: "surface sys-button",
|
||||
}),
|
||||
Widget.Button({
|
||||
child: Widget.Icon("system-shutdown-symbolic"),
|
||||
onClicked: () => {
|
||||
opened.value = opened.value === "shutdown" ? "" : "shutdown";
|
||||
},
|
||||
vpack: "center",
|
||||
className: "surface sys-button",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
VerificationMenu({
|
||||
name: "sleep",
|
||||
icon: "system-log-out-symbolic",
|
||||
title: "Hybernate?",
|
||||
command: "systemctl suspend --now",
|
||||
}),
|
||||
VerificationMenu({
|
||||
name: "shutdown",
|
||||
icon: "system-shutdown-symbolic",
|
||||
title: "Shutdown?",
|
||||
command: "shutdown --now",
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
/** @param {{
|
||||
* name: string,
|
||||
* icon: string,
|
||||
* title: string,
|
||||
* command: string,
|
||||
* }} props */
|
||||
const VerificationMenu = ({ name, icon, title, command }) =>
|
||||
Menu({
|
||||
name,
|
||||
icon: Widget.Icon(icon),
|
||||
title: title,
|
||||
content: [
|
||||
Widget.Button({
|
||||
onClicked: () => {
|
||||
opened.value = "";
|
||||
Utils.execAsync(command);
|
||||
},
|
||||
child: Widget.Label({
|
||||
label: "Yes",
|
||||
hpack: "start",
|
||||
css: "margin-left: 12px",
|
||||
}),
|
||||
}),
|
||||
Widget.Button({
|
||||
onClicked: () => {
|
||||
opened.value = "";
|
||||
},
|
||||
child: Widget.Label({
|
||||
label: "No",
|
||||
hpack: "start",
|
||||
css: "margin-left: 12px",
|
||||
}),
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
export const Quicksettings = () =>
|
||||
PopupWindow({
|
||||
name: "quicksettings",
|
||||
exclusivity: "exclusive",
|
||||
transition: "slide_down",
|
||||
layout: "top-right",
|
||||
duration: 300,
|
||||
child: Widget.Box({
|
||||
vertical: true,
|
||||
className: "bgcont qs-container",
|
||||
children: [
|
||||
Header(),
|
||||
Row(
|
||||
[audio.Volume({ type: "speaker" })],
|
||||
[audio.SinkSelector({}), audio.AppMixer({})],
|
||||
),
|
||||
brightness.Brightness({}),
|
||||
Row(
|
||||
[network.Toggle({}), bluetooth.Toggle({})],
|
||||
[network.Selection({}), bluetooth.Selection({})],
|
||||
),
|
||||
Widget.Box({
|
||||
homogeneous: true,
|
||||
children: [darkmode.Toggle(), audio.MuteToggle({})],
|
||||
}),
|
||||
Row(
|
||||
[systray.Toggle({}), powerprofile.Toggle({})],
|
||||
[systray.Selection({}), powerprofile.Selection({})],
|
||||
),
|
||||
Widget.Box({
|
||||
children: mprisService
|
||||
.bind("players")
|
||||
.as((x) => x.map((player) => mpris.MprisPlayer({ player }))),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user