495 current 2024-04-28 20:50:10 24.05.20240428.30ddacc 6.8.6-zen1 *

This commit is contained in:
zackartz 2024-04-28 20:50:20 -04:00
parent 5549a17e4c
commit d6c181bc5b
No known key found for this signature in database
GPG key ID: 5B53E53A9A514DBA
46 changed files with 1685 additions and 10 deletions

View file

@ -0,0 +1,35 @@
import { Widget } from "../../imports.js";
const { Window, Box, CenterBox } = Widget;
// Widgets
import { Workspaces } from "./workspaces.js";
import { Title } from "./title.js";
import { Media } from "./media.js";
import { Notification } from "./notification.js"
import { SysInfo } from "./sysinfo/sysinfo.js";
import { sysTray } from "./tray.js";
import { Clock } from "./clock.js";
const Left = () => Box({
children: [Workspaces(), Title()],
});
const Center = () => Box({
children: [Media()],
});
const Right = () => Box({
hpack: "end",
children: [Notification(), sysTray(), SysInfo(), Clock()],
});
export const Bar = () => Window({
name: "bar",
anchor: ["top", "right", "left"],
margins: [10, 15, 0],
exclusivity: "exclusive",
child: CenterBox({
className: "bar",
start_widget: Left(),
center_widget: Center(),
end_widget: Right(),
}),
});

View file

@ -0,0 +1,13 @@
import { Widget, Utils } from "../../imports.js";
const { execAsync } = Utils;
export const Clock = () => Widget.Button({
className: "clock",
setup: (self) => {
self.poll(1000, (self) =>
execAsync(["date", "+%a %b %d %H:%M"])
.then((time) => (self.label = time))
.catch(console.error),
);
},
});

View file

@ -0,0 +1,21 @@
import { Widget, Utils, Mpris } from "../../imports.js";
const { execAsync } = Utils;
export const Media = () => Widget.Button({
class_name: 'media',
on_primary_click: () => Mpris.getPlayer('').playPause(),
onSecondaryClickRelease: () => {
execAsync(['bash', '-c', 'anyrun', '&']);
},
on_scroll_up: () => Mpris.getPlayer('').next(),
on_scroll_down: () => Mpris.getPlayer('').previous(),
child: Widget.Label('-').hook(Mpris, self => {
if (Mpris.players[0]) {
const { track_title } = Mpris.players[0];
self.label = track_title.length > 60 ? `${track_title.substring(0, 60)}...` : track_title;
} else {
self.label = 'Nothing is playing';
}
}, 'player-changed'),
});

View file

@ -0,0 +1,20 @@
import { Widget, Notifications } from "../../imports.js"
const { Box } = Widget
export const Notification = () => Box({
class_name: 'barNotification',
visible: Notifications.bind('popups').transform(p => p.length > 0),
children: [
Widget.Label({
label: '󰍡 ',
}),
Widget.Label({
label: Notifications.bind('popups').transform(p => {
const summary = p[0]?.summary || '';
const maxLength = 50;
return summary.length > maxLength ? summary.slice(0, maxLength) + '...' : summary;
}),
}),
],
});

View file

@ -0,0 +1,38 @@
import { Widget, Utils, Battery } from "../../../imports.js";
const { Box } = Widget;
export const BatteryWidget = () => Box({
className: "battery",
children: [
Widget.Label({
className: "batIcon",
hexpand: true,
setup: (self) => {
self.hook(Battery, (self) => {
const icons = [
["󰂎", "󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"],
["󰢟", "󰢜", "󰂆", "󰂇", "󰂈", "󰢝", "󰂉", "󰢞", "󰂊", "󰂋", "󰂅"],
];
self.label =
icons[Battery.charging ? 1 : 0][
Math.floor(Battery.percent / 10)
].toString();
if (Battery.percent <= 15 && Battery.charging === false) {
self.toggleClassName("low", true);
} else {
self.toggleClassName("low", false);
}
});
},
}),
Widget.Label({
setup: (self) => {
self.hook(Battery, (self) => {
self.label = `${Battery.percent}%`;
});
},
}),
],
});

View file

@ -0,0 +1,13 @@
import { Widget } from "../../../imports.js";
import { Bluetooth } from "../../../imports.js";
const { Box } = Widget;
export const BluetoothWidget = () => Box({
class_name: 'bluetoothindicator',
children: [
Widget.Icon({
icon: Bluetooth.bind('enabled').transform(on =>
`bluetooth-${on ? 'active' : 'disabled'}-symbolic`),
})
]
})

View file

