This commit is contained in:
sankalp committed 2024-07-01 14:51:10 +05:45
1 parent 6b14451fe6
commit 1d69e6c2ce
17 files changed
+440 -189

No files matched your search

+33 -34
View File
@@ -17,6 +17,7 @@ const mpris = await Service.import("mpris")
const bluetooth = await Service.import("bluetooth")
const { Box, Button, EventBox } = Widget;
import Gtk from "gi://Gtk?version=3.0"
import { MaterialIcon } from "icons.js"
function checkKeymap() {
@@ -32,6 +33,14 @@ hyprland.connect("keyboard-layout", (hyprland, keyboardname, layoutname) => {
keyboard_layout.setValue(layoutname.trim().toLowerCase().substr(0, 2))
})
const MATERIAL_SYMBOL_SIGNAL_STRENGTH = {
'network-wireless-signal-excellent-symbolic': "signal_wifi_4_bar",
'network-wireless-signal-good-symbolic': "network_wifi_3_bar",
'network-wireless-signal-ok-symbolic': "network_wifi_2_bar",
'network-wireless-signal-weak-symbolic': "network_wifi_1_bar",
'network-wireless-signal-none-symbolic': "signal_wifi_0_bar",
}
const time = Variable("", {
poll: [1000, 'date "+%I:%M %p"'],
})
@@ -246,9 +255,7 @@ function AppLauncher() {
on_clicked: () => {
App.toggleWindow("applauncher")
},
child: Widget.Label(
"\uf002"
)
child: MaterialIcon("search")
})
return button
@@ -256,9 +263,11 @@ function AppLauncher() {
function Wifi() {
return Widget.Button({
class_name: "bar_wifi icon",
class_name: "bar_wifi",
on_primary_click: () => {
OpenSettings("network")
},
@@ -270,25 +279,24 @@ function Wifi() {
Utils.execAsync("nm-connection-editor").catch(print)
}
},
child: Widget.Icon({
icon: "network-wireless-offline-symbolic"
}),
child: MaterialIcon("signal_wifi_off", "16px"),
tooltip_text: 'Disabled'
}).hook(network, self => {
if (network.wifi.enabled) {
self.tooltip_text = network.wifi.ssid || 'Unknown';
self.child.icon = network.wifi.icon_name;
self.child.label = MATERIAL_SYMBOL_SIGNAL_STRENGTH[network.wifi.icon_name] || "signal_wifi_off";
} else {
self.tooltip_text = 'Disabled'
self.child.icon = "network-wireless-offline-symbolic";
self.child.label = "signal_wifi_off";
}
})
}
function Bluetooth() {
return Widget.Button({
class_name: "bar_bluetooth icon",
class_name: "bar_bluetooth",
on_primary_click: () => {
OpenSettings("bluetooth")
},
@@ -300,14 +308,12 @@ function Bluetooth() {
Utils.execAsync("blueman-manager").catch(print)
}
},
child: Widget.Icon({
icon: "bluetooth-disabled-symbolic"
}),
child: MaterialIcon("bluetooth_disabled", "18px"),
}).hook(bluetooth, self => {
if (bluetooth.enabled) {
self.child.icon = "bluetooth-active-symbolic";
self.child.icon = "bluetooth";
} else {
self.child.icon = "bluetooth-disabled-symbolic";
self.child.icon = "bluetooth_disabled";
}
})
}
@@ -328,14 +334,11 @@ function MediaPlayer() {
class_name: "filled_tonal_button awesome_icon",
on_primary_click: () => {
App.toggleWindow("media")
// Utils.execAsync(["ags", "-t", "media"])
},
on_secondary_click: () => {
Utils.execAsync(["playerctl", "play-pause"]).catch(print)
},
child: Widget.Label(
""
),
child: MaterialIcon("play_circle"),
visible: false,
tooltip_text: "Unknown"
}).hook(mpris, self => {
@@ -375,7 +378,7 @@ function OpenSideBar() {
on_secondary_click: () => {
OpenSettings()
},
label: ""
child: MaterialIcon("dock_to_left")
})
return button
@@ -432,31 +435,27 @@ if (globalWidgets.length === 0) {
function volumeIndicator() {
return Widget.EventBox({
onScrollUp: () => {
audio.speaker.volume = Math.min(audio.speaker.volume + 0.05, 1);
},
onScrollDown: () => {
audio.speaker.volume = Math.max(audio.speaker.volume - 0.05, 0);
},
onScrollUp: () => audio.speaker.volume += 0.01,
onScrollDown: () => audio.speaker.volume -= 0.01,
class_name: "filled_tonal_button volume_box",
child: Widget.Button({
on_primary_click: () => Utils.execAsync("pavucontrol").catch(print),
on_secondary_click: () => audio.speaker.is_muted = !audio.speaker.is_muted,
child: Widget.Box({
children: [
Widget.Icon().hook(audio.speaker, self => {
MaterialIcon("volume_off", "20px").hook(audio.speaker, self => {
const vol = audio.speaker.volume * 100;
const icon = [
[101, 'overamplified'],
[67, 'high'],
[34, 'medium'],
[1, 'low'],
[0, 'muted'],
[101, 'sound_detection_loud_sound'],
[67, 'volume_up'],
[34, 'volume_down'],
[1, 'volume_mute'],
[0, 'volume_off'],
].find(([threshold]) => Number(threshold) <= vol)?.[1];
if (audio.speaker.is_muted)
self.icon = `audio-volume-muted-symbolic`;
self.label = "volume_off";
else
self.icon = `audio-volume-${icon}-symbolic`;
self.label = String(icon!);
self.tooltip_text = `Volume ${Math.floor(vol)}%`;
}),
Widget.Label({
+1 -1
View File
@@ -140,7 +140,7 @@ function Emoji({ width = 500, height = 500, spacing = 12 }) {
setup: self => self.hook(App, (_, windowName, visible) => {
if (windowName !== WINDOW_NAME) return;
if (visible && emojisCache.length === 0) {
loadEmojis(`${App.configDir}/emojis.json`)
loadEmojis(`${App.configDir}/assets/emojis.json`)
.then(emojis => {
emojisCache = emojis;
list.children = emojis.map(entry => EmojiItem(entry));
+12 -11
View File
@@ -1,14 +1,15 @@
import { MprisPlayer } from 'types/service/mpris.js';
import popupwindow from './misc/popupwindow.ts';
import Label from 'types/widgets/label.js';
import { MaterialIcon } from 'icons.ts';
const mpris = await Service.import("mpris")
const players = mpris.bind("players")
const FALLBACK_ICON = "audio-x-generic-symbolic"
const PLAY_ICON = "media-playback-start-symbolic"
const PAUSE_ICON = "media-playback-pause-symbolic"
const PREV_ICON = "media-skip-backward-symbolic"
const NEXT_ICON = "media-skip-forward-symbolic"
const PLAY_ICON = "play_arrow"
const PAUSE_ICON = "pause"
const PREV_ICON = "skip_previous"
const NEXT_ICON = "skip_next"
const WINDOW_NAME = "media"
function lengthStr(length: number): string {
@@ -96,27 +97,28 @@ function Player(player: MprisPlayer) {
class_name: "play-pause",
on_clicked: () => player.playPause(),
visible: player.bind("can_play"),
child: Widget.Icon({
icon: player.bind("play_back_status").transform(s => {
child: MaterialIcon(
// @ts-ignore
player.bind("play_back_status").transform(s => {
switch (s) {
case "Playing": return PAUSE_ICON
case "Paused":
case "Stopped": return PLAY_ICON
}
}),
}),
}
), "18px"),
})
const prev = Widget.Button({
on_clicked: () => player.previous(),
visible: player.bind("can_go_prev"),
child: Widget.Icon(PREV_ICON),
child: MaterialIcon(PREV_ICON, "18px"),
})
const next = Widget.Button({
on_clicked: () => player.next(),
visible: player.bind("can_go_next"),
child: Widget.Icon(NEXT_ICON),
child: MaterialIcon(NEXT_ICON, "18px"),
})
return Widget.Box(
@@ -169,6 +171,5 @@ export const media = popupwindow({
visible: false,
keymode: "exclusive",
child: Media(),
//anchor: ["left", "top"],
anchor: ["left", "bottom"],
})
+4 -3
View File
@@ -5,6 +5,7 @@ import { timeout } from "resource:///com/github/Aylur/ags/utils.js";
import GLib from "gi://GLib";
import Pango from "gi://Pango";
import Label from "types/widgets/label";
import { MaterialIcon } from "icons";
const notifications = await Service.import("notifications")
import Gtk from "gi://Gtk?version=3.0"
@@ -73,11 +74,11 @@ export const Notification = (notification: NotificationType, dismiss = true) =>
}),
Widget.Label({
class_name: "notification-time",
label: GLib.DateTime.new_from_unix_local(notification.time).format("%I:%M %p"),
label: GLib.DateTime.new_from_unix_local(notification.time).format("%H:%M"),
}),
Widget.Button({
class_name: "standard_icon_button",
child: Widget.Icon("window-close-symbolic"),
class_name: "standard_icon_button notification-close",
child: MaterialIcon("close"),
on_clicked: () => {
if (dismiss) {
notification.dismiss();
+13 -25
View File
@@ -1,4 +1,7 @@
import { MaterialIcon } from "icons";
const { GLib } = imports.gi;
const lock_command = `hyprlock`;
const logout_command = `loginctl kill-session $XDG_SESSION_ID`;
const shutdown_command = `systemctl poweroff`;
@@ -9,10 +12,7 @@ function LockButton({ icon, ...props }) {
let clickCount = 0;
let button = Widget.Button({
tooltip_text: "Lock",
child: Widget.Label({
label: icon,
class_name: "awesome_icon"
}),
child: MaterialIcon(icon, "20px"),
class_name: "outline_button",
...props,
})
@@ -37,10 +37,7 @@ function SuspendButton({ icon, ...props }) {
let clickCount = 0;
let button = Widget.Button({
tooltip_text: "Suspend",
child: Widget.Label({
label: icon,
class_name: "awesome_icon"
}),
child: MaterialIcon(icon, "20px"),
class_name: "outline_button",
...props,
})
@@ -67,10 +64,7 @@ function LogoutButton({ icon, ...props }) {
let clickCount = 0;
let button = Widget.Button({
tooltip_text: "Logout",
child: Widget.Label({
label: icon,
class_name: "awesome_icon"
}),
child: MaterialIcon(icon, "20px"),
class_name: "outline_button",
...props,
})
@@ -95,10 +89,7 @@ function RebootButton({ icon, ...props }) {
let clickCount = 0;
let button = Widget.Button({
tooltip_text: "Reboot",
child: Widget.Label({
label: icon,
class_name: "awesome_icon"
}),
child: MaterialIcon(icon, "20px"),
class_name: "outline_button",
...props,
})
@@ -123,10 +114,7 @@ function ShutdownButton({ icon, ...props }) {
let clickCount = 0;
let button = Widget.Button({
tooltip_text: "Shutdown",
child: Widget.Label({
label: icon,
class_name: "awesome_icon"
}),
child: MaterialIcon(icon, "20px"),
class_name: "outline_button",
...props,
})
@@ -154,23 +142,23 @@ export function Buttons() {
spacing: 5,
children: [
LockButton({
icon: "",
icon: "lock",
hexpand: true,
}),
SuspendButton({
icon: "",
icon: "clear_night",
hexpand: true,
}),
LogoutButton({
icon: "",
icon: "logout",
hexpand: true,
}),
RebootButton({
icon: "",
icon: "restart_alt",
hexpand: true,
}),
ShutdownButton({
icon: "",
icon: "power_settings_new",
hexpand: true,
})
]
+59 -59
View File
@@ -5,6 +5,7 @@ const powerProfiles = await Service.import('powerprofiles')
import { OpenSettings } from "apps/settings/main.ts";
import { WINDOW_NAME } from "./main.ts"
import { bluetooth_enabled, idle_inhibitor, night_light, screen_recorder } from "variables.ts";
import { MaterialIcon } from "icons.ts";
import Gtk from "gi://Gtk?version=3.0"
@@ -16,11 +17,7 @@ function WifiIndicator() {
return Widget.Box({
css: "padding-left: 15px; padding-right: 15px; padding-top: 5px; padding-bottom: 5px;",
children: [
Widget.Label({
label: "\udb82\udd28",
class_name: "awesome_icon",
css: `font-weight: bold; font-size: 20px; margin-right: 0.60em;`,
}),
MaterialIcon("signal_wifi_4_bar", "20px"),
Widget.Box({
visible: network.wifi.bind('enabled'),
orientation: Gtk.Orientation.VERTICAL,
@@ -47,10 +44,8 @@ function WifiIndicator() {
Widget.Box({
hpack: "end",
hexpand: true,
child: Widget.Label({
label: "",
class_name: "awesome_icon",
css: `font-weight: normal; font-size: 15px;`,
child: MaterialIcon("chevron_right", "20px", {
class_name: "material_icon icon arrow"
})
})
],
@@ -60,9 +55,7 @@ function WifiIndicator() {
const WiredIndicator = () => Widget.Box({
css: "padding-left: 15px; padding-right: 15px; padding-top: 5px; padding-bottom: 5px;",
children: [
Widget.Icon({
icon: network.wired.bind('icon_name'),
}),
MaterialIcon("settings_ethernet", "20px"),
Widget.Label({
label: "Internet",
}),
@@ -83,11 +76,7 @@ function IconAndName({ label, icon, padding = "0.3em", arrow = false }) {
let box = Widget.Box({
css: "padding-left: 15px; padding-right: 15px; padding-top: 5px; padding-bottom: 5px;",
children: [
Widget.Label({
label: icon,
class_name: "awesome_icon",
css: `font-weight: bold; font-size: 20px; margin-right: ${padding};`,
}),
MaterialIcon(icon, "20px"),
Widget.Label({
label: label,
justification: "center",
@@ -98,10 +87,8 @@ function IconAndName({ label, icon, padding = "0.3em", arrow = false }) {
const arrow = Widget.Box({
hpack: "end",
hexpand: true,
child: Widget.Label({
label: "",
class_name: "awesome_icon",
css: `font-weight: normal; font-size: 15px;`,
child: MaterialIcon("chevron_right", "20px", {
class_name: "material_icon icon arrow"
})
})
// @ts-ignore
@@ -133,7 +120,10 @@ function startRecordingTimer(button) {
recordingStartTime = Date.now();
recordingInterval = setInterval(() => {
let elapsedTime = Date.now() - recordingStartTime;
button.label = formatTime(elapsedTime);
button.child = IconAndName({
label: formatTime(elapsedTime),
icon: "stop_circle"
});
}, 1000);
}
@@ -141,7 +131,11 @@ function stopRecordingTimer(button) {
clearInterval(recordingInterval);
recordingStartTime = null;
recordingInterval = null;
button.label = '󰑋 Screen Recorder';
button.label = 'Screen Recorder';
button.child = IconAndName({
label: "Screen Recorder",
icon: "screen_record"
});
}
// Widget
@@ -177,7 +171,7 @@ function Page1() {
),
child: IconAndName({
label: "Bluetooth",
icon: "󰂯",
icon: "bluetooth",
arrow: true,
}),
on_primary_click: () => {
@@ -202,7 +196,7 @@ function Page1() {
.as(bool => bool ? "management_button active" : "management_button"),
child: IconAndName({
label: "Idle inhibitor",
icon: ""
icon: "schedule"
}),
onClicked: () => {
idle_inhibitor.setValue(!idle_inhibitor.value)
@@ -223,7 +217,8 @@ function Page1() {
},
child: IconAndName({
label: "Do Not Disturb",
icon: ""
icon: notifications.bind("dnd")
.as((bool) => bool ? "do_not_disturb_on" : "do_not_disturb_off")
})
})
]
@@ -234,37 +229,42 @@ function Page1() {
hexpand: true,
children: [
Widget.Button({
hexpand: true,
class_name: screen_recorder.bind()
.as(bool => bool ? "management_button active" : "management_button"),
on_clicked: (self) => {
hexpand: true,
class_name: screen_recorder.bind()
.as(bool => bool ? "management_button active" : "management_button"),
child: IconAndName({
label: "Screen Recorder",
icon: "screen_record"
}),
onClicked: (self) => {
isScreenRecordingOn().then(isRecording => {
if (isRecording) {
stopRecordingTimer(self);
} else {
startRecordingTimer(self);
}
self.toggleClassName("active-button", !isRecording);
self.toggleClassName("recording", !isRecording);
Utils.execAsync(['bash', '-c', 'mkdir -p ~/Videos/Screenrecordings; pkill wf-recorder; if [ $? -ne 0 ]; then wf-recorder -f ~/Videos/Screenrecordings/recording_"$(date +\'%b-%d-%Y-%I:%M:%S-%P\')".mp4 -g "$(slurp)" --pixel-format yuv420p; fi'])
.catch(logError)
.then(() => {
isScreenRecordingOn().then(newIsRecording => {
if (!newIsRecording) {
stopRecordingTimer(self);
}
})
});
} else {
startRecordingTimer(self);
}
self.toggleClassName("active-button", !isRecording);
self.toggleClassName("recording", !isRecording);
Utils.execAsync(['bash', '-c', 'mkdir -p ~/Videos/Screenrecordings; pkill wf-recorder; if [ $? -ne 0 ]; then wf-recorder -f ~/Videos/Screenrecordings/recording_"$(date +\'%b-%d-%Y-%I:%M:%S-%P\')".mp4 -g "$(slurp)" --pixel-format yuv420p; fi'])
.catch(logError)
.then(() => {
isScreenRecordingOn().then(newIsRecording => {
if (!newIsRecording) {
stopRecordingTimer(self);
}
});
},
child: IconAndName({
label: "Screen Recorder",
icon: "󰑋",
setup: self => {
self.label = '󰑋 Screen Recorder';
}
})
});
});
},
setup: (self) => {
isScreenRecordingOn().then(isRecording => {
if (isRecording) {
startRecordingTimer(self);
self.addClassName("active-button");
self.addClassName("recording");
}
});
}
}),
Widget.Button({
hexpand: true,
@@ -272,7 +272,7 @@ function Page1() {
.as(mode => mode ? "management_button active" : "management_button"),
child: IconAndName({
label: "Night Light",
icon: ""
icon: "nightlight"
}),
onClicked: () => {
night_light.setValue(!night_light.value)
@@ -317,7 +317,7 @@ function Page2() {
class_name: "management_button",
child: IconAndName({
label: "Color picker",
icon: "",
icon: "colorize",
arrow: true,
}),
on_primary_click: () => {
@@ -338,11 +338,11 @@ function Page2() {
icon: powerProfiles.bind('active_profile').as(profile => {
switch (profile) {
case 'balanced':
return '';
return 'balance';
case 'performance':
return '';
return 'bolt';
default:
return '';
return 'eco';
}
})
}),
@@ -377,7 +377,7 @@ function Page2() {
class_name: "management_button",
child: IconAndName({
label: "Settings",
icon: "",
icon: "settings",
arrow: true,
}),
on_primary_click: () => {
+6 -10
View File
@@ -1,8 +1,8 @@
import { NotificationsBox } from "./notifications.ts"
import { SystemBox } from "./system.ts"
let shown = Variable("Messages");
import Gtk from "gi://Gtk?version=3.0"
import { MaterialIcon } from "icons.ts";
type ButtonType = {
@@ -22,13 +22,9 @@ function Button({ page, label, icon }: ButtonType) {
children: [
Widget.Box({
orientation: Gtk.Orientation.VERTICAL,
hpack: "end",
hpack: "center",
class_name: "container",
child: Widget.Label({
hpack: "center",
label: icon,
class_name: "awesome_icon icon"
}),
child: MaterialIcon(icon, "20px"),
}),
Widget.Label({
label: label,
@@ -63,17 +59,17 @@ export function Navigation() {
Button({
page: "Messages",
label: "Messages",
icon: ""
icon: "chat"
}),
Button({
page: "Notifications",
label: "Notifs",
icon: ""
icon: "notifications"
}),
Button({
page: "System",
label: "System",
icon: ""
icon: "info"
})
]
})