Added more configuration options
This commit is contained in:
@@ -14,7 +14,6 @@ import { BarItemBox as WidgetContainer } from "../shared/barItemBox.js";
|
||||
import options from "options";
|
||||
|
||||
const { start, center, end } = options.bar.layout;
|
||||
const { transparent, position } = options.bar;
|
||||
|
||||
export type BarWidget = keyof typeof widget;
|
||||
|
||||
|
||||
@@ -4,9 +4,10 @@ import { openMenu } from "../utils.js";
|
||||
const BatteryLabel = () => {
|
||||
const isVis = Variable(battery.available);
|
||||
|
||||
const icon = battery
|
||||
.bind("percent")
|
||||
.as((p) => `battery-level-${Math.floor(p / 10) * 10}-symbolic`);
|
||||
const icon = () =>
|
||||
battery
|
||||
.bind("percent")
|
||||
.as((p) => `battery-level-${Math.floor(p / 10) * 10}-symbolic`);
|
||||
|
||||
battery.connect("changed", ({ available }) => {
|
||||
isVis.value = available;
|
||||
@@ -36,19 +37,22 @@ const BatteryLabel = () => {
|
||||
class_name: "battery",
|
||||
visible: battery.bind("available"),
|
||||
tooltip_text: battery.bind("time_remaining").as((t) => t.toString()),
|
||||
children: [
|
||||
Widget.Icon({ icon }),
|
||||
Widget.Label({
|
||||
label: battery.bind("percent").as((p) => ` ${p}%`),
|
||||
}),
|
||||
],
|
||||
setup: (self) => {
|
||||
self.hook(battery, () => {
|
||||
self.tooltip_text = generateTooltip(
|
||||
battery.time_remaining,
|
||||
battery.charging,
|
||||
battery.charged,
|
||||
);
|
||||
if (battery.available) {
|
||||
self.children = [
|
||||
Widget.Icon({ icon: icon() }),
|
||||
Widget.Label({
|
||||
label: battery.bind("percent").as((p) => ` ${p}%`),
|
||||
}),
|
||||
];
|
||||
|
||||
self.tooltip_text = generateTooltip(
|
||||
battery.time_remaining,
|
||||
battery.charging,
|
||||
battery.charged,
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const bluetooth = await Service.import('bluetooth')
|
||||
import options from "options";
|
||||
import { openMenu } from "../utils.js";
|
||||
|
||||
const Bluetooth = () => {
|
||||
@@ -8,7 +9,13 @@ const Bluetooth = () => {
|
||||
});
|
||||
|
||||
const btText = Widget.Label({
|
||||
label: bluetooth.bind("enabled").as((v) => v ? " On" : " Off"),
|
||||
label: Utils.merge([bluetooth.bind("enabled"), options.bar.bluetooth.label.bind("value")], (btEnabled, showLabel) => {
|
||||
if (showLabel) {
|
||||
return btEnabled ? " On" : " Off"
|
||||
}
|
||||
return "";
|
||||
|
||||
}),
|
||||
class_name: "bar-bt_label",
|
||||
});
|
||||
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
import GLib from "gi://GLib";
|
||||
import { openMenu } from "../utils.js";
|
||||
import options from "options";
|
||||
const { format } = options.bar.clock;
|
||||
|
||||
const date = Variable("", {
|
||||
poll: [1000, 'date "+ %a %b %d %I:%M:%S %p"'],
|
||||
const date = Variable(GLib.DateTime.new_now_local(), {
|
||||
poll: [1000, () => GLib.DateTime.new_now_local()],
|
||||
});
|
||||
const time = Utils.derive([date, format], (c, f) => c.format(f) || "");
|
||||
|
||||
const Clock = () => {
|
||||
return {
|
||||
component: Widget.Label({
|
||||
class_name: "clock",
|
||||
label: date.bind(),
|
||||
label: time.bind(),
|
||||
}),
|
||||
isVisible: true,
|
||||
boxClass: "clock",
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
import { Menu } from "./menu/index.js";
|
||||
import { Workspaces } from "./workspaces/index.js";
|
||||
import { ClientTitle } from "./window_title/index.js";
|
||||
import { Media } from "./media/index.js";
|
||||
import { Notifications } from "./notifications/index.js";
|
||||
import { Volume } from "./volume/index.js";
|
||||
import { Network } from "./network/index.js";
|
||||
import { Bluetooth } from "./bluetooth/index.js";
|
||||
import { BatteryLabel } from "./battery/index.js";
|
||||
import { Clock } from "./clock/index.js";
|
||||
import { SysTray } from "./systray/index.js";
|
||||
|
||||
import { BarItemBox } from "../shared/barItemBox.js";
|
||||
|
||||
// layout of the bar
|
||||
const Left = (monitor, wsMap) => {
|
||||
return Widget.Box({
|
||||
class_name: "box-left",
|
||||
hpack: "start",
|
||||
spacing: 5,
|
||||
children: [BarItemBox(Menu()), BarItemBox(Workspaces(monitor, wsMap, 10)), BarItemBox(ClientTitle())],
|
||||
});
|
||||
};
|
||||
|
||||
const Center = () => {
|
||||
return Widget.Box({
|
||||
class_name: "box-center",
|
||||
spacing: 5,
|
||||
children: [
|
||||
BarItemBox(Media()),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
const Right = () => {
|
||||
return Widget.Box({
|
||||
class_name: "box-right",
|
||||
hpack: "end",
|
||||
spacing: 5,
|
||||
children: [
|
||||
BarItemBox(Volume()),
|
||||
BarItemBox(Network()),
|
||||
BarItemBox(Bluetooth()),
|
||||
BarItemBox(BatteryLabel()),
|
||||
BarItemBox(SysTray()),
|
||||
BarItemBox(Clock()),
|
||||
BarItemBox(Notifications()),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
const LeftAlt = (monitor, wsMap) => {
|
||||
return Widget.Box({
|
||||
class_name: "box-left",
|
||||
hpack: "start",
|
||||
spacing: 5,
|
||||
children: [BarItemBox(Menu()), BarItemBox(Workspaces(monitor, wsMap)), BarItemBox(ClientTitle())],
|
||||
});
|
||||
};
|
||||
|
||||
const CenterAlt = () => {
|
||||
return Widget.Box({
|
||||
class_name: "box-center",
|
||||
spacing: 5,
|
||||
children: [
|
||||
BarItemBox(Media()),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
const RightAlt = () => {
|
||||
return Widget.Box({
|
||||
class_name: "box-right",
|
||||
hpack: "end",
|
||||
spacing: 5,
|
||||
children: [
|
||||
BarItemBox(Volume()),
|
||||
BarItemBox(Clock()),
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
const Bar = (monitor = 0, wsMap) => {
|
||||
return Widget.Window({
|
||||
name: `bar-${monitor}`,
|
||||
class_name: "bar",
|
||||
monitor,
|
||||
anchor: ["top", "left", "right"],
|
||||
exclusivity: "exclusive",
|
||||
child: Widget.CenterBox({
|
||||
start_widget: Left(monitor, wsMap),
|
||||
center_widget: Center(),
|
||||
end_widget: Right(),
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
const BarAlt = (monitor = 0, wsMap) => {
|
||||
return Widget.Window({
|
||||
name: `bar-${monitor}`,
|
||||
class_name: "bar",
|
||||
monitor,
|
||||
anchor: ["top", "left", "right"],
|
||||
exclusivity: "exclusive",
|
||||
child: Widget.CenterBox({
|
||||
start_widget: LeftAlt(monitor, wsMap),
|
||||
center_widget: CenterAlt(),
|
||||
end_widget: RightAlt(),
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
export { Bar, BarAlt };
|
||||
@@ -1,11 +1,12 @@
|
||||
import { openMenu } from "../utils.js";
|
||||
import options from "options";
|
||||
|
||||
const Menu = () => {
|
||||
return {
|
||||
component: Widget.Box({
|
||||
child: Widget.Label({
|
||||
class_name: "bar-menu_label",
|
||||
label: "",
|
||||
label: options.bar.launcher.icon.bind("value"),
|
||||
}),
|
||||
}),
|
||||
isVisible: true,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const network = await Service.import("network");
|
||||
import options from "options";
|
||||
import { openMenu } from "../utils.js";
|
||||
|
||||
const Network = () => {
|
||||
@@ -22,7 +23,15 @@ const Network = () => {
|
||||
}),
|
||||
Widget.Label({
|
||||
class_name: "bar-network-label",
|
||||
label: network.bind("wired").as(() => " Wired"),
|
||||
label: Utils.merge(
|
||||
[network.bind("wired"), options.bar.network.label.bind("value")],
|
||||
(_, showLabel) => {
|
||||
if (showLabel) {
|
||||
return " Wired";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
),
|
||||
}),
|
||||
];
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { openMenu } from "../utils.js";
|
||||
import options from "options";
|
||||
|
||||
const { show_total } = options.bar.notifications;
|
||||
|
||||
const notifs = await Service.import("notifications");
|
||||
|
||||
@@ -9,21 +12,27 @@ export const Notifications = () => {
|
||||
child: Widget.Box({
|
||||
hpack: "start",
|
||||
class_name: "bar-notifications",
|
||||
child: Widget.Label({
|
||||
hpack: "center",
|
||||
class_name: "bar-notifications-label",
|
||||
setup: (self) => {
|
||||
self.hook(notifs, () => {
|
||||
if (notifs.dnd) {
|
||||
return (self.label = "");
|
||||
} else if (notifs.notifications.length > 0) {
|
||||
return (self.label = "");
|
||||
} else {
|
||||
return (self.label = "");
|
||||
}
|
||||
children: Utils.merge(
|
||||
[notifs.bind("notifications"), notifs.bind("dnd"), show_total.bind("value")],
|
||||
(notif, dnd, showTotal) => {
|
||||
const notifIcon = Widget.Label({
|
||||
hpack: "center",
|
||||
class_name: "bar-notifications-label",
|
||||
label: dnd ? "" : notif.length > 0 ? "" : "",
|
||||
});
|
||||
|
||||
const notifLabel = Widget.Label({
|
||||
hpack: "center",
|
||||
class_name: "bar-notifications-total",
|
||||
label: notif.length.toString(),
|
||||
});
|
||||
|
||||
if (showTotal) {
|
||||
return [notifIcon, notifLabel];
|
||||
}
|
||||
return [notifIcon];
|
||||
},
|
||||
}),
|
||||
),
|
||||
}),
|
||||
}),
|
||||
isVisible: true,
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
export const Power = () => {
|
||||
return {
|
||||
component: Widget.Box({
|
||||
child: Widget.Button({
|
||||
class_name: "bar-powermenu",
|
||||
child: Widget.Icon({
|
||||
class_name: "bar-power_label",
|
||||
icon: "system-shutdown-symbolic",
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
isVisible: true,
|
||||
boxClass: "power",
|
||||
props: {
|
||||
on_clicked: () => App.toggleWindow("powermenu"),
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -1,27 +1,37 @@
|
||||
const systemtray = await Service.import("systemtray");
|
||||
import { bash } from "lib/utils";
|
||||
import options from "options";
|
||||
|
||||
const { ignore } = options.bar.systray;
|
||||
|
||||
const SysTray = () => {
|
||||
const isVis = Variable(false);
|
||||
|
||||
const items = systemtray.bind("items").as((items) => {
|
||||
isVis.value = items.length > 0;
|
||||
return items.map((item) => {
|
||||
if (item.menu !== undefined) {
|
||||
item.menu["class_name"] = "systray-menu";
|
||||
}
|
||||
const items = Utils.merge(
|
||||
[systemtray.bind("items"), ignore.bind("value")],
|
||||
(items, ignored) => {
|
||||
const filteredTray = items.filter(({ id }) => !ignored.includes(id));
|
||||
|
||||
return Widget.Button({
|
||||
cursor: "pointer",
|
||||
child: Widget.Icon({
|
||||
class_name: "systray-icon",
|
||||
icon: item.bind("icon"),
|
||||
}),
|
||||
on_primary_click: (_, event) => item.activate(event),
|
||||
on_secondary_click: (_, event) => item.openMenu(event),
|
||||
tooltip_markup: item.bind("tooltip_markup"),
|
||||
isVis.value = filteredTray.length > 0;
|
||||
|
||||
return filteredTray.map((item) => {
|
||||
if (item.menu !== undefined) {
|
||||
item.menu["class_name"] = "systray-menu";
|
||||
}
|
||||
|
||||
return Widget.Button({
|
||||
cursor: "pointer",
|
||||
child: Widget.Icon({
|
||||
class_name: "systray-icon",
|
||||
icon: item.bind("icon"),
|
||||
}),
|
||||
on_primary_click: (_, event) => item.activate(event),
|
||||
on_secondary_click: (_, event) => item.openMenu(event),
|
||||
tooltip_markup: item.bind("tooltip_markup"),
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
component: Widget.Box({
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
const audio = await Service.import("audio");
|
||||
import { openMenu } from "../utils.js";
|
||||
import options from "options";
|
||||
|
||||
import { globalMousePos } from "../../../globals.js";
|
||||
import { globalMousePos } from "globals.js";
|
||||
|
||||
const Volume = () => {
|
||||
const icons = {
|
||||
@@ -41,7 +42,12 @@ const Volume = () => {
|
||||
component: Widget.Box({
|
||||
vpack: "center",
|
||||
class_name: "volume",
|
||||
children: [volIcn, volPct],
|
||||
children: options.bar.volume.label.bind("value").as((showLabel) => {
|
||||
if (showLabel) {
|
||||
return [volIcn, volPct];
|
||||
}
|
||||
return [volIcn];
|
||||
}),
|
||||
}),
|
||||
isVisible: true,
|
||||
boxClass: "volume",
|
||||
|
||||
@@ -58,8 +58,46 @@ const Workspaces = (monitor = -1, ws = 8) => {
|
||||
return Widget.Label({
|
||||
attribute: i,
|
||||
vpack: "center",
|
||||
label: `${i}`,
|
||||
setup: (self) =>
|
||||
class_name: Utils.merge(
|
||||
[
|
||||
options.bar.workspaces.show_icons.bind("value"),
|
||||
options.bar.workspaces.icons.available.bind("value"),
|
||||
options.bar.workspaces.icons.active.bind("value"),
|
||||
options.bar.workspaces.icons.occupied.bind("value"),
|
||||
],
|
||||
(show_icons) => {
|
||||
if (show_icons) {
|
||||
return `workspace-icon`;
|
||||
}
|
||||
return "";
|
||||
},
|
||||
),
|
||||
label: Utils.merge(
|
||||
[
|
||||
options.bar.workspaces.show_icons.bind("value"),
|
||||
options.bar.workspaces.icons.available.bind("value"),
|
||||
options.bar.workspaces.icons.active.bind("value"),
|
||||
options.bar.workspaces.icons.occupied.bind("value"),
|
||||
],
|
||||
(showIcons, available, active, occupied) => {
|
||||
if (showIcons) {
|
||||
if (hyprland.active.workspace.id === i) {
|
||||
return active;
|
||||
}
|
||||
if ((hyprland.getWorkspace(i)?.windows || 0) > 0) {
|
||||
return occupied;
|
||||
}
|
||||
if (
|
||||
monitor !== -1 &&
|
||||
hyprland.getWorkspace(i)?.monitorID !== monitor
|
||||
) {
|
||||
return available;
|
||||
}
|
||||
}
|
||||
return `${i}`;
|
||||
},
|
||||
),
|
||||
setup: (self) => {
|
||||
self.hook(hyprland, () => {
|
||||
self.toggleClassName(
|
||||
"active",
|
||||
@@ -69,13 +107,8 @@ const Workspaces = (monitor = -1, ws = 8) => {
|
||||
"occupied",
|
||||
(hyprland.getWorkspace(i)?.windows || 0) > 0,
|
||||
);
|
||||
|
||||
const isCurrentMonitor =
|
||||
monitor !== -1 &&
|
||||
hyprland.getWorkspace(i)?.monitorID !== monitor;
|
||||
|
||||
self.toggleClassName("hidden", isCurrentMonitor);
|
||||
}),
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user