This commit is contained in:
sankalp committed 2024-08-13 06:52:12 +05:45
1 parent 21d06eb075
commit c042bd9f8c
19 files changed
+259 -268

No files matched your search

+8 -8
View File
@@ -25,7 +25,7 @@ const color_schemes = {
}
};
export const updateGenerationScheme = async (scheme: string) => {
export const update_scheme = async (scheme: string) => {
try {
const settingsContent = await Utils.readFile(settings_file);
const settings = JSON.parse(settingsContent);
@@ -82,7 +82,7 @@ function toHex(value: number) {
return hex.length == 1 ? "0" + hex : hex;
}
const ReloadTheme = async () => {
const reload_theme = async () => {
let { color, scheme } = theme_settings;
let _color = color.value;
let color_to_write = _color;
@@ -96,7 +96,7 @@ const ReloadTheme = async () => {
theme_reload_lock = true;
const updateSettingsFile = async (customColor: string) => {
const update_settings_file = async (customColor: string) => {
try {
const settingsContent = await Utils.readFile(settings_file);
const settings = JSON.parse(settingsContent);
@@ -112,7 +112,7 @@ const ReloadTheme = async () => {
await Utils.execAsync(
`python -O ${color_generator} -w --color-scheme "${theme.value}" --scheme "${scheme.value}"`
);
await updateSettingsFile("none");
await update_settings_file("none");
} catch (error) {
print(error);
} finally {
@@ -125,7 +125,7 @@ const ReloadTheme = async () => {
await Utils.execAsync(
`python -O ${color_generator} --color "${_color}" --color-scheme "${theme.value}" --scheme "${scheme.value}"`
);
await updateSettingsFile(color_to_write);
await update_settings_file(color_to_write);
} catch (error) {
print(error);
await Default();
@@ -217,7 +217,7 @@ const ThemeColor = () =>
text: theme_settings.color.value,
on_accept: (self) => {
theme_settings.color.setValue(self.text!);
ReloadTheme();
reload_theme();
},
on_change: (self) => {
if (self.text!.length > 6) self.css = `border: 2px solid; border-color: ${self.text!}`;
@@ -272,8 +272,8 @@ const ColorScheme = () =>
self.connect("changed", () => {
selected = self.get_active_text();
theme_settings.scheme.setValue(color_schemes[selected!]);
updateGenerationScheme(color_schemes[selected!]);
ReloadTheme();
update_scheme(color_schemes[selected!]);
reload_theme();
});
}
})
-2
View File
@@ -1,6 +1,4 @@
import { type BluetoothDevice } from "types/service/bluetooth";
import Gtk from "gi://Gtk?version=3.0";
import { timeout } from "resource:///com/github/Aylur/ags/utils.js";
const bluetooth = await Service.import("bluetooth");
+6 -5
View File
@@ -6,6 +6,10 @@ type StringOrBinding = string | Binding<any, any, string> | null;
const empty_func = () => {};
const repo_link = "https://github.com/koeqaife/hyprland-material-you";
const current_de = GLib.getenv("DESKTOP_SESSION");
const author = "koeqaife";
const Row = (
title: StringOrBinding,
description: StringOrBinding,
@@ -42,15 +46,12 @@ const Row = (
})
});
const repo_link = "https://github.com/S4NKALP/hyprland";
const current_de = GLib.getenv("DESKTOP_SESSION");
export function Info() {
const box = Widget.Box({
vertical: true,
children: [
Row("Dotfiles", "hyprland"),
Row("Author", "S4NKALP (Discord)"),
Row("Dotfiles", "Material You"),
Row("Author", author),
Row("Repo", repo_link, () => {
Utils.execAsync(`xdg-open "${repo_link}"`).catch(print);
}),
+1 -1
View File
@@ -8,9 +8,9 @@ import { Apps } from "./apps";
import { MaterialIcon } from "icons";
import { Weather } from "./weather";
import { current_tab, current_window, set_current_window } from "./variables";
const hyprland = await Service.import("hyprland");
import Gtk from "gi://Gtk?version=3.0";
const hyprland = await Service.import("hyprland");
globalThis.OpenSettings = OpenSettings;
export async function OpenSettings(cur_tab: string = "network") {
+4 -5
View File
@@ -25,7 +25,7 @@ type AccessPoint = {
Utils.interval(1500, () => {
if (current_tab.value != "network" || !current_window?.visible) return;
WifiScan();
wifi_scan();
});
const network_state = {
@@ -42,13 +42,12 @@ const network_state = {
failed: "Connection failed"
};
function WifiScan() {
function wifi_scan() {
try {
network.wifi?.scan();
} catch (error) {
print(error);
}
// await Utils.execAsync("nmcli device wifi rescan").catch(print)
}
const WifiNetwork = (access_point: AccessPoint) => {
@@ -178,7 +177,7 @@ function WifiList() {
});
}
const nm_applet_required = () =>
const NmAppletRequired = () =>
Widget.Box({
class_name: "error_container",
visible: false,
@@ -200,7 +199,7 @@ const nm_applet_required = () =>
export function Network() {
const box = Widget.Box({
vertical: true,
children: [nm_applet_required(), WifiToggle(), WifiList()]
children: [NmAppletRequired(), WifiToggle(), WifiList()]
});
return Widget.Scrollable({
hscroll: "never",
+52 -55
View File
@@ -72,7 +72,7 @@ const Wallpaper = (image: string, name: string) =>
vpack: "center",
class_name: "image",
setup(self) {
const cache_file = `${GLib.get_home_dir()}/.cache/thumbnails/wallpaper/${name}`;
const cache_file = `${GLib.get_home_dir()}/.cache/ags/thumbnails/wallpaper/${name}`;
Utils.readFileAsync(cache_file).catch(() => {
Utils.execAsync(
`magick ${image} -resize x32 -gravity Center -extent 1:1 ${cache_file}`
@@ -106,13 +106,13 @@ const Wallpaper = (image: string, name: string) =>
});
function CacheThumbnails() {
Utils.execAsync(`mkdir -p ${GLib.get_home_dir()}/.cache/thumbnails/wallpaper`).catch(print);
Utils.execAsync(`mkdir -p ${GLib.get_home_dir()}/.cache/ags/thumbnails/wallpaper`).catch(print);
const original_directory = `${GLib.get_home_dir()}/Pictures/wallpapers`;
const extensions = [".jpg", ".jpeg", ".png"];
const fileList = listFilesByExtensions(original_directory, extensions);
fileList.forEach((value, index) => {
const path = `${original_directory}/${value}`;
const cache_file = `${GLib.get_home_dir()}/.cache/thumbnails/wallpaper/${value}`;
const cache_file = `${GLib.get_home_dir()}/.cache/ags/thumbnails/wallpaper/${value}`;
Utils.idle(() => {
Utils.readFileAsync(cache_file).catch(() => {
Utils.execAsync(`magick ${path} -resize x32 -gravity Center -extent 1:1 ${cache_file}`).catch(print);
@@ -163,6 +163,54 @@ export function Wallpapers() {
vertical: true,
children: [WallpaperList()]
});
const actions = Widget.Box({
class_name: "actions",
hpack: "end",
children: [
Widget.Button({
class_name: "standard_button",
label: "Random",
hpack: "end",
on_clicked: () => {
if (!changing.value) {
changing.setValue(true);
Utils.execAsync(`python -O ${GLib.get_home_dir()}/dotfiles/hypr/scripts/wallpaper.py -R`)
.catch(print)
.finally(() => {
changing.setValue(false);
});
}
},
setup: (self) => {
self.hook(changing, () => {
self.toggleClassName("disabled", changing.value);
});
}
}),
Widget.Button({
class_name: "filled_button",
label: "Select",
hpack: "end",
on_clicked: () => {
if (!changing.value) {
changing.setValue(true);
Utils.execAsync(
`python -O ${GLib.get_home_dir()}/dotfiles/hypr/scripts/wallpaper.py -I ${focused.value}`
)
.catch(print)
.finally(() => {
changing.setValue(false);
});
}
},
setup: (self) => {
self.hook(changing, () => {
self.toggleClassName("disabled", changing.value);
});
}
})
]
});
return Widget.Box({
vertical: true,
children: [
@@ -185,58 +233,7 @@ export function Wallpapers() {
})
]
}),
Widget.Box({
class_name: "actions",
hpack: "end",
children: [
Widget.Button({
class_name: "standard_button",
label: "Random",
hpack: "end",
on_clicked: () => {
if (!changing.value) {
changing.setValue(true);
Utils.execAsync(
`python -O ${GLib.get_home_dir()}/dotfiles/hypr/scripts/wallpaper.py -R`
)
.catch(print)
.finally(() => {
changing.setValue(false);
});
}
},
setup: (self) => {
self.hook(changing, () => {
self.toggleClassName("disabled", changing.value);
});
}
}),
Widget.Button({
class_name: "filled_button",
label: "Select",
hpack: "end",
on_clicked: () => {
if (!changing.value) {
changing.setValue(true);
Utils.execAsync(
`python -O ${GLib.get_home_dir()}/dotfiles/hypr/scripts/wallpaper.py -I ${
focused.value
}`
)
.catch(print)
.finally(() => {
changing.setValue(false);
});
}
},
setup: (self) => {
self.hook(changing, () => {
self.toggleClassName("disabled", changing.value);
});
}
})
]
})
actions
]
})
]
+12 -8
View File
@@ -47,30 +47,34 @@ App.config({
onConfigParsed: function () {}
});
function ReloadCSS() {
function reload_css() {
App.resetCss();
App.applyCss(`${GLib.get_home_dir()}/.config/gtk-3.0/gtk.css`);
App.applyCss(`${App.configDir}/style.css`);
App.applyCss(`${App.configDir}/style-apps.css`);
}
function ReloadColors() {
function reload_colors() {
App.applyCss(`${GLib.get_home_dir()}/.cache/material/colors.css`);
}
Utils.monitorFile(`${GLib.get_home_dir()}/.cache/material/colors.css`, ReloadCSS);
Utils.monitorFile(`${GLib.get_home_dir()}/.cache/material/colors.css`, reload_css);
forMonitorsAsync(Bar);
ReloadCSS();
reload_css();
function enableAnimations(bool: boolean) {
function enable_animations(bool: boolean) {
const settings = Gtk.Settings.get_default()!;
settings.gtk_enable_animations = bool;
}
globalThis.ReloadCSS = ReloadCSS;
globalThis.ReloadColors = ReloadColors;
globalThis.enableAnimations = enableAnimations;
globalThis.ReloadCSS = reload_css;
globalThis.ReloadColors = reload_colors;
globalThis.enableAnimations = enable_animations;
globalThis.reload_css = reload_css;
globalThis.reload_colors = reload_colors;
globalThis.enable_animations = enable_animations;
start_battery_warning_service();
+14 -14
View File
@@ -31,7 +31,7 @@ const off_icons = {
headset_mic: "headset_off",
speaker: "volume_off"
};
const button_with_icon = (
const IconButton = (
icon: string,
size: string,
stream: Stream,
@@ -50,7 +50,7 @@ const button_with_icon = (
on_clicked: on_clicked
});
const create_slider = (stream: Stream) =>
const Slider = (stream: Stream) =>
Widget.Slider({
min: 0,
max: 100,
@@ -71,7 +71,7 @@ const create_slider = (stream: Stream) =>
}
});
const speaker = (stream: Stream, icons: [number, string][], off: string) =>
const Speaker = (stream: Stream, icons: [number, string][], off: string) =>
Widget.Box({
class_name: "device",
vertical: true,
@@ -95,7 +95,7 @@ const speaker = (stream: Stream, icons: [number, string][], off: string) =>
}),
Widget.Box({
children: [
button_with_icon(
IconButton(
off,
"20px",
stream,
@@ -105,7 +105,7 @@ const speaker = (stream: Stream, icons: [number, string][], off: string) =>
icons,
off
),
create_slider(stream)
Slider(stream)
]
})
]
@@ -143,14 +143,14 @@ const app = (stream: Stream) => {
stream.is_muted = !stream.is_muted;
}
}),
create_slider(stream)
Slider(stream)
]
})
]
});
};
const tab = (icon: string, on_clicked: (any) => void, page?: string) =>
const Tab = (icon: string, on_clicked: (any) => void, page?: string) =>
Widget.Overlay({
child: Widget.Button({
hexpand: true,
@@ -162,13 +162,13 @@ const tab = (icon: string, on_clicked: (any) => void, page?: string) =>
overlays: [MaterialIcon(icon, "22px")]
});
const audio_widget = () => {
const Audio = () => {
const cur_page = Variable("speakers");
const tabs = Widget.Box({
class_name: "tabs",
children: [
tab("volume_up", () => cur_page.setValue("speakers"), "speakers"),
tab("apps", () => cur_page.setValue("apps"), "apps")
Tab("volume_up", () => cur_page.setValue("speakers"), "speakers"),
Tab("apps", () => cur_page.setValue("apps"), "apps")
],
setup: (self) => {
self.hook(cur_page, () => {
@@ -178,7 +178,7 @@ const audio_widget = () => {
});
}
});
const speakers = Widget.Box({ vertical: true, children: [] as ReturnType<typeof speaker>[] });
const speakers = Widget.Box({ vertical: true, children: [] as ReturnType<typeof Speaker>[] });
const apps = Widget.Box({ vertical: true, children: [] as ReturnType<typeof app>[] });
function update() {
@@ -200,7 +200,7 @@ const audio_widget = () => {
audio.speakers.forEach((s) => {
if (!speakers.children.some((v) => v.attribute.stream.id == s.id)) {
speakers.pack_start(speaker(s, icons.speaker, off_icons.speaker), false, false, 0);
speakers.pack_start(Speaker(s, icons.speaker, off_icons.speaker), false, false, 0);
}
});
@@ -210,7 +210,7 @@ const audio_widget = () => {
s.icon_name == "audio-headset-analog-usb"
? { off: off_icons.headset_mic, default: icons.headset_mic }
: { off: off_icons.microphone, default: icons.microphone };
speakers.pack_start(speaker(s, _icons.default, _icons.off), false, false, 0);
speakers.pack_start(Speaker(s, _icons.default, _icons.off), false, false, 0);
}
});
@@ -257,6 +257,6 @@ export const audio_popup = popupwindow({
class_name: "audio",
visible: false,
keymode: "exclusive",
child: audio_widget(),
child: Audio(),
anchor: ["top", "right", "bottom"]
});
+19 -18
View File
@@ -3,23 +3,24 @@ const battery = await Service.import("battery");
const systemtray = await Service.import("systemtray");
const audio = await Service.import("audio");
const network = await Service.import("network");
const bluetooth = await Service.import("bluetooth");
const mpris = await Service.import("mpris");
const { GLib, Gio } = imports.gi;
const decoder = new TextDecoder();
import { OpenSettings } from "apps/settings/main.ts";
import { enableClickThrough } from "./misc/clickthrough.js";
import { enable_click_through } from "./misc/clickthrough.js";
import { RoundedCorner } from "./misc/cairo_roundedcorner.js";
import { Client, Workspace } from "types/service/hyprland.js";
import { Client } from "types/service/hyprland.js";
import Button from "types/widgets/button.js";
import Icon from "types/widgets/icon.js";
import { FileEnumerator, FileInfo } from "types/@girs/gio-2.0/gio-2.0.cjs";
const mpris = await Service.import("mpris");
const bluetooth = await Service.import("bluetooth");
import Gtk from "gi://Gtk?version=3.0";
import { MaterialIcon } from "icons.js";
import config from "services/configuration.ts";
import { toggleAppsWindow, toggleMediaWindow } from "./sideleft/main.js";
import { Variable as VariableType } from "types/variable";
import Gtk from "gi://Gtk?version=3.0";
const keyboard_layout = Variable("none");
hyprland.connect("keyboard-layout", (hyprland, keyboardname, layoutname) => {
keyboard_layout.setValue(layoutname.trim().toLowerCase().substr(0, 2));
@@ -99,8 +100,8 @@ function getIconNameFromClass(windowClass: string) {
const dispatch = (ws: string) => hyprland.messageAsync(`dispatch workspace ${ws}`).catch(print);
function Workspaces() {
let workspaceButtons = new Map<Number, any>();
const workspaceButtonsArray: VariableType<Button<any, any>[] | any> = Variable([]);
let workspace_buttons = new Map<Number, any>();
const workspace_buttons_array: VariableType<Button<any, any>[] | any> = Variable([]);
function createWorkspaceButton(id: Number) {
return Widget.Button({
@@ -113,20 +114,20 @@ function Workspaces() {
function initializeWorkspaceButtons() {
for (let i = 1; i <= 10; i++) {
workspaceButtons.set(i, createWorkspaceButton(i));
workspace_buttons.set(i, createWorkspaceButton(i));
}
workspaceButtonsArray.setValue(Array.from(workspaceButtons.values()));
workspace_buttons_array.setValue(Array.from(workspace_buttons.values()));
}
function update() {
workspaceButtons.forEach((workspace) => {
workspace_buttons.forEach((workspace) => {
const existingWorkspace = hyprland.workspaces.some((element) => element.id === workspace.attribute.id);
workspace.toggleClassName("exists", existingWorkspace);
});
}
function activeWorkspace() {
workspaceButtons.forEach((workspace, key) => {
workspace_buttons.forEach((workspace, key) => {
workspace.toggleClassName("active", workspace.attribute.id == hyprland.active.workspace.id);
});
}
@@ -143,11 +144,11 @@ function Workspaces() {
});
return Widget.EventBox({
onScrollUp: () => dispatch("+1"),
onScrollDown: () => dispatch("-1"),
on_scroll_up: () => dispatch("+1"),
on_scroll_down: () => dispatch("-1"),
hpack: "center",
child: Widget.Box({
children: workspaceButtonsArray.bind(),
children: workspace_buttons_array.bind(),
class_name: "workspaces"
})
});
@@ -455,8 +456,8 @@ function TaskBar() {
function volumeIndicator() {
return Widget.EventBox({
onScrollUp: () => (audio.speaker.volume += 0.01),
onScrollDown: () => (audio.speaker.volume -= 0.01),
on_scroll_up: () => (audio.speaker.volume += 0.01),
on_scroll_down: () => (audio.speaker.volume -= 0.01),
class_name: "volume_box",
child: Widget.Button({
on_primary_click_release: () => App.toggleWindow("audio"),
@@ -549,7 +550,7 @@ export const BarCornerTopLeft = (monitor = 0) =>
exclusivity: "normal",
visible: true,
child: RoundedCorner("top_left", { className: "corner" }),
setup: enableClickThrough
setup: enable_click_through
});
export const BarCornerTopRight = (monitor = 0) =>
@@ -562,5 +563,5 @@ export const BarCornerTopRight = (monitor = 0) =>
exclusivity: "normal",
visible: true,
child: RoundedCorner("top_right", { className: "corner" }),
setup: enableClickThrough
setup: enable_click_through
});
+4 -2
View File
@@ -180,6 +180,7 @@ function ClipHistWidget({ width = 500, height = 500, spacing = 12 }) {
hexpand: true,
class_name: "cliphistory_entry",
placeholder_text: "Search",
vpack: "center",
on_change: ({ text }) => {
const searchText = (text ?? "").toLowerCase();
@@ -191,7 +192,8 @@ function ClipHistWidget({ width = 500, height = 500, spacing = 12 }) {
const clearButton = Widget.Button({
child: MaterialIcon("delete_forever"),
class_name: "clear_button",
class_name: "filled_tonal_button clear_button",
vpack: "center",
on_clicked: () => {
Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --clear`)
.then(() => {
@@ -248,4 +250,4 @@ export const cliphist = popupwindow({
spacing: 0
}),
anchor: ["top", "right"]
});
});
+1 -1
View File
@@ -1,4 +1,4 @@
import Cairo from "gi://cairo?version=1.0";
export const dummyRegion = new Cairo.Region();
export const enableClickThrough = (self) => self.input_shape_combine_region(dummyRegion);
export const enable_click_through = (self) => self.input_shape_combine_region(dummyRegion);
+6 -6
View File
@@ -8,7 +8,7 @@ import Slider from "types/widgets/slider";
import { Binding } from "types/service";
import { audio_popup } from "./audio";
const brightnessIcons = [
const brightness_icons = [
"brightness_1",
"brightness_2",
"brightness_3",
@@ -18,8 +18,8 @@ const brightnessIcons = [
"brightness_7"
];
function getBrightnessIcon(brightness: number): string {
const totalIcons = brightnessIcons.length;
function get_brightness_icon(brightness: number): string {
const totalIcons = brightness_icons.length;
const maxBrightness = 1;
const ratio = 1.6;
@@ -31,11 +31,11 @@ function getBrightnessIcon(brightness: number): string {
for (let i = 0; i < totalIcons; i++) {
if (brightness < thresholds[i]) {
return brightnessIcons[i];
return brightness_icons[i];
}
}
return brightnessIcons[totalIcons - 1];
return brightness_icons[totalIcons - 1];
}
type popup_on_change = ((self: Slider<any>) => void) | undefined;
@@ -93,7 +93,7 @@ const default_popup = (
const backlight_popup = () =>
default_popup(
MaterialIcon("brightness_1").hook(backlight_service, (self) => {
self.label = getBrightnessIcon(backlight_service.screen_value);
self.label = get_brightness_icon(backlight_service.screen_value);
}),
backlight_service.bind("screen_value").as((n) => n * 100),
(self) => {
+8 -8
View File
@@ -4,15 +4,15 @@ const decoder = new TextDecoder();
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
import Box from "types/widgets/box";
import { Application } from "types/service/applications";
import Gtk from "gi://Gtk?version=3.0";
import { Application } from "types/service/applications";
import { WINDOW_NAME } from "modules/sideleft/main";
const LAUNCH_COUNT_FILE = Gio.File.new_for_path(
GLib.build_filenamev([GLib.get_home_dir(), ".cache", "launch_counts.json"])
);
function readLaunchCounts() {
function read_launch_counts() {
try {
if (!LAUNCH_COUNT_FILE.query_exists(null)) {
return {};
@@ -24,7 +24,7 @@ function readLaunchCounts() {
}
}
function writeLaunchCounts(launchCounts: number) {
function write_launch_counts(launchCounts: number) {
const data = JSON.stringify(launchCounts, null, 2);
LAUNCH_COUNT_FILE.replace_contents(
encoder.encode(data),
@@ -35,14 +35,14 @@ function writeLaunchCounts(launchCounts: number) {
);
}
function incrementLaunchCount(appName: string) {
const launchCounts = readLaunchCounts();
function increment_launch_count(appName: string) {
const launchCounts = read_launch_counts();
launchCounts[appName] = (launchCounts[appName] || 0) + 1;
writeLaunchCounts(launchCounts);
write_launch_counts(launchCounts);
}
function sortApplicationsByLaunchCount(applications: Box<any, any>[]) {
const launchCounts = readLaunchCounts();
const launchCounts = read_launch_counts();
return applications.sort((a: Box<any, any>, b: Box<any, any>) => {
const countA = launchCounts[a.attribute.app.name] || 0;
const countB = launchCounts[b.attribute.app.name] || 0;
@@ -76,7 +76,7 @@ function AppItem(app: Application): Box<any, any> {
button.connect("clicked", () => {
clickCount++;
if (clickCount === 2) {
incrementLaunchCount(app.name);
increment_launch_count(app.name);
App.closeWindow(WINDOW_NAME);
app.launch();
clickCount = 0;
+2 -2
View File
@@ -4,7 +4,7 @@ import { MaterialIcon } from "icons.ts";
import { ChatMessage, SystemMessage } from "modules/misc/chat_message.ts";
import { markdownTest } from "modules/misc/md2pango.ts";
import Gdk from "gi://Gdk";
import { enableClickThrough } from "../misc/clickthrough.js";
import { enable_click_through } from "../misc/clickthrough.js";
import { TextView } from "modules/misc/textview.js";
function apiSendMessage(textView: any) {
@@ -93,7 +93,7 @@ const chatPlaceholderRevealer = Widget.Revealer({
transition: "crossfade",
transitionDuration: 200,
child: chatPlaceholder,
setup: enableClickThrough
setup: enable_click_through
});
const chatSendButton = Widget.Button({
+3 -3
View File
@@ -11,7 +11,7 @@ const PAUSE_ICON = "pause";
const PREV_ICON = "skip_previous";
const NEXT_ICON = "skip_next";
function lengthStr(length: number): string {
function length_str(length: number): string {
const min = Math.floor(length / 60);
const sec = Math.floor(length % 60);
const sec0 = sec < 10 ? "0" : "";
@@ -68,7 +68,7 @@ function Player(player: MprisPlayer) {
hpack: "start",
setup: (self) => {
const update = (self: Label<any>) => {
self.label = lengthStr(player.position);
self.label = length_str(player.position);
self.visible = player.length > 0;
};
@@ -81,7 +81,7 @@ function Player(player: MprisPlayer) {
class_name: "length",
hpack: "end",
visible: player.bind("length").transform((l) => l > 0),
label: player.bind("length").transform(lengthStr)
label: player.bind("length").transform(length_str)
});
const icon = Widget.Icon({
+17 -17
View File
@@ -8,7 +8,7 @@ import { MaterialIcon } from "icons.ts";
import Gtk from "gi://Gtk?version=3.0";
const currentPage = Variable(0);
const current_page = Variable(0);
function WifiIndicator() {
const ssid = Widget.Label({
@@ -207,7 +207,7 @@ function Page1() {
label: "Idle inhibitor",
icon: "schedule"
}),
onClicked: () => {
on_clicked: () => {
idle_inhibitor.setValue(!idle_inhibitor.value);
if (idle_inhibitor.value)
Utils.execAsync([
@@ -231,7 +231,7 @@ function Page1() {
label: "Night Light",
icon: "nightlight"
}),
onClicked: () => {
on_clicked: () => {
night_light.setValue(!night_light.value);
Utils.execAsync(`${App.configDir}/scripts/night-light.sh --toggle`)
.then((out) => {
@@ -298,15 +298,15 @@ function Page2() {
});
}
const createDotButton = (index: number) =>
const DotButton = (index: number) =>
Widget.Button({
label: "●",
onClicked: () => currentPage.setValue(index),
on_clicked: () => current_page.setValue(index),
class_name: "dotbutton",
hexpand: false,
setup: (self) => {
self.hook(currentPage, () => {
self.toggleClassName("active", currentPage.value == index);
self.hook(current_page, () => {
self.toggleClassName("active", current_page.value == index);
});
}
});
@@ -316,35 +316,35 @@ export function Management() {
page1: Page1(),
page2: Page2()
};
const numberOfPages = Object.keys(pages).length;
const pageNames = Array.from({ length: numberOfPages }, (_, i) => `page${i + 1}`);
const number_of_pages = Object.keys(pages).length;
const page_names = Array.from({ length: number_of_pages }, (_, i) => `page${i + 1}`);
const stack = Widget.Stack({
children: pages,
// @ts-expect-error
shown: currentPage.bind().as((v) => `page${v + 1}`),
shown: current_page.bind().as((v) => `page${v + 1}`),
transition: "slide_left_right",
transitionDuration: 200
transition_duration: 200
});
const dotButtons = pageNames.map((_, index) => createDotButton(index));
const dot_buttons = page_names.map((_, index) => DotButton(index));
return Widget.EventBox({
onScrollUp: () => currentPage.setValue(Math.min(currentPage.value + 1, numberOfPages - 1)),
onScrollDown: () => currentPage.setValue(Math.max(currentPage.value - 1, 0)),
on_scroll_up: () => current_page.setValue(Math.min(current_page.value + 1, number_of_pages - 1)),
on_scroll_down: () => current_page.setValue(Math.max(current_page.value - 1, 0)),
child: Widget.Box({
orientation: Gtk.Orientation.VERTICAL,
children: [
stack,
Widget.Box({
children: dotButtons,
children: dot_buttons,
class_name: "dotbuttons_box",
hpack: "center"
})
],
setup: (self) => {
for (let page in pageNames) {
for (let page in page_names) {
// @ts-expect-error
self.keybind(`${Number(page.replace("page", "")) + 1}`, () => {
currentPage.setValue(Number(page.replace("page", "")));
current_page.setValue(Number(page.replace("page", "")));
});
}
}
+2 -2
View File
@@ -9,7 +9,7 @@ copy_by_id() {
cliphist decode $id | wl-copy
}
clear(){
clear() {
cliphist wipe
}
@@ -40,4 +40,4 @@ elif [[ "$1" == "--clear-cache" ]]; then
clear_tmp
elif [[ "$1" == "--clear" ]]; then
clear
fi
fi
+96 -108
View File
@@ -270,114 +270,6 @@ window.notification-popups box.notifications {
font-weight: 300;
}
/* -----------------------------------------------------
* Clipboard history
* ----------------------------------------------------- */
.cliphistory_box {
border-radius: 20px;
background-color: @background;
border: 1px solid;
border-color: @outlineVariant;
}
.cliphistory_box separator {
margin: 0px;
}
.cliphistory_entry {
background-color: @surfaceContainerHigh;
color: @onSurface;
border: none;
outline: none;
border-radius: 100px;
margin-bottom: 16px;
padding: 5px;
padding-left: 25px;
margin: 11px;
}
.clip_container {
border: none;
outline: none;
border-radius: 0px;
min-height: 40px;
}
.clip_container label {
margin-left: 11px;
margin-right: 11px;
}
.clip_container:hover {
background-color: mix(@onSurface, @surface, 0.92);
}
.clip_container:focus {
background-color: mix(@onSurface, @surface, 0.8);
border: 0px solid;
border: none;
outline: none;
}
.clip_container:active {
background-image: radial-gradient(circle, mix(@onSurface, @surface, 0.78) 10%, transparent 0%);
}
.clip_container .clip_id {
font-weight: 200;
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;
min-width: 0px;
margin: 0px;
color: @outlineVariant;
}
.clip_divider {
color: @outline;
margin: 0px;
}
.clip_label {
color: @onSurface;
font-weight: normal;
}
.clip_container.with_image .clip_label {
color: @tertiary;
}
.clear_button {
background-color: @surfaceContainerHigh;
color: @onSurface;
border: none;
outline: none;
border-radius: 50%;
margin-right: 5px;
margin-left: 5px;
margin-top: 11px;
margin-bottom: 11px;
}
.clear_button:hover {
background-color: mix(@onSurface, @surface, 0.92);
}
.clear_button:active {
background-color: mix(@onSurface, @surface, 0.8);
}
/* -----------------------------------------------------
* Misc
* ----------------------------------------------------- */
@@ -1775,6 +1667,102 @@ switch:checked:active slider {
color: @foreground;
}
/* -----------------------------------------------------
* Clipboard history
* ----------------------------------------------------- */
.cliphistory_box {
border-radius: 20px;
background-color: @background;
border: 1px solid;
border-color: @outlineVariant;
}
.cliphistory_box separator {
margin: 0px;
}
.cliphistory_entry {
background-color: @surfaceContainerHigh;
color: @onSurface;
border: none;
outline: none;
border-radius: 100px;
margin-bottom: 16px;
padding-left: 25px;
margin: 11px;
min-height: 44px;
}
.clip_container {
border: none;
outline: none;
border-radius: 0px;
min-height: 40px;
}
.clip_container label {
margin-left: 11px;
margin-right: 11px;
}
.clip_container:hover {
background-color: mix(@onSurface, @surface, 0.92);
}
.clip_container:focus {
background-color: mix(@onSurface, @surface, 0.8);
border: 0px solid;
border: none;
outline: none;
}
.clip_container:active {
background-image: radial-gradient(circle, mix(@onSurface, @surface, 0.78) 10%, transparent 0%);
}
.clip_container .clip_id {
font-weight: 200;
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;
min-width: 0px;
margin: 0px;
color: @outlineVariant;
}
.clip_divider {
color: @outline;
margin: 0px;
}
.clip_label {
color: @onSurface;
font-weight: normal;
}
.clip_container.with_image .clip_label {
color: @tertiary;
}
.clear_button {
margin: 11px;
margin-left: 0px;
min-width: 44px;
min-height: 44px;
border-radius: 100%
}
/* -----------------------------------------------------
* Material
* ----------------------------------------------------- */
+4 -3
View File
@@ -90,7 +90,7 @@ export const current_os = await Utils.execAsync(`${App.configDir}/scripts/system
export const settings_file = `${GLib.get_home_dir()}/dotfiles/.settings/settings.json`;
export const wallpaper_cache_file = `${GLib.get_home_dir()}/.cache/current_wallpaper`;
function readSettingsFile() {
function read_settings() {
Utils.readFileAsync(settings_file)
.then((out) => {
const settings = JSON.parse(out);
@@ -108,9 +108,10 @@ function readSettingsFile() {
Utils.writeFileSync(current_wallpaper.value, wallpaper_cache_file);
});
}
readSettingsFile();
read_settings();
Utils.monitorFile(settings_file, read_settings);
Utils.monitorFile(settings_file, readSettingsFile);
Utils.monitorFile(wallpaper_cache_file, () => {
Utils.readFileAsync(wallpaper_cache_file)
.then((out) => {