updates
This commit is contained in:
1 parent
129838bebf
commit
4aa99210a8
19 files changed
+537
-322
No files matched your search
@@ -9,3 +9,4 @@
|
||||
"endOfLine": "auto",
|
||||
"printWidth": 120
|
||||
}
|
||||
|
||||
@@ -54,9 +54,12 @@ const saved_networks: VariableType<string[]> = Variable([], {
|
||||
});
|
||||
|
||||
function WifiScan() {
|
||||
network.wifi.scan();
|
||||
try {
|
||||
network.wifi?.scan();
|
||||
} catch (error) {
|
||||
print(error)
|
||||
}
|
||||
// await Utils.execAsync("nmcli device wifi rescan").catch(print)
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const WifiNetwork = (access_point: AccessPoint) => {
|
||||
|
||||
+6
-2
@@ -10,6 +10,8 @@ import {} from "apps/settings/main.ts";
|
||||
import {} from "apps/emoji/main.ts";
|
||||
import { cheatsheet } from "modules/cheatsheet.ts";
|
||||
import Window from "types/widgets/window";
|
||||
import { popups } from "modules/popups.ts";
|
||||
import { start_battery_warning_service } from "services/battery_warning.ts";
|
||||
const GLib = imports.gi.GLib;
|
||||
|
||||
const range = (length: number, start = 1) => Array.from({ length }, (_, i) => i + start);
|
||||
@@ -27,8 +29,8 @@ const Windows = () => [
|
||||
forMonitors(BarCornerTopLeft),
|
||||
forMonitors(BarCornerTopRight),
|
||||
sideright,
|
||||
cheatsheet,
|
||||
sideleft
|
||||
sideleft,
|
||||
forMonitors(popups)
|
||||
];
|
||||
|
||||
const CLOSE_ANIM_TIME = 210;
|
||||
@@ -64,3 +66,5 @@ Utils.monitorFile(`${GLib.get_home_dir()}/.cache/material/colors.json`, ReloadCS
|
||||
Utils.monitorFile(`${GLib.get_home_dir()}/.config/gtk-3.0/gtk.css`, ReloadGtkCSS);
|
||||
forMonitorsAsync(Bar);
|
||||
ReloadGtkCSS();
|
||||
|
||||
start_battery_warning_service()
|
||||
+40
-92
@@ -20,6 +20,7 @@ import { MaterialIcon } from "icons.js";
|
||||
import config from "services/configuration.ts";
|
||||
import { toggleAppsWindow, toggleMediaWindow } from "./sideleft/main.js";
|
||||
|
||||
|
||||
function checkKeymap() {
|
||||
const layout = Utils.execAsync(`hyprctl devices -j | jq -r '.keyboards[] | select(.main == true) | .active_keymap' | tail -n1 | cut -c1-2 | tr 'A-Z' 'a-z'`)
|
||||
.then(out => { return out })
|
||||
@@ -94,99 +95,44 @@ function getIconNameFromClass(windowClass: string) {
|
||||
const dispatch = (ws: string) => hyprland.messageAsync(`dispatch workspace ${ws}`).catch(print);
|
||||
|
||||
function Workspaces() {
|
||||
return EventBox({
|
||||
const activeId = hyprland.active.workspace.bind("id");
|
||||
let workspaceButtons = new Map();
|
||||
|
||||
function createWorkspaceButton(id: Number) {
|
||||
const button = Widget.Button({
|
||||
on_clicked: () => dispatch(`${id}`),
|
||||
child: Widget.Label(`${id}`),
|
||||
class_name: activeId.as((i) => `${i === id ? "active" : ""}`)
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
function updateWorkspaceButtons(workspaces: Workspace[]): Array<Button<any, any>> {
|
||||
workspaces.sort((a, b) => a.id - b.id);
|
||||
|
||||
const updatedButtons = new Map();
|
||||
|
||||
workspaces.forEach(({ id }) => {
|
||||
if (workspaceButtons.has(id)) {
|
||||
updatedButtons.set(id, workspaceButtons.get(id));
|
||||
} else {
|
||||
updatedButtons.set(id, createWorkspaceButton(id));
|
||||
}
|
||||
});
|
||||
if (workspaceButtons != updatedButtons) workspaceButtons = updatedButtons;
|
||||
|
||||
return Array.from(workspaceButtons.values());
|
||||
}
|
||||
|
||||
const workspaceButtonsArray = hyprland.bind("workspaces").as(updateWorkspaceButtons);
|
||||
|
||||
return Widget.EventBox({
|
||||
onScrollUp: () => dispatch("+1"),
|
||||
onScrollDown: () => dispatch("-1"),
|
||||
className: "workspaces",
|
||||
child: Box({
|
||||
className: "outer-workspace",
|
||||
children: Array.from({ length: 9 }, (_, i) => i + 1).map(
|
||||
(i, index, array) =>
|
||||
Box({
|
||||
attribute: i,
|
||||
className:
|
||||
index === 0
|
||||
? "workspace first"
|
||||
: index === array.length - 1
|
||||
? "workspace last"
|
||||
: "workspace",
|
||||
})
|
||||
),
|
||||
}).hook(hyprland, (self) => {
|
||||
let previousWorkspace = {};
|
||||
previousWorkspace.className = "";
|
||||
self.children.forEach((box, index, array) => {
|
||||
const isActive = hyprland.active.workspace.id === box.attribute;
|
||||
const isOccupied = hyprland.workspaces.some(
|
||||
(item) => item.id === box.attribute
|
||||
);
|
||||
let buttonClassName;
|
||||
if (isActive) {
|
||||
buttonClassName = "focused";
|
||||
box.className = "workspace focused";
|
||||
} else if (isOccupied) {
|
||||
buttonClassName = "occupied";
|
||||
box.className = "workspace occupied";
|
||||
} else {
|
||||
buttonClassName = "normal";
|
||||
box.className = "workspace normal";
|
||||
}
|
||||
|
||||
if (isOccupied || isActive) {
|
||||
if (index === 0) box.toggleClassName("occupied-start", true);
|
||||
else if (
|
||||
index === 8 &&
|
||||
previousWorkspace.className.indexOf("occupied-start") === -1
|
||||
)
|
||||
box.toggleClassName("occupied-single", true);
|
||||
else if (
|
||||
index === 8 &&
|
||||
previousWorkspace.className.indexOf("occupied-middle") === -1
|
||||
)
|
||||
box.toggleClassName("occupied-end", true);
|
||||
else if (
|
||||
previousWorkspace.className.indexOf("occupied-start") !== -1
|
||||
) {
|
||||
box.toggleClassName("occupied-end", true);
|
||||
} else if (
|
||||
previousWorkspace.className.indexOf("occupied-end") !== -1
|
||||
) {
|
||||
previousWorkspace.toggleClassName("occupied-middle", true);
|
||||
previousWorkspace.toggleClassName("occupied-end", false);
|
||||
box.toggleClassName("occupied-end", true);
|
||||
} else {
|
||||
box.toggleClassName("occupied-start", true);
|
||||
}
|
||||
} else {
|
||||
if (previousWorkspace.className.indexOf("occupied-start") !== -1) {
|
||||
previousWorkspace.toggleClassName("occupied-start", false);
|
||||
previousWorkspace.toggleClassName("occupied-single", true);
|
||||
}
|
||||
}
|
||||
|
||||
if (index === 0) {
|
||||
box.toggleClassName("first", true);
|
||||
} else if (index === array.length - 1) {
|
||||
box.toggleClassName("last", true);
|
||||
}
|
||||
|
||||
box.child = Button({
|
||||
className: buttonClassName,
|
||||
label: isActive ? `•` : box.attribute.toString(),
|
||||
onClicked: () => dispatch(box.attribute),
|
||||
setup: (self) => {
|
||||
if (index === 0) {
|
||||
self.toggleClassName("first", true);
|
||||
} else if (index === array.length - 1) {
|
||||
self.toggleClassName("last", true);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Pass current workspace attributes as previousWorkspace
|
||||
previousWorkspace = box;
|
||||
});
|
||||
}),
|
||||
child: Widget.Box({
|
||||
children: workspaceButtonsArray,
|
||||
class_name: "workspaces"
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -263,6 +209,7 @@ function BatteryLabel() {
|
||||
self.hook(battery, () => {
|
||||
self.children[0].label = getClosestBatteryLevel(battery.percent, battery.charging);
|
||||
self.visible = (battery.percent < 100 && battery.available) || config.config.always_show_battery;
|
||||
self.toggleClassName("critical", battery.percent < 15);
|
||||
});
|
||||
self.hook(config, () => {
|
||||
if (config.config.always_show_battery) {
|
||||
@@ -275,6 +222,7 @@ function BatteryLabel() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function SysTray() {
|
||||
return Widget.Box({
|
||||
class_name: "tray",
|
||||
@@ -562,7 +510,7 @@ function Right() {
|
||||
class_name: "modules-right",
|
||||
hpack: "end",
|
||||
spacing: 8,
|
||||
children: [volumeIndicator(), KeyboardLayout(), BatteryLabel(), SysTray(), Applets(), Clock(), OpenSideBar()]
|
||||
children: [/*Recorder,*/ volumeIndicator(), KeyboardLayout(), BatteryLabel(), SysTray(), Applets(), Clock(), OpenSideBar()]
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -23,15 +23,20 @@ const icons = {
|
||||
$mainmod: ""
|
||||
};
|
||||
|
||||
const replace = {
|
||||
slash: "/",
|
||||
period: ".",
|
||||
escape: "Esc"
|
||||
};
|
||||
|
||||
const category_icons = {
|
||||
actions: "accessibility_new",
|
||||
applications: "apps",
|
||||
windows: "select_window",
|
||||
workspaces: "overview_key",
|
||||
misc: "construction",
|
||||
plugins: "extension"
|
||||
tools: "build"
|
||||
};
|
||||
|
||||
const CheatSheet = () =>
|
||||
Widget.FlowBox({
|
||||
attribute: {
|
||||
@@ -90,7 +95,7 @@ const CheatSheet = () =>
|
||||
else
|
||||
key_box.pack_start(
|
||||
Widget.Label({
|
||||
label: key.charAt(0).toUpperCase() + key.slice(1),
|
||||
label: replace[key.toLowerCase()] || key.charAt(0).toUpperCase() + key.slice(1),
|
||||
class_name: "key",
|
||||
hpack: "start",
|
||||
vpack: "center"
|
||||
|
||||
@@ -73,7 +73,7 @@ export const Notification = (notification: NotificationType, dismiss = true) =>
|
||||
}),
|
||||
Widget.Label({
|
||||
class_name: "notification-time",
|
||||
label: GLib.DateTime.new_from_unix_local(notification.time).format("%H:%M")
|
||||
label: GLib.DateTime.new_from_unix_local(notification.time).format("%I:%M %P")
|
||||
}),
|
||||
Widget.Button({
|
||||
class_name: "standard_icon_button notification-close",
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
const audio = await Service.import("audio");
|
||||
import backlight_service from "services/backlight.ts";
|
||||
import { MaterialIcon } from "icons.ts";
|
||||
import Gtk from "types/@girs/gtk-3.0/gtk-3.0";
|
||||
import Revealer from "types/widgets/revealer";
|
||||
import Box from "types/widgets/box";
|
||||
import Slider from "types/widgets/slider";
|
||||
import { Binding } from "types/service";
|
||||
|
||||
const brightnessIcons = [
|
||||
"brightness_1",
|
||||
"brightness_2",
|
||||
"brightness_3",
|
||||
"brightness_4",
|
||||
"brightness_5",
|
||||
"brightness_6",
|
||||
"brightness_7"
|
||||
];
|
||||
|
||||
function getBrightnessIcon(brightness: number): string {
|
||||
const totalIcons = brightnessIcons.length;
|
||||
const maxBrightness = 1;
|
||||
const ratio = 1.6;
|
||||
|
||||
let thresholds: number[] = [];
|
||||
for (let i = 0; i < totalIcons; i++) {
|
||||
const threshold = maxBrightness / Math.pow(ratio, totalIcons - i - 1);
|
||||
thresholds.push(threshold);
|
||||
}
|
||||
|
||||
for (let i = 0; i < totalIcons; i++) {
|
||||
if (brightness < thresholds[i]) {
|
||||
return brightnessIcons[i];
|
||||
}
|
||||
}
|
||||
|
||||
return brightnessIcons[totalIcons - 1];
|
||||
}
|
||||
|
||||
type popup_on_change = ((self: Slider<any>) => void) | undefined;
|
||||
type popup_setup =
|
||||
| ((
|
||||
self: Revealer<
|
||||
Box<Gtk.Widget | Slider<unknown>, unknown>,
|
||||
{
|
||||
count: number;
|
||||
}
|
||||
>
|
||||
) => void)
|
||||
| undefined;
|
||||
|
||||
const default_popup = (
|
||||
icon: Gtk.Widget,
|
||||
value: number | Binding<any, any, number>,
|
||||
on_change?: popup_on_change,
|
||||
setup?: popup_setup
|
||||
) =>
|
||||
Widget.Revealer({
|
||||
transition_duration: 200,
|
||||
transition: "slide_up",
|
||||
child: Widget.Revealer({
|
||||
reveal_child: false,
|
||||
transition_duration: 190,
|
||||
transition: "crossfade",
|
||||
child: Widget.Box({
|
||||
class_name: "popup",
|
||||
children: [
|
||||
icon,
|
||||
Widget.Slider({
|
||||
min: 0,
|
||||
max: 100,
|
||||
draw_value: false,
|
||||
class_name: "popup_slider",
|
||||
value: value,
|
||||
on_change: on_change
|
||||
})
|
||||
]
|
||||
}),
|
||||
attribute: { count: 0 },
|
||||
setup: setup
|
||||
}),
|
||||
setup: (self) => {
|
||||
self.child.connect("notify::child-revealed", () => {
|
||||
self.reveal_child = self.child.child_revealed;
|
||||
});
|
||||
self.child.connect("notify::reveal-child", () => {
|
||||
if (self.child.reveal_child) self.reveal_child = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const backlight_popup = () =>
|
||||
default_popup(
|
||||
MaterialIcon("brightness_1").hook(backlight_service, (self) => {
|
||||
self.label = getBrightnessIcon(backlight_service.screen_value);
|
||||
}),
|
||||
backlight_service.bind("screen_value").as((n) => n * 100),
|
||||
(self) => {
|
||||
backlight_service.screen_value = self.value / 100;
|
||||
},
|
||||
(self) => {
|
||||
backlight_service.connect("screen-changed", (_) => {
|
||||
self.attribute.count++;
|
||||
if (self.attribute.count > 0) self.reveal_child = true;
|
||||
Utils.timeout(1500, () => {
|
||||
self.attribute.count--;
|
||||
if (self.attribute.count <= 0) self.reveal_child = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const volume_popup = () =>
|
||||
default_popup(
|
||||
MaterialIcon("volume_off", "20px").hook(audio.speaker, (self) => {
|
||||
const vol = audio.speaker.volume * 100;
|
||||
const icon = [
|
||||
[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.label = "volume_off";
|
||||
else self.label = String(icon!);
|
||||
}),
|
||||
audio.speaker.bind("volume").as((volume) => Math.floor(volume * 100)),
|
||||
(self) => {
|
||||
audio.speaker.volume = self.value / 100;
|
||||
},
|
||||
(self) => {
|
||||
audio.speaker.connect("notify::volume", (_) => {
|
||||
self.attribute.count++;
|
||||
if (self.attribute.count > 0) self.reveal_child = true;
|
||||
Utils.timeout(1500, () => {
|
||||
self.attribute.count--;
|
||||
if (self.attribute.count <= 0) self.reveal_child = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
export const popups = (monitor = 0) => {
|
||||
const _volume_popup = volume_popup();
|
||||
const _backlight_popup = backlight_popup();
|
||||
return Widget.Window({
|
||||
monitor,
|
||||
name: `popups${monitor}`,
|
||||
child: Widget.Box({
|
||||
css: "min-height: 1px; min-width: 1px;",
|
||||
vertical: true,
|
||||
children: [_backlight_popup, _volume_popup]
|
||||
}),
|
||||
class_name: "popups",
|
||||
anchor: ["bottom"],
|
||||
visible: true
|
||||
});
|
||||
};
|
||||
@@ -75,7 +75,7 @@ function AppItem(app: Application): Box<any, any> {
|
||||
|
||||
button.connect("clicked", () => {
|
||||
clickCount++;
|
||||
if (clickCount === 1) {
|
||||
if (clickCount === 2) {
|
||||
incrementLaunchCount(app.name);
|
||||
App.closeWindow(WINDOW_NAME);
|
||||
app.launch();
|
||||
|
||||
@@ -4,6 +4,7 @@ const GLib = imports.gi.GLib;
|
||||
import Box from "types/widgets/box";
|
||||
import { WINDOW_NAME } from "modules/sideleft/main";
|
||||
|
||||
// Function to get clipboard history
|
||||
async function getClipboardHistory() {
|
||||
try {
|
||||
const process = new Gio.Subprocess({
|
||||
@@ -21,6 +22,7 @@ async function getClipboardHistory() {
|
||||
}
|
||||
}
|
||||
|
||||
// Function to clear clipboard history
|
||||
async function clearClipboardHistory() {
|
||||
try {
|
||||
const process = new Gio.Subprocess({
|
||||
@@ -35,32 +37,46 @@ async function clearClipboardHistory() {
|
||||
}
|
||||
}
|
||||
|
||||
// Function to show image preview
|
||||
async function showImagePreview(id, format, width, height) {
|
||||
try {
|
||||
const file = await Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --save-by-id ${id}`);
|
||||
const _widthPx = Number(width);
|
||||
const heightPx = Number(height);
|
||||
const maxWidth = 400;
|
||||
const widthPx = (_widthPx / heightPx) * 150;
|
||||
|
||||
let css = `background-image: url("${file}");`;
|
||||
|
||||
if (widthPx > maxWidth) {
|
||||
const newHeightPx = (150 / widthPx) * maxWidth;
|
||||
css += `min-height: ${newHeightPx}px; min-width: ${maxWidth}px;`;
|
||||
} else {
|
||||
css += `min-height: 150px; min-width: ${widthPx}px;`;
|
||||
}
|
||||
|
||||
return css;
|
||||
} catch (error) {
|
||||
// Handle error silently or log to a file if needed
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
// Function to create a clipboard history item
|
||||
function ClipHistItem(entry) {
|
||||
const [id, ...content] = entry.split("\t");
|
||||
const [id, ..._content] = entry.split("\t");
|
||||
const content = _content.join(" ").trim();
|
||||
const matches = content.match(/\[\[ binary data (\d+) (KiB|MiB) (\w+) (\d+)x(\d+) \]\]/);
|
||||
let _show_image = false;
|
||||
|
||||
let clickCount = 0;
|
||||
const button = Widget.Button({
|
||||
class_name: "clip_container",
|
||||
child: Widget.Box({
|
||||
children: [
|
||||
Widget.Label({
|
||||
label: id,
|
||||
class_name: "clip_id",
|
||||
xalign: 0,
|
||||
vpack: "center"
|
||||
}),
|
||||
Widget.Label({
|
||||
label: "・",
|
||||
class_name: "dot_divider",
|
||||
xalign: 0,
|
||||
vpack: "center"
|
||||
}),
|
||||
Widget.Label({
|
||||
label: content.join(" ").trim(),
|
||||
class_name: "clip_label",
|
||||
xalign: 0,
|
||||
vpack: "center",
|
||||
truncate: "end"
|
||||
})
|
||||
Widget.Label({ label: id, class_name: "clip_id", xalign: 0, vpack: "center" }),
|
||||
Widget.Label({ label: "・", class_name: "dot_divider", xalign: 0, vpack: "center" }),
|
||||
Widget.Label({ label: content, class_name: "clip_label", xalign: 0, vpack: "center", truncate: "end" })
|
||||
]
|
||||
})
|
||||
});
|
||||
@@ -68,9 +84,9 @@ function ClipHistItem(entry) {
|
||||
button.connect("clicked", async () => {
|
||||
try {
|
||||
clickCount++;
|
||||
if (clickCount === 1) {
|
||||
if (clickCount === 2) {
|
||||
App.closeWindow(WINDOW_NAME);
|
||||
Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --copy-by-id ${id}`);
|
||||
await Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --copy-by-id ${id}`);
|
||||
clickCount = 0;
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -82,8 +98,32 @@ function ClipHistItem(entry) {
|
||||
clickCount = 0;
|
||||
});
|
||||
|
||||
if (matches) {
|
||||
const format = matches[3];
|
||||
const width = matches[4];
|
||||
const height = matches[5];
|
||||
if (format === "png") {
|
||||
button.toggleClassName("with_image", true);
|
||||
button.connect("clicked", async () => {
|
||||
if (!_show_image) {
|
||||
const css = await showImagePreview(id, format, width, height);
|
||||
const box = button.child;
|
||||
box.children[2].destroy(); // Remove text label
|
||||
const icon = Widget.Box({
|
||||
vpack: "center",
|
||||
css: css,
|
||||
class_name: "preview"
|
||||
});
|
||||
// @ts-expect-error
|
||||
box.children = [...box.children, icon];
|
||||
_show_image = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return Widget.Box({
|
||||
attribute: { content: content.join(" ").trim() },
|
||||
attribute: { content: content },
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
children: [
|
||||
button,
|
||||
@@ -95,6 +135,7 @@ function ClipHistItem(entry) {
|
||||
});
|
||||
}
|
||||
|
||||
// Main export function for clipboard history widget
|
||||
export const cliphist = () => {
|
||||
const list = Widget.Box({ vertical: true, vexpand: true });
|
||||
const loadingIndicator = Widget.Label({
|
||||
@@ -111,13 +152,11 @@ export const cliphist = () => {
|
||||
if (entries.length > 0) {
|
||||
list.children = entries.map(ClipHistItem);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
list.children = [Widget.Label ({
|
||||
list.children = [Widget.Label({
|
||||
label: "Error loading history",
|
||||
class_name: "error_loading"
|
||||
})
|
||||
];
|
||||
})];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,10 +185,7 @@ export const cliphist = () => {
|
||||
|
||||
const searchBox = Widget.Box({
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
children: [
|
||||
entry,
|
||||
clearButton
|
||||
]
|
||||
children: [entry, clearButton]
|
||||
});
|
||||
|
||||
return Widget.Box({
|
||||
|
||||
@@ -30,8 +30,15 @@ export function toggleClipsWindow() {
|
||||
shown.setValue("clips");
|
||||
}
|
||||
}
|
||||
export function toggleChatsWindow() {
|
||||
if (shown.value == "gemini" && sideleft.visible) App.closeWindow(WINDOW_NAME); else {
|
||||
App.openWindow(WINDOW_NAME);
|
||||
shown.setValue("gemini");
|
||||
}
|
||||
}
|
||||
|
||||
globalThis.toggleClipsWindow = toggleClipsWindow;
|
||||
globalThis.toggleChatsWindow = toggleChatsWindow;
|
||||
globalThis.toggleMediaWindow = toggleMediaWindow;
|
||||
globalThis.toggleAppsWindow = toggleAppsWindow;
|
||||
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
import { cpu_cores, cpu_name, kernel_name, amount_of_ram, gpu_name, cur_uptime } from "variables";
|
||||
import {
|
||||
cpu_cores,
|
||||
cpu_name,
|
||||
kernel_name,
|
||||
amount_of_ram,
|
||||
gpu_name,
|
||||
cur_uptime,
|
||||
current_brightness
|
||||
} from "variables.ts";
|
||||
import Gtk from "gi://Gtk?version=3.0";
|
||||
import { Variable as VariableType } from "types/variable";
|
||||
import backlight_service from "services/backlight.ts";
|
||||
|
||||
type InfoType = {
|
||||
cpu: string;
|
||||
@@ -60,28 +69,6 @@ const usage = Variable(
|
||||
}
|
||||
);
|
||||
|
||||
function checkBacklight() {
|
||||
const get = Utils.execAsync(`${App.configDir}/scripts/backlight.sh --get`)
|
||||
.then((out) => Number(out.trim()))
|
||||
.catch(print);
|
||||
return get;
|
||||
}
|
||||
|
||||
function checkBrightness() {
|
||||
const get = Utils.execAsync(`${App.configDir}/scripts/brightness.sh --get`)
|
||||
.then((out) => Number(out.trim()))
|
||||
.catch(print);
|
||||
return get;
|
||||
}
|
||||
|
||||
const current_backlight = Variable(100, {
|
||||
poll: [500, checkBacklight]
|
||||
});
|
||||
|
||||
const current_brightness = Variable(100, {
|
||||
poll: [500, checkBrightness]
|
||||
});
|
||||
|
||||
const Usage = (name: string, var_name: keyof InfoType, class_name: string | undefined) => {
|
||||
const usage_progress_bar = Widget.ProgressBar({
|
||||
class_name: "usage_bar",
|
||||
@@ -145,10 +132,9 @@ export function SystemBox() {
|
||||
draw_value: false,
|
||||
class_name: "system_scale backlight",
|
||||
// @ts-ignore
|
||||
value: current_backlight.bind(),
|
||||
value: backlight_service.bind("screen_value").as(n => n * 100),
|
||||
on_change: (self) => {
|
||||
current_backlight.setValue(Number(self.value));
|
||||
Utils.execAsync(`${App.configDir}/scripts/backlight.sh --smooth ${self.value}`).catch(print);
|
||||
backlight_service.screen_value = self.value / 100;
|
||||
},
|
||||
tooltip_markup: "Backlight"
|
||||
});
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
#!/bin/bash
|
||||
LOCKFILE=/tmp/smooth_backlight.lock
|
||||
BRIGHTNESS=/tmp/set_backlight
|
||||
smooth() {
|
||||
if [ -n "$1" ]; then
|
||||
rounded_value=$(echo "scale=0; $1/1" | bc)
|
||||
echo $rounded_value > $BRIGHTNESS
|
||||
else
|
||||
echo "Not enough arguments"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e "$LOCKFILE" ] && kill -0 "$(cat $LOCKFILE)"; then
|
||||
echo "locked"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
trap "rm -f $LOCKFILE; exit" INT TERM EXIT
|
||||
echo $$ > "$LOCKFILE"
|
||||
|
||||
smooth_brightness() {
|
||||
local max_brightness=$(brightnessctl m)
|
||||
local step=$((max_brightness / 100))
|
||||
|
||||
while true; do
|
||||
local target_brightness=$(cat $BRIGHTNESS)
|
||||
local current_brightness=$(brightnessctl g)
|
||||
target_brightness=$(echo "$max_brightness * $target_brightness / 100" | bc)
|
||||
|
||||
if [ $current_brightness -eq $target_brightness ]; then
|
||||
exit 0
|
||||
fi
|
||||
while [ $current_brightness -ne $target_brightness ]; do
|
||||
if [ $current_brightness -lt $target_brightness ]; then
|
||||
current_brightness=$((current_brightness + step))
|
||||
else
|
||||
current_brightness=$((current_brightness - step))
|
||||
fi
|
||||
|
||||
brightnessctl s $current_brightness > /dev/null 2>&1
|
||||
sleep 0.001
|
||||
|
||||
local new_target_brightness=$(cat $BRIGHTNESS)
|
||||
new_target_brightness=$(echo "$max_brightness * $new_target_brightness / 100" | bc)
|
||||
if [ $new_target_brightness -ne $target_brightness ]; then
|
||||
target_brightness=$new_target_brightness
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
smooth_brightness
|
||||
|
||||
rm -f "$LOCKFILE"
|
||||
trap - INT TERM EXIT
|
||||
}
|
||||
|
||||
set() {
|
||||
if [ -n "$1" ]; then
|
||||
brightnessctl s $1
|
||||
else
|
||||
echo "Not enough arguments"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
get() {
|
||||
if [ -e "$LOCKFILE" ] && kill -0 "$(cat $LOCKFILE)"; then
|
||||
local target_brightness=$(cat $BRIGHTNESS)
|
||||
echo $target_brightness
|
||||
exit 0
|
||||
fi
|
||||
brightness=$(brightnessctl g)
|
||||
max_brightness=$(brightnessctl m)
|
||||
percentage=$((100 * brightness / max_brightness))
|
||||
|
||||
echo "$percentage"
|
||||
}
|
||||
|
||||
if [[ "$1" == "--smooth" ]]; then
|
||||
smooth $2
|
||||
elif [[ "$1" == "--set" ]]; then
|
||||
set $2
|
||||
elif [[ "$1" == "--get" ]]; then
|
||||
get
|
||||
fi
|
||||
@@ -1,11 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
get() {
|
||||
clip_list=$(cliphist list)
|
||||
|
||||
while IFS= read -r line; do
|
||||
echo "$line" | iconv -t UTF-8
|
||||
done <<<"$clip_list"
|
||||
cliphist list | iconv -f ISO-8859-1 -t UTF-8 -c
|
||||
}
|
||||
|
||||
copy_by_id() {
|
||||
@@ -13,8 +9,29 @@ copy_by_id() {
|
||||
cliphist decode $id | wl-copy
|
||||
}
|
||||
|
||||
save_cache_file() {
|
||||
id=$1
|
||||
|
||||
output_file="/tmp/ags/cliphist/$id.png"
|
||||
|
||||
if [[ ! -f "$output_file" ]]; then
|
||||
mkdir -p "/tmp/ags/cliphist/"
|
||||
cliphist decode "$id" >"$output_file"
|
||||
fi
|
||||
|
||||
echo $output_file
|
||||
}
|
||||
|
||||
clear_tmp() {
|
||||
rm "/tmp/ags/cliphist/*"
|
||||
}
|
||||
|
||||
if [[ "$1" == "--get" ]]; then
|
||||
get
|
||||
elif [[ "$1" == "--copy-by-id" ]]; then
|
||||
{ copy_by_id "$2"; }
|
||||
elif [[ "$1" == "--save-by-id" ]]; then
|
||||
{ save_cache_file "$2"; }
|
||||
elif [[ "$1" == "--clear-cache" ]]; then
|
||||
clear_tmp
|
||||
fi
|
||||
@@ -9,11 +9,11 @@ toggle() {
|
||||
|
||||
if [ "$VALUE" == "dark" ]; then
|
||||
python -O $GENERATOR -R --color-scheme light --scheme $GENERATION_SCHEME
|
||||
echo "light" > $FILE
|
||||
|
||||
echo "light" >$FILE
|
||||
|
||||
elif [ "$VALUE" == "light" ]; then
|
||||
python -O $GENERATOR -R --color-scheme dark --scheme $GENERATION_SCHEME
|
||||
echo "dark" > $FILE
|
||||
echo "dark" >$FILE
|
||||
else
|
||||
echo "Unknown value: $VALUE"
|
||||
fi
|
||||
@@ -21,12 +21,11 @@ toggle() {
|
||||
|
||||
set() {
|
||||
python -O $GENERATOR -R --color-scheme $1 --scheme $GENERATION_SCHEME
|
||||
echo $1 > $FILE
|
||||
echo $1 >$FILE
|
||||
}
|
||||
|
||||
if [[ "$1" == "--toggle" ]]; then
|
||||
toggle
|
||||
elif [[ "$1" == "--set" ]]; then
|
||||
elif [[ "$1" == "--set" ]]; then
|
||||
set $2
|
||||
fi
|
||||
|
||||
@@ -42,7 +42,15 @@ get_os() {
|
||||
}
|
||||
|
||||
get_uptime() {
|
||||
uptime -p | sed -e 's/up //' -e 's/ hours\{0,1\}/h/g' -e 's/ minutes\{0,1\}/min/g' -e 's/ days\{0,1\}/d/g' -e 's/ seconds\{0,1\}/sec/g' -e 's/ //g' -e 's/,/, /'
|
||||
uptime -p | sed -e 's/up //' \
|
||||
-e 's/ hours\{0,1\}/h/g' \
|
||||
-e 's/ minutes\{0,1\}/min/g' \
|
||||
-e 's/ days\{0,1\}/d/g' \
|
||||
-e 's/ seconds\{0,1\}/sec/g' \
|
||||
-e 's/,/, /g' \
|
||||
-e 's/ */ /g' \
|
||||
-e 's/^ //g' \
|
||||
-e 's/ $//g'
|
||||
}
|
||||
|
||||
if [[ "$1" == "--cpu-usage" ]]; then
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
class BrightnessService extends Service {
|
||||
static {
|
||||
Service.register(
|
||||
this,
|
||||
{
|
||||
"screen-changed": ["float"]
|
||||
},
|
||||
{
|
||||
"screen-value": ["float", "rw"]
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#interface = Utils.exec("sh -c 'ls -w1 /sys/class/backlight | head -1'");
|
||||
|
||||
#screenValue = 0;
|
||||
#max = Number(Utils.exec("brightnessctl max"));
|
||||
#brightness_file = `/sys/class/backlight/${this.#interface}/brightness`;
|
||||
|
||||
get screen_value() {
|
||||
return this.#screenValue;
|
||||
}
|
||||
|
||||
set screen_value(percent) {
|
||||
if (percent < 0) percent = 0;
|
||||
|
||||
if (percent > 1) percent = 1;
|
||||
|
||||
Utils.execAsync(`brightnessctl set ${percent * 100}% -q`);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
Utils.monitorFile(this.#brightness_file, () => this.#onChange());
|
||||
|
||||
this.#onChange();
|
||||
}
|
||||
|
||||
async #onChange() {
|
||||
this.#screenValue = Number(await Utils.readFileAsync(this.#brightness_file)) / this.#max;
|
||||
|
||||
this.emit("changed");
|
||||
this.notify("screen-value");
|
||||
|
||||
this.emit("screen-changed", this.#screenValue);
|
||||
}
|
||||
}
|
||||
|
||||
const service = new BrightnessService();
|
||||
|
||||
export default service;
|
||||
@@ -0,0 +1,35 @@
|
||||
const battery = await Service.import("battery");
|
||||
|
||||
const battery_messages = {
|
||||
warnLevels: [15, 5],
|
||||
warnTitles: ["Low battery", "Very low battery"],
|
||||
warnMessages: ["Plug in the charger", "You there?"]
|
||||
};
|
||||
|
||||
let battery_warned = false;
|
||||
|
||||
async function battery_notification() {
|
||||
const percent = battery.percent;
|
||||
const charging = battery.charging;
|
||||
if (charging) {
|
||||
battery_warned = false;
|
||||
return;
|
||||
}
|
||||
for (let i = battery_messages.warnLevels.length - 1; i >= 0; i--) {
|
||||
if (percent <= battery_messages.warnLevels[i] && !charging && !battery_warned) {
|
||||
battery_warned = true;
|
||||
Utils.execAsync([
|
||||
"bash",
|
||||
"-c",
|
||||
`notify-send "${battery_messages.warnTitles[i]}" "${battery_messages.warnMessages[i]}" -u critical &`
|
||||
]).catch(print);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function start_battery_warning_service() {
|
||||
Utils.timeout(1, () => {
|
||||
battery.connect("changed", () => battery_notification().catch(print));
|
||||
});
|
||||
}
|
||||
+95
-62
@@ -104,80 +104,44 @@ separator {
|
||||
* Workspaces
|
||||
* ----------------------------------------------------- */
|
||||
|
||||
.outer-workspace {
|
||||
background-color: @surfaceContainerHigh;
|
||||
border-radius: 20px;
|
||||
.workspaces {
|
||||
border-radius: 16px;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
font-size: 16px;
|
||||
color: @onSurface;
|
||||
background: @surfaceContainer;
|
||||
}
|
||||
|
||||
.workspace {
|
||||
background-color: @surfaceVariant;
|
||||
/* padding: 0; */
|
||||
.workspaces * {
|
||||
transition: all 0.35s ease-in-out;
|
||||
transition-property: background-color, color, min-width;
|
||||
}
|
||||
|
||||
.workspace button {
|
||||
background-color: transparent;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
.workspaces button {
|
||||
padding: 0px 5px;
|
||||
margin: 4px 3px;
|
||||
border-radius: 16px;
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
.workspace.first {
|
||||
border-radius: 20px 0 0 20px;
|
||||
}
|
||||
.workspace.last {
|
||||
border-radius: 0 20px 20px 0;
|
||||
.workspaces button label {
|
||||
color: @onSurfaceVariant;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.workspace.normal,
|
||||
.workspace button.normal {
|
||||
background-color: transparent;
|
||||
color: @surfaceDim;
|
||||
.workspaces button:hover {
|
||||
color: @onSurface;
|
||||
background-color: mix(@onSurface, @surface, 0.85);
|
||||
}
|
||||
|
||||
.workspace button.normal:hover {
|
||||
border-radius: 20px;
|
||||
background-color: @primary;
|
||||
color: @surfaceDim;
|
||||
.workspaces button.active {
|
||||
background: @secondaryContainer;
|
||||
min-width: 40px;
|
||||
}
|
||||
|
||||
.workspace button.focused {
|
||||
background-color: @outline;
|
||||
color: @secondary;
|
||||
font-weight: bold;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.workspace button.focused:hover {
|
||||
border-radius: 20px;
|
||||
color: @primary;
|
||||
background-color: mix(@onSurface, @surface, 0.85);
|
||||
}
|
||||
|
||||
.workspace button.occupied {
|
||||
color: @primary;
|
||||
}
|
||||
|
||||
.workspaces button.occupied:hover {
|
||||
border-radius: 20px;
|
||||
background-color: mix(@onSurface, @surface, 0.85);
|
||||
color: @surfaceDim;
|
||||
}
|
||||
|
||||
.workspace.occupied-single {
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.workspace.occupied-start {
|
||||
border-radius: 20px 0 0 20px;
|
||||
}
|
||||
|
||||
.workspace.occupied-middle {
|
||||
border-radius: 0px;
|
||||
}
|
||||
|
||||
.workspace.occupied-end {
|
||||
border-radius: 0px 20px 20px 0px;
|
||||
.workspaces button.active label {
|
||||
color: @onSecondaryContainer;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------
|
||||
@@ -352,6 +316,13 @@ window.notification-popups box.notifications {
|
||||
font-feature-settings: "tnum";
|
||||
}
|
||||
|
||||
.clip_container .preview {
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.clip_container .dot_divider {
|
||||
font-weight: 900;
|
||||
font-size: 12px;
|
||||
@@ -370,6 +341,10 @@ window.notification-popups box.notifications {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.clip_container.with_image .clip_label {
|
||||
color: @tertiary;
|
||||
}
|
||||
|
||||
.clear_history_button {
|
||||
background-color: @surfaceContainerHigh;
|
||||
color: @onSurface;
|
||||
@@ -439,6 +414,14 @@ window.notification-popups box.notifications {
|
||||
color: @onSurface;
|
||||
}
|
||||
|
||||
.battery.critical {
|
||||
background-color: @error;
|
||||
}
|
||||
|
||||
.battery.critical label, .battery.critical .icon {
|
||||
color: @onError;
|
||||
}
|
||||
|
||||
.bar_applets {
|
||||
background-color: @surfaceContainer;
|
||||
border-radius: 100px;
|
||||
@@ -1578,6 +1561,56 @@ switch:checked:active slider {
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* Popups
|
||||
* ----------------------------------------------------- */
|
||||
.popups {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.popups .popup {
|
||||
background-color: @surfaceContainer;
|
||||
margin-bottom: 14px;
|
||||
padding: 4px;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
.popup_slider {
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.popup .icon {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.popup_slider slider {
|
||||
color: @onPrimary;
|
||||
background-color: @primary;
|
||||
background-size: 20px 20px;
|
||||
min-width: 5px;
|
||||
min-height: 14px;
|
||||
border-radius: 100px;
|
||||
padding: 0px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
margin-top: -16px;
|
||||
margin-bottom: -16px;
|
||||
box-shadow: -4px 0px 0px 1px @surfaceContainer, 4px 0px 0px 1px @surfaceContainer;
|
||||
}
|
||||
|
||||
.popup_slider trough {
|
||||
background-color: @secondaryContainer;
|
||||
min-height: 10px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.popup_slider highlight {
|
||||
border-radius: 100px 0px 0px 100px;
|
||||
background-color: @primary;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* Material
|
||||
* ----------------------------------------------------- */
|
||||
|
||||
+13
-2
@@ -60,7 +60,7 @@ export type WeatherJson = {
|
||||
|
||||
export const theme = Variable("dark");
|
||||
export const main_color = Variable("#000000");
|
||||
export const current_wallpaper = Variable(`${GLib.get_home_dir()}/Pictures/wallpapers/1.jpg`);
|
||||
export const current_wallpaper = Variable(`${GLib.get_home_dir()}/Pictures/wallpapers/default.png`);
|
||||
// @ts-expect-error
|
||||
export const weather: VariableType<WeatherJson> = Variable({ no_data: true });
|
||||
const reload = () => {
|
||||
@@ -73,7 +73,7 @@ const reload = () => {
|
||||
})
|
||||
.catch(print);
|
||||
}
|
||||
Utils.interval(100, reload);
|
||||
Utils.interval(150, reload);
|
||||
configuration.connect("changed", reload)
|
||||
|
||||
export const idle_inhibitor = Variable(false);
|
||||
@@ -105,6 +105,17 @@ export const generation_scheme_file = `${GLib.get_home_dir()}/dotfiles/.settings
|
||||
export const color_scheme_file = `${GLib.get_home_dir()}/dotfiles/.settings/color-scheme`;
|
||||
export const wallpaper_cache_file = `${GLib.get_home_dir()}/.cache/current_wallpaper`;
|
||||
|
||||
function checkBrightness() {
|
||||
const get = Utils.execAsync(`${App.configDir}/scripts/brightness.sh --get`)
|
||||
.then((out) => Number(out.trim()))
|
||||
.catch(print);
|
||||
return get;
|
||||
}
|
||||
|
||||
export const current_brightness = Variable(100, {
|
||||
poll: [500, checkBrightness]
|
||||
});
|
||||
|
||||
function readFiles() {
|
||||
Utils.readFileAsync(custom_color_file)
|
||||
.then((out) => {
|
||||
|
||||
Reference in new issue
Block a user