@ -0,0 +1,23 @@
import { Network } from "../../../imports.js"
import { Widget } from "../../../imports.js";
const WifiIndicator = () => Widget.Box({
children: [
Widget.Icon({
icon: Network.wifi.bind('icon_name'),
}),
],
})
const WiredIndicator = () => Widget.Icon({
icon: Network.wired.bind('icon_name'),
})
export const NetworkWidget = () => Widget.Stack({
class_name: 'network',
items: [
['wifi', WifiIndicator()],
['wired', WiredIndicator()],
],
shown: Network.bind('primary').transform(p => p || 'wifi'),
})

View file

@ -0,0 +1,20 @@
import { Widget } from "../../../imports.js"
const { Box } = Widget;
import{ NetworkWidget } from "./network.js"
import{ BluetoothWidget } from "./bluetooth.js"
import{ Volume } from "./volume.js"
import{ BatteryWidget } from "./battery.js"
export const SysInfo = () => Widget.Button({
class_name: 'sysinfo',
onClicked: () => App.toggleWindow("dashboard"),
child: Box({
children: [
NetworkWidget(),
BluetoothWidget(),
Volume(),
// BatteryWidget(),
]
}),
});

View file

@ -0,0 +1,25 @@
import { Widget, Audio } from "../../../imports.js";
const { Box } = Widget;
export const Volume = () => Box({
class_name: 'volume',
children: [
Widget.Icon().hook(Audio, self => {
if (!Audio.speaker)
return;
const category = {
101: 'overamplified',
67: 'high',
34: 'medium',
1: 'low',
0: 'muted',
};
const icon = Audio.speaker.is_muted ? 0 : [101, 67, 34, 1, 0].find(
threshold => threshold <= Audio.speaker.volume * 100);
self.icon = `audio-volume-${category[icon]}-symbolic`;
}, 'speaker-changed'),
],
});

View file

@ -0,0 +1,11 @@
import { Widget, Hyprland, Utils } from "../../imports.js";
const { execAsync } = Utils;
export const Title = () => Widget.Button({
className: 'title',
visible:Hyprland.active.client.bind('title').transform(title => title.length > 0),
label: Hyprland.active.client.bind('title').transform(title => title.length > 40 ? title.substring(0, 40) + '...' : title),
onClicked: () => {
execAsync(['bash', '-c', 'hyprctl dispatch killactive', '&']);
},
});

View file

@ -0,0 +1,15 @@
import { SystemTray } from "../../imports.js"
import { Widget } from "../../imports.js";
const { Box } = Widget;
const SysTrayItem = item => Widget.Button({
child: Widget.Icon().bind('icon', item, 'icon'),
tooltipMarkup: item.bind('tooltip_markup'),
onPrimaryClick: (_, event) => item.activate(event),
onSecondaryClick: (_, event) => item.openMenu(event),
});
export const sysTray = () => Box({
class_name: 'tray',
children: SystemTray.bind('items').transform(i => i.map(SysTrayItem))
})

View file

@ -0,0 +1,43 @@
import { Utils, Widget, Hyprland } from "../../imports.js";
const { execAsync } = Utils;
const { Box } = Widget;
export const Workspaces = () => Box({
className:"workspaces_pill",
child:Box({
className: "workspaces",
child: Box({
children: Array.from({ length: 10 }, (_, i) => i + 1).map((i) =>
Widget.Button({
cursor: "pointer",
attribute: { index: i },
onClicked: () =>
execAsync(["hyprctl", "dispatch", "workspace", `${i}`]).catch(
console.error,
),
onSecondaryClick: () =>
execAsync([
"hyprctl",
"dispatch",
"movetoworkspacesilent",
`${i}`,
]).catch(console.error),
}),
),
setup: (self) => {
self.hook(Hyprland, (self) =>
self.children.forEach((btn) => {
btn.className =
btn.attribute.index === Hyprland.active.workspace.id
? "focused"
: "";
btn.visible = Hyprland.workspaces.some(
(ws) => ws.id === btn.attribute.index,
);
}),
);
},
}),
}),
});

View file

