move to snowfall

This commit is contained in:
zackartz 2024-05-23 20:26:30 +00:00
parent 9d7ad7c973
commit 769d4b0df5
No known key found for this signature in database
GPG key ID: 5B53E53A9A514DBA
188 changed files with 2203 additions and 3041 deletions

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",
}),
],
}),
],
}),
});