@ -0,0 +1,52 @@
import { Widget, Bluetooth, Utils } from "../../imports.js";
const { execAsync } = Utils
const { Box } = Widget;
export const BluetoothWidget = () =>
Widget.Button({
onClicked: () => Bluetooth.toggle(),
onSecondaryClickRelease: () => {
execAsync(['bash', '-c', 'blueman-manager', '&']);
App.closeWindow('dashboard');
},
child: Box({
className: "bluetooth",
vpack: "center",
vexpand: true,
setup: (self) => {
self.hook(Bluetooth, (self) => {
if (Bluetooth.enabled) {
self.toggleClassName("off", false);
} else {
self.toggleClassName("off", true);
}
});
},
children: [
Widget.Label({
className: "bluetoothIcon",
label: "󰂲",
setup: (self) => {
self.hook(Bluetooth, (self) => {
if (Bluetooth.enabled) {
self.label = "󰂯";
} else {
self.label = "󰂲";
}
});
},
}),
Box({
vertical: true,
vpack: "center",
children: [
Widget.Label({
className: "bluetoothLabel",
label: "Bluetooth",
hpack: "start",
}),
],
}),
],
}),
});

View file

@ -0,0 +1,42 @@
import { Widget } from "../../imports.js";
import Brightness from "../../services/brightness.js";
const { Box } = Widget;
const Icon = () =>
Widget.Label({
className: "sldIcon",
setup: (self) => {
self.hook(Brightness, (self) => {
const icons = ["󰃚", "󰃛", "󰃜", "󰃝", "󰃞", "󰃟", "󰃠"];
self.label =
icons[Math.floor((Brightness.screen * 100) / 14)].toString();
});
},
});
const Slider = () =>
Widget.Slider({
className: "sldSlider",
drawValue: false,
onChange: ({ value }) => (Brightness.screen = value),
setup: (self) => {
self.hook(Brightness, (self) => (self.value = Brightness.screen));
},
});
export const BrightnessSlider = () =>
Box({
className: "Slider",
vertical: true,
children: [
Widget.Label({
className: "sldLabel",
label: "Brightness",
hpack: "start",
}),
Box({
children: [Icon(), Slider()],
}),
],
});

View file

@ -0,0 +1,16 @@
import Gtk from 'gi://Gtk';
import { Widget } from "../../imports.js";
const { Box } = Widget;
export const CalendarWidget = () => Box({
className: "calendar",
vpack: 'end',
vertical: true,
children: [
Widget.subclass(Gtk.Calendar)({
showDayNames: true,
showHeading: true,
className: 'calendarWidget',
})
]
})

View file

@ -0,0 +1,62 @@
import { Widget, Utils } from "../../imports.js";
const { Box } = Widget;
const { execAsync } = Utils;
import PopupWindow from "../../utils/popupWindow.js";
import { PowerIcon, TerminalIcon } from "./iconButtons.js"
import { WiFi } from "./wifi.js";
import { BluetoothWidget } from "./bluetooth.js";
import { VolumeSlider } from "./volumeSlider.js"
import { BrightnessSlider } from "./brightnessSlider.js";
import { NotificationList } from "./notificationList.js";
import { CalendarWidget } from "./calendar.js";
const uptime = Box({
children: [
Widget.Label({
setup: (self) => self
.poll(5000, label => {
execAsync(['bash', '-c', `w | sed -n '1p' | cut -d, -f1 | cut -d' ' -f4-`])
.then(upTimeString => {
label.label = `Uptime: ${upTimeString}`;
}).catch(print);
})
,
}),
Box({ hexpand: true }),
TerminalIcon({ hpack: 'end' }),
PowerIcon({ hpack: 'end' }),
]
});
export const Dashboard = () => PopupWindow({
name: "dashboard",
anchor: ["top","bottom", "right"],
margins: [12, 12, 15],
transition: "slide_left",
transitionDuration: 150,
child:
Box({
vertical:true,
children: [
Box({
className: "quicktoggles",
vertical: true,
vexpand: false,
children: [
uptime,
Box({
className: "buttons",
children: [
WiFi(),
BluetoothWidget(),
]
}),
]
}),
VolumeSlider(),
// BrightnessSlider(),
NotificationList(),
CalendarWidget(),
]
})
});

View file

@ -0,0 +1,21 @@
import { Widget, Utils } from "../../imports.js"
const { execAsync } = Utils;
export const PowerIcon = () => Widget.Button({
className: 'Icon',
child: Widget.Label({ label:"⏻" }),
onClicked: () => {
App.closeWindow('dashboard');
execAsync(['bash', '-c', '~/.config/hypr/scripts/powermenu.sh', '&']);
},
})
export const TerminalIcon = () => Widget.Button({
className: 'Icon',
child: Widget.Label({ label:"󰄛" }),
onClicked: () => {
execAsync(['bash', '-c', 'kitty', '&']);
App.closeWindow('dashboard');
},
})

View file

@ -0,0 +1,117 @@
import { Widget, Notifications, Utils } from "../../imports.js";
const { Box } = Widget;
const Notifs = Widget.Box({
class_name: "panel-notifs",
spacing: 20,
vertical: true,
vexpand: true,
setup: (self) => {
self.hook(Notifications, (self) => {
self.children = Notifications.notifications.map(n => Widget.Box({
class_name: "notification",
vertical: true,
children: [
Widget.Button({
on_clicked: () => {
n.close()
},
child: Box({
class_name: "notificationBody",
spacing: 20,
children: [
Widget.Label({
label: "󰍡",
class_name: "notificationImage"
}),
Box({
vertical: true,
children: [
Widget.Label({
label: `${n.summary}`,
class_name: "notificationTitle",
xalign: 0,
wrap: true
}),
Widget.Label({
vpack: "start",
hpack: "start",
class_name: "notificationDescription",
xalign: 0,
wrap: true,
label: n.body
})
]
})
]
})
})
],
})
)
})
}
})
const NotifBox = Widget.Scrollable({
vscroll: 'always',
hscroll: 'never',
vexpand: true,
class_name: 'notificationBox',
child: Notifs,
})
const Empty = Widget.Box({
class_name: "notificationEmpty",
spacing: 20,
hpack: "center",
vpack: "center",
vertical: true,
children: [
Widget.Label({
label: ` 󱙎 `,
vpack: "center",
vexpand: true,
})
]
})
export const NotificationList = () => Widget.Box({
class_name: "notificationList",
spacing: 20,
vertical: true,
children: [
Widget.CenterBox({
start_widget: Widget.Label({
label: "Notifications",
hpack: 'start',
class_name: "nt"
}),
end_widget: Widget.Button({
label: "  ",
hpack: 'end',
class_name: "icon ni",
on_clicked: () => {
const list = Array.from(Notifications.notifications);
for (let i = 0; i < list.length; i++) {
Utils.timeout(50 * i, () => list[i]?.close());
}
}
})
}),
Widget.Stack({
transition: 'crossfade',
transitionDuration: 150,
items: [
['empty', Empty],
['list', NotifBox]
],
setup: (self) => {
self.hook(Notifications, (self) => {
self.shown = (Notifications.notifications.length == 0 ? 'empty' : 'list')
})
}
}),
],
})

View file

@ -0,0 +1,60 @@
import { Widget, Audio } from "../../imports.js";
const { Box } = Widget;
const Icon = () => Widget.Label({
className: "sldIcon",
setup: (self) => {
self.hook(
Audio,
(self) => {
if (!Audio.speaker) return;
const icons = ["󰝟", "󰕿", "󰖀", "󰕾"];
self.label =
icons[
Audio.speaker.stream.isMuted
? 0
: Math.floor((Audio.speaker.volume * 100) / 26)
].toString();
},
"speaker-changed",
);
},
});
const Slider = () => Widget.Slider({
className: "sldSlider",
drawValue: false,
onChange: ({ value }) => (Audio.speaker.volume = value),
setup: (self) => {
self.hook(
Audio,
(self) => {
if (!Audio.speaker) return;
self.value = Audio.speaker.volume;
},
"speaker-changed",
);
},
});
export const VolumeSlider = () => Box({
className: "Slider",
vertical: true,
children: [
Widget.Label({
className: "sldLabel",
label: "Volume",
hpack: "start",
}),
Box({
children: [
Icon(),
Slider()
],
}),
],
});

View file

@ -0,0 +1,52 @@
import { Widget, Network, Utils } from "../../imports.js";
const { execAsync } = Utils
const { Box } = Widget;
export const WiFi = () =>
Widget.Button({
onClicked: () => Network.toggleWifi(),
onSecondaryClickRelease: () => {
execAsync(['bash', '-c', 'XDG_CURRENT_DESKTOP="gnome" gnome-control-center wifi', '&']);
App.closeWindow('dashboard');
},
child: Box({
className: "wifi",
vpack: "center",
vexpand: true,
setup: (self) => {
self.hook(Network, (self) => {
if (Network.wifi.internet === "disconnected") {
self.toggleClassName("off", true);
} else {
self.toggleClassName("off", false);
}
});
},
children: [
Widget.Label({
className: "wifiIcon",
label: "󰤭",
setup: (self) => {
self.hook(Network, (self) => {
if (Network.wifi.internet === "disconnected") {
self.label = "󰤭";
} else {
self.label = "󰤨";
}
});
},
}),
Box({
vertical: true,
vpack: "center",
children: [
Widget.Label({
className: "wifiLabel",
label: "Wi-Fi",
hpack: "start",
}),
],
}),
],
}),
});