diff --git a/config/ags/assets/mixer-symbolic.svg b/config/ags/assets/mixer-symbolic.svg new file mode 100644 index 00000000..ad6cfa85 --- /dev/null +++ b/config/ags/assets/mixer-symbolic.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/config/ags/colors.json b/config/ags/colors.json new file mode 100644 index 00000000..ad03dcbc --- /dev/null +++ b/config/ags/colors.json @@ -0,0 +1,106 @@ +{ + "colors": { + "dark": { + "background": "#111318", + "error": "#ffb4ab", + "error_container": "#93000a", + "inverse_on_surface": "#2e3035", + "inverse_primary": "#3f5f90", + "inverse_surface": "#e1e2e9", + "on_background": "#e1e2e9", + "on_error": "#690005", + "on_error_container": "#ffdad6", + "on_primary": "#06305f", + "on_primary_container": "#d5e3ff", + "on_primary_fixed": "#001b3c", + "on_primary_fixed_variant": "#254777", + "on_secondary": "#273141", + "on_secondary_container": "#d9e3f8", + "on_secondary_fixed": "#121c2b", + "on_secondary_fixed_variant": "#3e4758", + "on_surface": "#e1e2e9", + "on_surface_variant": "#c4c6cf", + "on_tertiary": "#3e2845", + "on_tertiary_container": "#f8d8fe", + "on_tertiary_fixed": "#28132f", + "on_tertiary_fixed_variant": "#563e5d", + "outline": "#8e9099", + "outline_variant": "#43474e", + "primary": "#a8c8ff", + "primary_container": "#254777", + "primary_fixed": "#d5e3ff", + "primary_fixed_dim": "#a8c8ff", + "scrim": "#000000", + "secondary": "#bdc7dc", + "secondary_container": "#bdc7dc", + "secondary_fixed": "#d9e3f8", + "secondary_fixed_dim": "#bdc7dc", + "shadow": "#000000", + "surface": "#111318", + "surface_bright": "#37393e", + "surface_container": "#1d2024", + "surface_container_high": "#282a2f", + "surface_container_highest": "#33353a", + "surface_container_low": "#191c20", + "surface_container_lowest": "#0c0e13", + "surface_dim": "#111318", + "surface_variant": "#43474e", + "tertiary": "#dbbce1", + "tertiary_container": "#563e5d", + "tertiary_fixed": "#f8d8fe", + "tertiary_fixed_dim": "#dbbce1" + }, + "light": { + "background": "#f9f9ff", + "error": "#ba1a1a", + "error_container": "#ffdad6", + "inverse_on_surface": "#f0f0f7", + "inverse_primary": "#a8c8ff", + "inverse_surface": "#2e3035", + "on_background": "#191c20", + "on_error": "#ffffff", + "on_error_container": "#410002", + "on_primary": "#ffffff", + "on_primary_container": "#001b3c", + "on_primary_fixed": "#001b3c", + "on_primary_fixed_variant": "#254777", + "on_secondary": "#ffffff", + "on_secondary_container": "#121c2b", + "on_secondary_fixed": "#121c2b", + "on_secondary_fixed_variant": "#3e4758", + "on_surface": "#191c20", + "on_surface_variant": "#43474e", + "on_tertiary": "#ffffff", + "on_tertiary_container": "#28132f", + "on_tertiary_fixed": "#28132f", + "on_tertiary_fixed_variant": "#563e5d", + "outline": "#74777f", + "outline_variant": "#c4c6cf", + "primary": "#3f5f90", + "primary_container": "#d5e3ff", + "primary_fixed": "#d5e3ff", + "primary_fixed_dim": "#a8c8ff", + "scrim": "#000000", + "secondary": "#555f71", + "secondary_container": "#555f71", + "secondary_fixed": "#d9e3f8", + "secondary_fixed_dim": "#bdc7dc", + "shadow": "#000000", + "source_color": "#22518e", + "surface": "#f9f9ff", + "surface_bright": "#f9f9ff", + "surface_container": "#ededf4", + "surface_container_high": "#e7e8ee", + "surface_container_highest": "#e1e2e9", + "surface_container_low": "#f3f3fa", + "surface_container_lowest": "#ffffff", + "surface_dim": "#d9d9e0", + "surface_variant": "#e0e2ec", + "tertiary": "#6f5675", + "tertiary_container": "#f8d8fe", + "tertiary_fixed": "#f8d8fe", + "tertiary_fixed_dim": "#dbbce1" + } + }, + "harmonized_colors": {} +} \ No newline at end of file diff --git a/config/ags/config.js b/config/ags/config.js index 278bf351..227daaf2 100644 --- a/config/ags/config.js +++ b/config/ags/config.js @@ -1,31 +1,7 @@ -"use strict"; -import GLib from 'gi://GLib'; -import App from 'resource:///com/github/Aylur/ags/app.js' -import userOptions from './modules/.configuration/user_options.js'; -import Overview from './modules/overview/main.js'; +import onConfigParsed from "./init.js"; +import windows from "./windows.js"; -const COMPILED_STYLE_DIR = `${GLib.get_user_config_dir()}/ags/user/` - -async function applyStyle() { - - App.resetCss(); - App.applyCss(`${COMPILED_STYLE_DIR}/style.css`); - console.log('[LOG] Styles loaded') -} -applyStyle().catch(print); - -const Windows = () => [ - Overview() -]; -const CLOSE_ANIM_TIME = 210; App.config({ - css: `${COMPILED_STYLE_DIR}/style.css`, - stackTraceOnError: true, - closeWindowDelay: { - 'sideright': CLOSE_ANIM_TIME, - 'sideleft': CLOSE_ANIM_TIME, - 'osk': CLOSE_ANIM_TIME, - }, - windows: Windows().flat(1), + windows: windows, + onConfigParsed: onConfigParsed, }); - diff --git a/config/ags/config.json b/config/ags/config.json new file mode 100644 index 00000000..6df5f795 --- /dev/null +++ b/config/ags/config.json @@ -0,0 +1,51 @@ +{ + "wallpaper": { + "folder": "{{home}}/Pictures/wallpapers", + "current": "wall-16.png" + }, + "theme": { + "dark_mode": true, + "border_radius": "6", + "window": { + "margin": "12", + "border": false, + "opacity": 0.6 + }, + "bar": { + "position": "bottom", + "opacity": 0, + "shadow": false, + "border": false, + "button_opacity": 0.6, + "button_padding": "4, 8", + "button_spacing": 4, + "button_shadow": false, + "button_border_radius": "6", + "margin": "3", + "padding": "3", + "border_radius": "0", + "launcher_icon": "󰢚", + "workspace_active_width": "20" + } + }, + "osd": { + "regular": { + "position": "bottom", + "vertical": true, + "margin": "0, 12, 60, 0", + "capslock": true, + "mic": true + }, + "progress": { + "position": "bottom", + "vertical": false, + "margin": "12, 12, 2, 12", + "brightness": true, + "volume": true + } + }, + "system_monitor": { + "position": "bottom left", + "margin": "12, 12, 12, 12" + } +} diff --git a/config/ags/functions/globals.js b/config/ags/functions/globals.js new file mode 100644 index 00000000..538b9260 --- /dev/null +++ b/config/ags/functions/globals.js @@ -0,0 +1,19 @@ +import recorder from "../services/screen_record.js"; +import brightness from "../services/brightness.js"; +import { capsLockState, configs } from "../vars.js"; +import GLib from "gi://GLib"; + +export default function globals() { + globalThis.TMP = GLib.get_tmp_dir() + "/ags"; + Utils.ensureDirectory(TMP); + globalThis.recorder = recorder; + globalThis.brightness = brightness; + globalThis.update_capslock = () => { + Utils.exec(`brightnessctl -d input3::capslock g`, (stdout) => { + capsLockState.setValue(stdout); + }); + }; + globalThis.moveBar = (pos) => { + configs.theme.bar.position.updateValue(pos); + }; +} diff --git a/config/ags/functions/hyprland/init.js b/config/ags/functions/hyprland/init.js new file mode 100644 index 00000000..a3bed8fa --- /dev/null +++ b/config/ags/functions/hyprland/init.js @@ -0,0 +1,7 @@ +import windowAnimation from "./window_animation.js"; +import windowBlur from "./window_blur.js"; + +export default function initHyprland() { + windowAnimation(); + windowBlur(); +} diff --git a/config/ags/functions/hyprland/window_animation.js b/config/ags/functions/hyprland/window_animation.js new file mode 100644 index 00000000..1d93ccc0 --- /dev/null +++ b/config/ags/functions/hyprland/window_animation.js @@ -0,0 +1,13 @@ +import { sendBatch } from "../utils.js"; +import { configs } from "../../vars.js"; + +export default function windowAnimation() { + sendBatch( + App.windows + .filter((win) => !!win.animation) + .map( + (win) => + `layerrule animation ${win.animation === "slide top" ? `slide ${configs.theme.bar.position.value}` : win.animation}, ${win.name}`, + ), + ); +} diff --git a/config/ags/functions/hyprland/window_blur.js b/config/ags/functions/hyprland/window_blur.js new file mode 100644 index 00000000..3a3ec05b --- /dev/null +++ b/config/ags/functions/hyprland/window_blur.js @@ -0,0 +1,14 @@ +import { sendBatch } from "../utils.js"; + +export default function windowBlur() { + const noIgnorealpha = ["verification__window", "powermenu__window"]; + + sendBatch( + App.windows.flatMap(({ name }) => [ + `layerrule blur, ${name}`, + noIgnorealpha.some((skip) => name?.includes(skip)) + ? "" + : `layerrule ignorealpha 0.3, ${name}`, + ]), + ); +} diff --git a/config/ags/functions/monitor_configuration.js b/config/ags/functions/monitor_configuration.js new file mode 100644 index 00000000..6e7b2b8e --- /dev/null +++ b/config/ags/functions/monitor_configuration.js @@ -0,0 +1,127 @@ +import { configPath } from "../services/configuration.js"; +import { HOME, configs } from "../vars.js"; +import { replacePlaceholders as rep } from "./utils.js"; +import Gio from "gi://Gio"; + +//sorry (?) + +export default function() { + const wallpaper = configs.wallpaper; + const theme = configs.theme; + const bar = theme.bar; + const osd = configs.osd; + const sysmonitor = configs.system_monitor; + const window = theme.window; + + Utils.monitorFile(configPath, (file, type) => { + // Monitor non Utils.writeFile event + if (type === Gio.FileMonitorEvent.ATTRIBUTE_CHANGED) { + const configJson = JSON.parse(Utils.readFile(file.get_path()) || "{}"); + const wallpaperJson = configJson.wallpaper; + const themeJson = configJson.theme; + const windowJson = themeJson.window; + const barJson = themeJson.bar; + const osdJson = configJson.osd; + const sysmonitorJson = configJson.system_monitor; + + if (wallpaper.folder.value != rep(wallpaperJson.folder, { home: HOME })) + wallpaper.folder.setValue(rep(wallpaperJson.folder, { home: HOME })); + + if (wallpaper.current.value != wallpaperJson.current) + wallpaper.current.setValue(wallpaperJson.current); + + if (theme.dark_mode.value != themeJson.dark_mode) + theme.dark_mode.setValue(themeJson.dark_mode); + + if (window.margin.value != windowJson.margin) + window.margin.setValue(windowJson.margin); + + if (window.opacity.value != windowJson.opacity) + window.opacity.setValue(windowJson.opacity); + + if (window.border.value != windowJson.border) + window.border.setValue(windowJson.border); + + if (theme.border_radius.value != themeJson.border_radius) + theme.border_radius.setValue(themeJson.border_radius); + + if (bar.position.value != barJson.position) + bar.position.setValue(barJson.position); + + if (bar.border.value != barJson.border) + bar.border.setValue(barJson.border); + + if (bar.opacity.value != barJson.opacity) + bar.opacity.setValue(barJson.opacity); + + if (bar.button_opacity.value != barJson.button_opacity) + bar.button_opacity.setValue(barJson.button_opacity); + + if (bar.shadow.value != barJson.shadow) + bar.shadow.setValue(barJson.shadow); + + if (bar.button_padding.value != barJson.button_padding) + bar.button_padding.setValue(barJson.button_padding); + + if (bar.button_spacing.value != barJson.button_spacing) + bar.button_spacing.setValue(barJson.button_spacing); + + if (bar.button_shadow.value != barJson.button_shadow) + bar.button_shadow.setValue(barJson.button_shadow); + + if (bar.button_border_radius.value != barJson.button_border_radius) + bar.button_border_radius.setValue(barJson.button_border_radius); + + if (bar.margin.value != barJson.margin) + bar.margin.setValue(barJson.margin); + + if (bar.padding.value != barJson.padding) + bar.padding.setValue(barJson.padding); + + if (bar.border_radius.value != barJson.border_radius) + bar.border_radius.setValue(barJson.border_radius); + + if (bar.launcher_icon.value != barJson.launcher_icon) + bar.launcher_icon.setValue(barJson.launcher_icon); + + if (bar.workspace_active_width.value != barJson.workspace_active_width) + bar.workspace_active_width.setValue(barJson.workspace_active_width); + + if (osd.progress.position.value != osdJson.progress.position) + osd.progress.position.setValue(osdJson.progress.position); + + if (osd.regular.position.value != osdJson.regular.position) + osd.regular.position.setValue(osdJson.regular.position); + + if (osd.progress.vertical.value != osdJson.progress.vertical) + osd.progress.vertical.setValue(osdJson.progress.vertical); + + if (osd.regular.vertical.value != osdJson.regular.vertical) + osd.regular.vertical.setValue(osdJson.regular.vertical); + + if (osd.regular.margin.value != osdJson.regular.margin) + osd.regular.margin.setValue(osdJson.regular.margin); + + if (osd.progress.margin.value != osdJson.progress.margin) + osd.progress.margin.setValue(osdJson.progress.margin); + + if (osd.regular.capslock.value != osdJson.regular.capslock) + osd.regular.capslock.setValue(osdJson.regular.capslock); + + if (osd.regular.mic.value != osdJson.regular.mic) + osd.regular.mic.setValue(osdJson.regular.mic); + + if (osd.progress.brightness.value != osdJson.progress.brightness) + osd.progress.brightness.setValue(osdJson.progress.brightness); + + if (osd.progress.volume.value != osdJson.progress.volume) + osd.progress.volume.setValue(osdJson.progress.volume); + + if (sysmonitor.position.value != sysmonitorJson.position) + sysmonitor.position.setValue(sysmonitorJson.position); + + if (sysmonitor.margin.value != sysmonitorJson.margin) + sysmonitor.margin.setValue(sysmonitorJson.margin); + } + }); +} diff --git a/config/ags/functions/theme/ags.js b/config/ags/functions/theme/ags.js new file mode 100644 index 00000000..f0c33d08 --- /dev/null +++ b/config/ags/functions/theme/ags.js @@ -0,0 +1,135 @@ +import { isVertical, matugenStringify, posIndex } from "../utils.js"; +import { configs } from "../../vars.js"; + +export const format = (str, four_values = true, px = true) => { + let splitted = str + .split(",") + .map((item) => `${item}${px ? `px` : ""}`.trim()); + + let result = splitted.join(" "); + if (four_values) { + switch (splitted.length) { + case 1: + result = `${splitted[0]} `.repeat(4); + break; + case 2: + result = `${splitted[0]} ${splitted[1]} ${splitted[0]} ${splitted[1]}`; + break; + case 3: + result = `${splitted[0]} ${splitted[1]} ${splitted[2]} ${splitted[1]}`; + break; + } + } + + return result; +}; + +function switchArray(arr) { + var temp = arr[0]; + arr[0] = arr[1]; + arr[1] = temp; + + temp = arr[2]; + arr[2] = arr[3]; + arr[3] = temp; + + return arr; +} + +export function setScssVariable({ + key = "", + value = "", + need_format = true, + four_values = true, + bar_pos = configs.theme.bar.position.value, +}) { + let data = { + window_margin: "0", + border_radius: "0", + bar_border_radius: "0", + bar_margin: "0", + workspace_active_width: "30", + dark_mode: false, + osd_regular_margin: "0", + osd_progress_margin: "0", + bar_opacity: 1.0, + bar_button_opacity: 1.0, + panel_button_padding: "0", + bar_padding: "0", + bar_shadow: false, + bar_button_shadow: false, + bar_button_border_radius: "0", + system_monitor_margin: "0", + bar_border: false, + window_opacity: 0.7, + window_border: false, + }; + + let idx = [2, 3, 0, 1]; + + data.window_margin = format(configs.theme.window.margin.value); + data.border_radius = format(configs.theme.border_radius.value); + data.bar_border_radius = format(configs.theme.bar.border_radius.value); + data.bar_margin = format(configs.theme.bar.margin.value); + data.dark_mode = configs.theme.dark_mode.value.toString(); + data.workspace_active_width = format( + configs.theme.bar.workspace_active_width.value, + false, + ); + data.osd_regular_margin = format(configs.osd.regular.margin.value); + data.osd_progress_margin = format(configs.osd.progress.margin.value); + data.bar_opacity = configs.theme.bar.opacity.value; + data.bar_button_opacity = configs.theme.bar.button_opacity.value; + data.bar_shadow = configs.theme.bar.shadow.value; + data.bar_button_shadow = configs.theme.bar.button_shadow.value; + data.panel_button_padding = format(configs.theme.bar.button_padding.value); + data.bar_padding = format(configs.theme.bar.padding.value); + data.bar_button_border_radius = format( + configs.theme.bar.button_border_radius.value, + ); + data.bar_border = configs.theme.bar.border.value; + data.system_monitor_margin = format(configs.system_monitor.margin.value); + data.window_opacity = configs.theme.window.opacity.value; + data.window_border = configs.theme.window.border.value; + + if (isVertical(bar_pos)) { + data.panel_button_padding = switchArray( + data.panel_button_padding.split(" "), + ).join(" "); + } + + let update = {}; + if (key != "" && value != "") { + update[key] = need_format ? format(value, four_values) : value; + } + let merged = { ...data, ...update }; + + merged.window_margin = merged.window_margin.split(" "); + const tempWindowMargin = + Number(merged.window_margin[posIndex(bar_pos)].replace("px", "")) / 2; + merged.window_margin[posIndex(bar_pos)] = `${tempWindowMargin}px`; + merged.window_margin = merged.window_margin.join(" "); + merged.bar_margin = merged.bar_margin.split(" "); + merged.bar_margin[idx[posIndex(bar_pos)]] = `${tempWindowMargin}px`; + merged.bar_margin = merged.bar_margin.join(" "); + + let result = ""; + + Object.entries(merged).forEach(([key, value]) => { + result += `$${key}: ${value};\n`; + }); + + Utils.writeFile(result, App.configDir + "/style/vars.scss"); +} + +function setScssColors(theme) { + Utils.writeFile( + matugenStringify("${{key}}: {{value}};", theme), + App.configDir + "/style/colors.scss", + ); +} + +export default function setAgs(theme) { + setScssVariable({}); + setScssColors(theme); +} diff --git a/config/ags/functions/theme/gtk.js b/config/ags/functions/theme/gtk.js new file mode 100644 index 00000000..73efcaa6 --- /dev/null +++ b/config/ags/functions/theme/gtk.js @@ -0,0 +1,46 @@ +import { HOME, configs } from "../../vars.js"; +import Gio from "gi://Gio"; + +const settings = new Gio.Settings({ + schema: "org.gnome.desktop.interface", +}); + +function setGtkSetting(themeScheme) { + settings.reset("color-scheme"); + settings.set_string("color-scheme", `prefer-${themeScheme}`); + settings.set_string( + "gtk-theme", + `adw-gtk3${themeScheme == "dark" ? "-dark" : ""}`, + ); +} + +export default async function setGtk(theme, themeScheme) { + if (themeScheme === undefined) { + themeScheme = configs.theme.dark_mode.value ? "dark" : "light"; + } + + if (theme === undefined) { + theme = JSON.parse(Utils.readFile(App.configDir + "/colors.json") || "{}") + .colors[themeScheme]; + } + + const primaryColor = theme.primary; + const bgColor = theme.background; + const gtkCss = [ + `accent_bg_color ${primaryColor};`, + `view_bg_color alpha(${bgColor}, ${configs.theme.window.opacity.value});`, + `sidebar_bg_color alpha(${bgColor}, ${configs.theme.window.opacity.value});`, + `headerbar_bg_color ${bgColor};`, + `popover_bg_color alpha(${bgColor}, ${configs.theme.window.opacity.value});`, + ]; + Utils.writeFile( + gtkCss + .map((vars) => { + return "@define-color " + vars; + }) + .join(`\n`), + HOME + "/.themes/colors.css", + ).then(() => { + setGtkSetting(themeScheme); + }); +} diff --git a/config/ags/functions/theme/hyprland.js b/config/ags/functions/theme/hyprland.js new file mode 100644 index 00000000..b60e8081 --- /dev/null +++ b/config/ags/functions/theme/hyprland.js @@ -0,0 +1,34 @@ +import { configs } from "../../vars.js"; +import { isVertical, posIndex, sendBatch } from "../utils.js"; +import { format } from "./ags.js"; + +export default function setHyprland(theme) { + const bgColor = theme.background.replace("#", ""); + const primaryColor = theme.primary.replace("#", ""); + let margin = format(configs.theme.window.margin.value, true, false); + margin = margin.split(" "); + const marginValue = Number( + margin[posIndex(configs.theme.bar.position.value)], + ); + margin[posIndex(configs.theme.bar.position.value)] = `${marginValue / 2}`; + margin = margin.join(", "); + sendBatch([ + `decoration:col.shadow rgb(${bgColor})`, + `decoration:rounding ${configs.theme.border_radius.value.split(",")[0].trim()}`, + `general:col.active_border rgb(${primaryColor})`, + `general:gaps_out ${margin}`, + `animation workspaces,1,7,menu_decel,${isVertical(configs.theme.bar.position.value) ? `slidevert` : "slide"}`, + ]); +} + +export function setGapsOut() { + const bar_pos = configs.theme.bar.position.value; + const value = configs.theme.window.margin.value; + let margin = format(value, true, false); + margin = margin.split(" "); + const marginValue = Number(margin[posIndex(bar_pos)]); + margin[posIndex(bar_pos)] = `${marginValue / 2}`; + margin = margin.join(", "); + + sendBatch([`general:gaps_out ${margin}`]); +} diff --git a/config/ags/functions/theme/init.js b/config/ags/functions/theme/init.js new file mode 100644 index 00000000..232233d2 --- /dev/null +++ b/config/ags/functions/theme/init.js @@ -0,0 +1,42 @@ +import setAgs from "./ags.js"; +import setHyprland from "./hyprland.js"; +import setGtk from "./gtk.js"; +import Gio from "gi://Gio"; +import { applyCss, sh } from "../utils.js"; +import { configs } from "../../vars.js"; + +export function setTheme() { + let colors = Utils.readFile(App.configDir + "/colors.json"); + + if (colors === "") { + sh(`matugen color hex "#282828" --json hex`).then((out) => { + colors = out; + Utils.writeFile( + JSON.stringify(JSON.parse(out), null, 2), + App.configDir + "/colors.json", + ).catch(print); + }); + } + const themeJson = JSON.parse(colors || "{}"); + const themeMode = configs.theme.dark_mode.value ? "dark" : "light"; + const theme = themeJson["colors"][themeMode]; + const harmonizedColors = themeJson.harmonized_colors; + + setAgs(theme); + setHyprland(theme); + setGtk(theme, themeMode); +} + +function monitorTheme() { + Utils.monitorFile(App.configDir + "/colors.json", (_, eventType) => { + if (eventType === Gio.FileMonitorEvent.CHANGES_DONE_HINT) { + setTheme(); + } + }); + Utils.monitorFile(App.configDir + "/style/", applyCss); +} + +export default function initTheme() { + monitorTheme(); + setTheme(); +} diff --git a/config/ags/functions/theme/matugen.js b/config/ags/functions/theme/matugen.js new file mode 100644 index 00000000..5fa13f81 --- /dev/null +++ b/config/ags/functions/theme/matugen.js @@ -0,0 +1,10 @@ +import { sh } from "../utils.js"; + +export function generateColor(path) { + sh(`matugen image ${path} --json hex`).then((out) => { + Utils.writeFile( + JSON.stringify(JSON.parse(out), null, 2), + App.configDir + "/colors.json", + ).catch(print); + }); +} diff --git a/config/ags/functions/utils.js b/config/ags/functions/utils.js new file mode 100644 index 00000000..c6d1e522 --- /dev/null +++ b/config/ags/functions/utils.js @@ -0,0 +1,159 @@ +import GLib from "gi://GLib?version=2.0"; +const hyprland = await Service.import("hyprland"); + +const substitutes = { + "transmission-gtk": "transmission", + "blueberry.py": "blueberry", + Caprine: "facebook-messenger", + "Alacritty-symbolic": "terminal-symbolic", + "com.raggesilver.BlackBox-symbolic": "terminal-symbolic", + "org.wezfurlong.wezterm-symbolic": "terminal-symbolic", + "audio-headset-bluetooth": "audio-headphones-symbolic", + "audio-card-analog-usb": "audio-speakers-symbolic", + "audio-card-analog-pci": "audio-card-symbolic", + "preferences-system": "emblem-system-symbolic", + "com.github.Aylur.ags-symbolic": "controls-symbolic", + "com.github.Aylur.ags": "controls-symbolic", +}; + +export function icon(name, fallback = "image-missing-symbolic") { + if (!name) return fallback || ""; + + if (GLib.file_test(name, GLib.FileTest.EXISTS)) return name; + + const icon = substitutes[name] || name; + if (Utils.lookUpIcon(icon)) return icon; + + return fallback; +} + +export const sendBatch = (batch) => { + const cmd = batch + .filter((x) => !!x) + .map((x) => `keyword ${x}`) + .join("; "); + + hyprland.message(`[[BATCH]]/${cmd}`); +}; + +export async function sh(cmd) { + return Utils.execAsync(cmd).catch((err) => { + console.error(typeof cmd === "string" ? cmd : cmd.join(" "), err); + return ""; + }); +} +export async function bash(strings, ...values) { + const cmd = + typeof strings === "string" + ? strings + : strings.flatMap((str, i) => str + `${values[i] ?? ""}`).join(""); + + return Utils.execAsync(["bash", "-c", cmd]).catch((err) => { + console.error(cmd, err); + return ""; + }); +} + +export function matugenStringify(format, json) { + let result = ""; + + for (let key in json) { + let value = json[key]; + result += format.replace("{{key}}", key).replace("{{value}}", value) + "\n"; + } + + return result; +} + +export function applyCss() { + const scss = App.configDir + "/style/main.scss"; + const css = TMP + "/style.css"; + + sh(`sass ${scss} ${css}`).then(() => { + App.resetCss(); + App.applyCss(css); + }); +} + +const isObject = (item) => { + return item && typeof item === "object" && !Array.isArray(item); +}; + +export function deepMerge(target, ...sources) { + if (!sources.length) return target; + const source = sources.shift(); + + if (isObject(target) && isObject(source)) { + for (const key in source) { + if (isObject(source[key])) { + if (!target[key]) + Object.assign(target, { + [key]: {}, + }); + deepMerge(target[key], source[key]); + } else { + Object.assign(target, { + [key]: source[key], + }); + } + } + } + + return deepMerge(target, ...sources); +} + +export function replacePlaceholders(str, data) { + if (typeof str !== "string") { + return str; + } + return str.replace(/\{\{(\w+)\}\}/g, (match, key) => { + return data[key] || match; + }); +} + +export function reverseReplace(str, data) { + for (const key in data) { + if (data.hasOwnProperty(key)) { + const value = data[key]; + const regex = new RegExp(value, "g"); + str = str.replace(regex, `{{${key}}}`); + } + } + return str; +} + +export function isVertical(pos) { + return pos === "left" || pos === "right"; +} + +export const posIndex = (pos) => { + switch (pos) { + case "top": + return 0; + case "right": + return 1; + case "bottom": + return 2; + default: + return 3; + } +}; + +export const layoutPos = (pos, layout) => { + const win = { + top: {}, + left: { + "top-right": "bottom-left", + }, + right: { + "top-right": "bottom-right", + "top-left": "top-right", + }, + bottom: { + "top-left": "bottom-left", + "top-right": "bottom-right", + }, + }; + + return win[pos][layout] ?? layout; +}; diff --git a/config/ags/functions/wallpaper.js b/config/ags/functions/wallpaper.js new file mode 100644 index 00000000..c3c8f9cf --- /dev/null +++ b/config/ags/functions/wallpaper.js @@ -0,0 +1,33 @@ +import { configs, HOME } from "../vars.js"; +import { sh } from "./utils.js"; +import { generateColor } from "./theme/matugen.js"; +import Gio from "gi://Gio"; + +export function cpWallpaper(filename) { + const folder = configs.wallpaper.folder.value; + const path = folder + "/" + filename; + sh(`cp ${path} ${HOME}/.config/background`); +} + +export function setWallpaper(path) { + generateColor(path); + sh([ + "swww", + "img", + "--transition-type", + "any", + "--transition-fps", + "60", + path, + ]); +} + +export default function initWallpaper() { + Utils.monitorFile(`${HOME}/.config/background/`, (file, eventType) => { + if (eventType === Gio.FileMonitorEvent.CHANGES_DONE_HINT) { + setWallpaper(file.get_path()); + } + }); + + sh("swww-daemon --format xrgb"); +} diff --git a/config/ags/init.js b/config/ags/init.js new file mode 100644 index 00000000..e8be8a81 --- /dev/null +++ b/config/ags/init.js @@ -0,0 +1,16 @@ +// import { initTheme, initWallpaper, setWallpaper } from "./functions/theme.js"; +import initWallpaper from "./functions/wallpaper.js"; +import watchConfiguration from "./functions/monitor_configuration.js"; +import initHyprland from "./functions/hyprland/init.js"; +import initTheme from "./functions/theme/init.js"; +import globals from "./functions/globals.js"; +import { setupWindows } from "./windows.js"; + +export default function() { + globals(); + setupWindows(); + initWallpaper(); + initTheme(); + initHyprland(); + watchConfiguration(); +} diff --git a/config/ags/modules/.configuration/user_options.js b/config/ags/modules/.configuration/user_options.js deleted file mode 100644 index 0c76a549..00000000 --- a/config/ags/modules/.configuration/user_options.js +++ /dev/null @@ -1,121 +0,0 @@ - -import userOverrides from '../../user_options.js'; - -// Defaults -let configOptions = { - // General stuff - 'ai': { - 'defaultGPTProvider': "openai", - 'defaultTemperature': 0.9, - 'enhancements': true, - 'useHistory': true, - 'writingCursor': " ...", // Warning: Using weird characters can mess up Markdown rendering - }, - 'animations': { - 'choreographyDelay': 35, - 'durationSmall': 110, - 'durationLarge': 180, - }, - 'appearance': { - 'keyboardUseFlag': false, // Use flag emoji instead of abbreviation letters - }, - 'apps': { - 'imageViewer': "loupe", - 'terminal': "foot", // This is only for shell actions - }, - 'battery': { - 'low': 20, - 'critical': 10, - }, - 'music': { - 'preferredPlayer': "plasma-browser-integration", - }, - 'onScreenKeyboard': { - 'layout': "qwerty_full", // See modules/onscreenkeyboard/onscreenkeyboard.js for available layouts - }, - 'overview': { - 'scale': 0.18, // Relative to screen size - 'numOfRows': 2, - 'numOfCols': 5, - 'wsNumScale': 0.09, - 'wsNumMarginScale': 0.07, - }, - 'sidebar': { - 'imageColumns': 2, - 'imageBooruCount': 20, - 'imageAllowNsfw': false, - }, - 'search': { - 'engineBaseUrl': "https://www.google.com/search?q=", - 'excludedSites': [], //add site to exclude from result. eg: "quora.com" - }, - 'time': { - // See https://docs.gtk.org/glib/method.DateTime.format.html - // Here's the 12h format: "%I:%M%P" - // For seconds, add "%S" and set interval to 1000 - 'format': "%H:%M", - 'interval': 5000, - 'dateFormatLong': "%A, %d/%m", // On bar - 'dateInterval': 5000, - 'dateFormat': "%d/%m", // On notif time - }, - 'weather': { - 'city': "", - }, - 'workspaces': { - 'shown': 10, - }, - // Longer stuff - 'icons': { - substitutions: { - 'code-url-handler': "visual-studio-code", - 'Code': "visual-studio-code", - 'GitHub Desktop': "github-desktop", - 'Minecraft* 1.20.1': "minecraft", - 'gnome-tweaks': "org.gnome.tweaks", - 'pavucontrol-qt': "pavucontrol", - 'wps': "wps-office2019-kprometheus", - 'wpsoffice': "wps-office2019-kprometheus", - '': "image-missing", - } - }, - 'keybinds': { - // Format: Mod1+Mod2+key. CaSe SeNsItIvE! - // Modifiers: Shift Ctrl Alt Hyper Meta - // See https://docs.gtk.org/gdk3/index.html#constants for the other keys (they are listed as KEY_key) - 'overview': { - 'altMoveLeft': "Ctrl+b", - 'altMoveRight': "Ctrl+f", - 'deleteToEnd': "Ctrl+k", - }, - 'sidebar': { - 'apis': { - 'nextTab': "Page_Down", - 'prevTab': "Page_Up", - }, - 'options': { // Right sidebar - 'nextTab': "Page_Down", - 'prevTab': "Page_Up", - }, - 'pin': "Ctrl+p", - 'cycleTab': "Ctrl+Tab", - 'nextTab': "Ctrl+Page_Down", - 'prevTab': "Ctrl+Page_Up", - }, - }, -} - -// Override defaults with user's options -function overrideConfigRecursive(userOverrides, configOptions = {}) { - for (const [key, value] of Object.entries(userOverrides)) { - if (typeof value === 'object') { - overrideConfigRecursive(value, configOptions[key]); - } else { - configOptions[key] = value; - } - } -} -overrideConfigRecursive(userOverrides, configOptions); - -globalThis['userOptions'] = configOptions; -export default configOptions; \ No newline at end of file diff --git a/config/ags/modules/.miscutils/icons.js b/config/ags/modules/.miscutils/icons.js deleted file mode 100644 index fb1e20da..00000000 --- a/config/ags/modules/.miscutils/icons.js +++ /dev/null @@ -1,13 +0,0 @@ -const { Gtk } = imports.gi; - -export function iconExists(iconName) { - let iconTheme = Gtk.IconTheme.get_default(); - return iconTheme.has_icon(iconName); -} - -export function substitute(str) { - if(userOptions.icons.substitutions[str]) return userOptions.icons.substitutions[str]; - - if (!iconExists(str)) str = str.toLowerCase().replace(/\s+/g, '-'); // Turn into kebab-case - return str; -} \ No newline at end of file diff --git a/config/ags/modules/.miscutils/mathfuncs.js b/config/ags/modules/.miscutils/mathfuncs.js deleted file mode 100644 index ba1c0b59..00000000 --- a/config/ags/modules/.miscutils/mathfuncs.js +++ /dev/null @@ -1,4 +0,0 @@ - -export function clamp(x, min, max) { - return Math.min(Math.max(x, min), max); -} \ No newline at end of file diff --git a/config/ags/modules/.miscutils/system.js b/config/ags/modules/.miscutils/system.js deleted file mode 100644 index ef7d15c3..00000000 --- a/config/ags/modules/.miscutils/system.js +++ /dev/null @@ -1,54 +0,0 @@ -const { GLib } = imports.gi; -import Variable from 'resource:///com/github/Aylur/ags/variable.js'; -import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; -const { execAsync, exec } = Utils; - -export const distroID = exec(`bash -c 'cat /etc/os-release | grep "^ID=" | cut -d "=" -f 2 | sed "s/\\"//g"'`).trim(); -export const isDebianDistro = (distroID == 'linuxmint' || distroID == 'ubuntu' || distroID == 'debian' || distroID == 'zorin' || distroID == 'popos' || distroID == 'raspbian' || distroID == 'kali'); -export const isArchDistro = (distroID == 'arch' || distroID == 'endeavouros' || distroID == 'cachyos'); -export const hasFlatpak = !!exec(`bash -c 'command -v flatpak'`); - -const LIGHTDARK_FILE_LOCATION = `${GLib.get_user_cache_dir()}/ags/user/colormode.txt`; -const colorMode = Utils.exec('bash -c "sed -n \'1p\' $HOME/.cache/ags/user/colormode.txt"'); -export let darkMode = Variable(!(Utils.readFile(LIGHTDARK_FILE_LOCATION).split('\n')[0].trim() == 'light')); -export const hasPlasmaIntegration = !!Utils.exec('bash -c "command -v plasma-browser-integration-host"'); - -export const getDistroIcon = () => { - // Arches - if(distroID == 'arch') return 'arch-symbolic'; - if(distroID == 'endeavouros') return 'endeavouros-symbolic'; - if(distroID == 'cachyos') return 'cachyos-symbolic'; - // Funny flake - if(distroID == 'nixos') return 'nixos-symbolic'; - // Cool thing - if(distroID == 'fedora') return 'fedora-symbolic'; - // Debians - if(distroID == 'linuxmint') return 'ubuntu-symbolic'; - if(distroID == 'ubuntu') return 'ubuntu-symbolic'; - if(distroID == 'debian') return 'debian-symbolic'; - if(distroID == 'zorin') return 'ubuntu-symbolic'; - if(distroID == 'popos') return 'ubuntu-symbolic'; - if(distroID == 'raspbian') return 'debian-symbolic'; - if(distroID == 'kali') return 'debian-symbolic'; - return 'linux-symbolic'; -} - -export const getDistroName = () => { - // Arches - if(distroID == 'arch') return 'Arch Linux'; - if(distroID == 'endeavouros') return 'EndeavourOS'; - if(distroID == 'cachyos') return 'CachyOS'; - // Funny flake - if(distroID == 'nixos') return 'NixOS'; - // Cool thing - if(distroID == 'fedora') return 'Fedora'; - // Debians - if(distroID == 'linuxmint') return 'Linux Mint'; - if(distroID == 'ubuntu') return 'Ubuntu'; - if(distroID == 'debian') return 'Debian'; - if(distroID == 'zorin') return 'Zorin'; - if(distroID == 'popos') return 'Pop!_OS'; - if(distroID == 'raspbian') return 'Raspbian'; - if(distroID == 'kali') return 'Kali Linux'; - return 'Linux'; -} diff --git a/config/ags/modules/.widgethacks/advancedrevealers.js b/config/ags/modules/.widgethacks/advancedrevealers.js deleted file mode 100644 index 3f127931..00000000 --- a/config/ags/modules/.widgethacks/advancedrevealers.js +++ /dev/null @@ -1,86 +0,0 @@ -import Widget from 'resource:///com/github/Aylur/ags/widget.js'; - -const { Revealer, Scrollable } = Widget; - -export const MarginRevealer = ({ - transition = 'slide_down', - child, - revealChild, - showClass = 'element-show', // These are for animation curve, they don't really hide - hideClass = 'element-hide', // Don't put margins in these classes! - extraSetup = () => { }, - ...rest -}) => { - const widget = Scrollable({ - ...rest, - attribute: { - 'revealChild': true, // It'll be set to false after init if it's supposed to hide - 'transition': transition, - 'show': () => { - if (widget.attribute.revealChild) return; - widget.hscroll = 'never'; - widget.vscroll = 'never'; - child.toggleClassName(hideClass, false); - child.toggleClassName(showClass, true); - widget.attribute.revealChild = true; - child.css = 'margin: 0px;'; - }, - 'hide': () => { - if (!widget.attribute.revealChild) return; - child.toggleClassName(hideClass, true); - child.toggleClassName(showClass, false); - widget.attribute.revealChild = false; - if (widget.attribute.transition == 'slide_left') - child.css = `margin-right: -${child.get_allocated_width()}px;`; - else if (widget.attribute.transition == 'slide_right') - child.css = `margin-left: -${child.get_allocated_width()}px;`; - else if (widget.attribute.transition == 'slide_up') - child.css = `margin-bottom: -${child.get_allocated_height()}px;`; - else if (widget.attribute.transition == 'slide_down') - child.css = `margin-top: -${child.get_allocated_height()}px;`; - }, - 'toggle': () => { - if (widget.attribute.revealChild) widget.attribute.hide(); - else widget.attribute.show(); - }, - }, - child: child, - hscroll: `${revealChild ? 'never' : 'always'}`, - vscroll: `${revealChild ? 'never' : 'always'}`, - setup: (self) => { - extraSetup(self); - } - }); - child.toggleClassName(`${revealChild ? showClass : hideClass}`, true); - return widget; -} - -// TODO: Allow reveal update. Currently this just helps at declaration -export const DoubleRevealer = ({ - transition1 = 'slide_right', - transition2 = 'slide_left', - duration1 = 150, - duration2 = 150, - child, - revealChild, - ...rest -}) => { - const r2 = Revealer({ - transition: transition2, - transitionDuration: duration2, - revealChild: revealChild, - child: child, - }); - const r1 = Revealer({ - transition: transition1, - transitionDuration: duration1, - revealChild: revealChild, - child: r2, - ...rest, - }) - r1.toggleRevealChild = (value) => { - r1.revealChild = value; - r2.revealChild = value; - } - return r1; -} diff --git a/config/ags/modules/.widgethacks/popupwindow.js b/config/ags/modules/.widgethacks/popupwindow.js deleted file mode 100644 index 26dad59c..00000000 --- a/config/ags/modules/.widgethacks/popupwindow.js +++ /dev/null @@ -1,32 +0,0 @@ -import App from 'resource:///com/github/Aylur/ags/app.js'; -import Widget from 'resource:///com/github/Aylur/ags/widget.js'; -const { Box, Window } = Widget; - - -export default ({ - name, - child, - showClassName = "", - hideClassName = "", - ...props -}) => { - return Window({ - name, - visible: false, - layer: 'overlay', - ...props, - - child: Box({ - setup: (self) => { - self.hook(App, (self, currentName, visible) => { - if (currentName === name) { - self.toggleClassName(hideClassName, !visible); - } - }).keybind("Escape", () => App.closeWindow(name)) - if (showClassName !== "" && hideClassName !== "") - self.className = `${showClassName} ${hideClassName}`; - }, - child: child, - }), - }); -} \ No newline at end of file diff --git a/config/ags/modules/.widgetutils/clickthrough.js b/config/ags/modules/.widgetutils/clickthrough.js deleted file mode 100644 index 505f1412..00000000 --- a/config/ags/modules/.widgetutils/clickthrough.js +++ /dev/null @@ -1,4 +0,0 @@ -import Cairo from 'gi://cairo?version=1.0'; - -export const dummyRegion = new Cairo.Region(); -export const enableClickthrough = (self) => self.input_shape_combine_region(dummyRegion); \ No newline at end of file diff --git a/config/ags/modules/.widgetutils/cursorhover.js b/config/ags/modules/.widgetutils/cursorhover.js deleted file mode 100644 index 89be913b..00000000 --- a/config/ags/modules/.widgetutils/cursorhover.js +++ /dev/null @@ -1,57 +0,0 @@ -const { Gdk } = imports.gi; - -export function setupCursorHover(button) { // Hand pointing cursor on hover - const display = Gdk.Display.get_default(); - button.connect('enter-notify-event', () => { - const cursor = Gdk.Cursor.new_from_name(display, 'pointer'); - button.get_window().set_cursor(cursor); - }); - - button.connect('leave-notify-event', () => { - const cursor = Gdk.Cursor.new_from_name(display, 'default'); - button.get_window().set_cursor(cursor); - }); - -} - -export function setupCursorHoverAim(button) { // Crosshair cursor on hover - button.connect('enter-notify-event', () => { - const display = Gdk.Display.get_default(); - const cursor = Gdk.Cursor.new_from_name(display, 'crosshair'); - button.get_window().set_cursor(cursor); - }); - - button.connect('leave-notify-event', () => { - const display = Gdk.Display.get_default(); - const cursor = Gdk.Cursor.new_from_name(display, 'default'); - button.get_window().set_cursor(cursor); - }); -} - -export function setupCursorHoverGrab(button) { // Hand ready to grab on hover - button.connect('enter-notify-event', () => { - const display = Gdk.Display.get_default(); - const cursor = Gdk.Cursor.new_from_name(display, 'grab'); - button.get_window().set_cursor(cursor); - }); - - button.connect('leave-notify-event', () => { - const display = Gdk.Display.get_default(); - const cursor = Gdk.Cursor.new_from_name(display, 'default'); - button.get_window().set_cursor(cursor); - }); -} - -export function setupCursorHoverInfo(button) { // "?" mark cursor on hover - const display = Gdk.Display.get_default(); - button.connect('enter-notify-event', () => { - const cursor = Gdk.Cursor.new_from_name(display, 'help'); - button.get_window().set_cursor(cursor); - }); - - button.connect('leave-notify-event', () => { - const cursor = Gdk.Cursor.new_from_name(display, 'default'); - button.get_window().set_cursor(cursor); - }); -} - diff --git a/config/ags/modules/.widgetutils/keybind.js b/config/ags/modules/.widgetutils/keybind.js deleted file mode 100644 index eda7877b..00000000 --- a/config/ags/modules/.widgetutils/keybind.js +++ /dev/null @@ -1,25 +0,0 @@ -const { Gdk } = imports.gi; - -const MODS = { - 'Shift': Gdk.ModifierType.SHIFT_MASK, - 'Ctrl': Gdk.ModifierType.CONTROL_MASK, - 'Alt': Gdk.ModifierType.ALT_MASK, - 'Hyper': Gdk.ModifierType.HYPER_MASK, - 'Meta': Gdk.ModifierType.META_MASK -} - -export const checkKeybind = (event, keybind) => { - const pressedModMask = event.get_state()[1]; - const pressedKey = event.get_keyval()[1]; - const keys = keybind.split('+'); - for (let i = 0; i < keys.length; i++) { - if (keys[i] in MODS) { - if (!(pressedModMask & MODS[keys[i]])) { - return false; - } - } else if (pressedKey !== Gdk[`KEY_${keys[i]}`]) { - return false; - } - } - return true; -} diff --git a/config/ags/modules/overview/actions.js b/config/ags/modules/overview/actions.js deleted file mode 100644 index 766cf454..00000000 --- a/config/ags/modules/overview/actions.js +++ /dev/null @@ -1,28 +0,0 @@ -import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; -import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js'; - -function moveClientToWorkspace(address, workspace) { - Utils.execAsync(['bash', '-c', `hyprctl dispatch movetoworkspacesilent ${workspace},address:${address} &`]); -} - -export function dumpToWorkspace(from, to) { - if (from == to) return; - Hyprland.clients.forEach(client => { - if (client.workspace.id == from) { - moveClientToWorkspace(client.address, to); - } - }); -} - -export function swapWorkspace(workspaceA, workspaceB) { - if (workspaceA == workspaceB) return; - const clientsA = []; - const clientsB = []; - Hyprland.clients.forEach(client => { - if (client.workspace.id == workspaceA) clientsA.push(client.address); - if (client.workspace.id == workspaceB) clientsB.push(client.address); - }); - - clientsA.forEach((address) => moveClientToWorkspace(address, workspaceB)); - clientsB.forEach((address) => moveClientToWorkspace(address, workspaceA)); -} \ No newline at end of file diff --git a/config/ags/modules/overview/main.js b/config/ags/modules/overview/main.js deleted file mode 100644 index 1f5348d9..00000000 --- a/config/ags/modules/overview/main.js +++ /dev/null @@ -1,18 +0,0 @@ -import Widget from 'resource:///com/github/Aylur/ags/widget.js'; -import { SearchAndWindows } from "./windowcontent.js"; -import PopupWindow from '../.widgethacks/popupwindow.js'; - -export default (id = '') => PopupWindow({ - name: `overview${id}`, - exclusivity: 'ignore', - keymode: 'exclusive', - visible: false, - // anchor: ['middle'], - layer: 'overlay', - child: Widget.Box({ - vertical: true, - children: [ - SearchAndWindows(), - ] - }), -}) diff --git a/config/ags/modules/overview/miscfunctions.js b/config/ags/modules/overview/miscfunctions.js deleted file mode 100644 index 187ee6ec..00000000 --- a/config/ags/modules/overview/miscfunctions.js +++ /dev/null @@ -1,155 +0,0 @@ -const { Gio, GLib } = imports.gi; -import App from 'resource:///com/github/Aylur/ags/app.js'; -import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; -const { execAsync, exec } = Utils; -// import Todo from "../../services/todo.js"; -import { darkMode } from '../.miscutils/system.js'; - -export function hasUnterminatedBackslash(inputString) { - // Use a regular expression to match a trailing odd number of backslashes - const regex = /\\+$/; - return regex.test(inputString); -} - -export function launchCustomCommand(command) { - const args = command.toLowerCase().split(' '); - if (args[0] == '>raw') { // Mouse raw input - Utils.execAsync('hyprctl -j getoption input:accel_profile') - .then((output) => { - const value = JSON.parse(output)["str"].trim(); - if (value != "[[EMPTY]]" && value != "") { - execAsync(['bash', '-c', `hyprctl keyword input:accel_profile '[[EMPTY]]'`]).catch(print); - } - else { - execAsync(['bash', '-c', `hyprctl keyword input:accel_profile flat`]).catch(print); - } - }) - } - else if (args[0] == '>img') { // Change wallpaper - execAsync([`bash`, `-c`, `${App.configDir}/scripts/color_generation/switchwall.sh`, `&`]).catch(print); - } - else if (args[0] == '>color') { // Generate colorscheme from color picker - execAsync([`bash`, `-c`, `${App.configDir}/scripts/color_generation/switchcolor.sh --pick`, `&`]).catch(print); - } - else if (args[0] == '>light') { // Light mode - darkMode.value = false; - execAsync([`bash`, `-c`, `mkdir -p ${GLib.get_user_cache_dir()}/ags/user && sed -i "1s/.*/light/" ${GLib.get_user_cache_dir()}/ags/user/colormode.txt`]) - .then(execAsync(['bash', '-c', `${App.configDir}/scripts/color_generation/switchcolor.sh`])) - .catch(print); - } - else if (args[0] == '>dark') { // Dark mode - darkMode.value = true; - execAsync([`bash`, `-c`, `mkdir -p ${GLib.get_user_cache_dir()}/ags/user && sed -i "1s/.*/dark/" ${GLib.get_user_cache_dir()}/ags/user/colormode.txt`]) - .then(execAsync(['bash', '-c', `${App.configDir}/scripts/color_generation/switchcolor.sh`])) - .catch(print); - } - else if (args[0] == '>badapple') { // Black and white - execAsync([`bash`, `-c`, `mkdir -p ${GLib.get_user_cache_dir()}/ags/user && sed -i "3s/.*/monochrome/" ${GLib.get_user_cache_dir()}/ags/user/colormode.txt`]) - .then(execAsync(['bash', '-c', `${App.configDir}/scripts/color_generation/switchcolor.sh`])) - .catch(print); - } - else if (args[0] == '>material') { // Use material colors - execAsync([`bash`, `-c`, `mkdir -p ${GLib.get_user_cache_dir()}/ags/user && echo "material" > ${GLib.get_user_cache_dir()}/ags/user/colorbackend.txt`]).catch(print) - .then(execAsync(['bash', '-c', `${App.configDir}/scripts/color_generation/switchwall.sh --noswitch`]).catch(print)) - .catch(print); - } - else if (args[0] == '>pywal') { // Use Pywal (ik it looks shit but I'm not removing) - execAsync([`bash`, `-c`, `mkdir -p ${GLib.get_user_cache_dir()}/ags/user && echo "pywal" > ${GLib.get_user_cache_dir()}/ags/user/colorbackend.txt`]).catch(print) - .then(execAsync(['bash', '-c', `${App.configDir}/scripts/color_generation/switchwall.sh --noswitch`]).catch(print)) - .catch(print); - } - else if (args[0] == '>todo') { // Todo - Todo.add(args.slice(1).join(' ')); - } - else if (args[0] == '>shutdown') { // Shut down - execAsync([`bash`, `-c`, `systemctl poweroff || loginctl poweroff`]).catch(print); - } - else if (args[0] == '>reboot') { // Reboot - execAsync([`bash`, `-c`, `systemctl reboot || loginctl reboot`]).catch(print); - } - else if (args[0] == '>sleep') { // Sleep - execAsync([`bash`, `-c`, `systemctl suspend || loginctl suspend`]).catch(print); - } - else if (args[0] == '>logout') { // Log out - execAsync([`bash`, `-c`, `pkill Hyprland || pkill sway`]).catch(print); - } -} - -export function execAndClose(command, terminal) { - App.closeWindow('overview'); - if (terminal) { - execAsync([`bash`, `-c`, `${userOptions.apps.terminal} fish -C "${command}"`, `&`]).catch(print); - } - else - execAsync(command).catch(print); -} - -export function couldBeMath(str) { - const regex = /^[0-9.+*/-]/; - return regex.test(str); -} - -export function expandTilde(path) { - if (path.startsWith('~')) { - return GLib.get_home_dir() + path.slice(1); - } else { - return path; - } -} - -function getFileIcon(fileInfo) { - let icon = fileInfo.get_icon(); - if (icon) { - // Get the icon's name - return icon.get_names()[0]; - } else { - // Default icon for files - return 'text-x-generic'; - } -} - -export function ls({ path = '~', silent = false }) { - let contents = []; - try { - let expandedPath = expandTilde(path); - if (expandedPath.endsWith('/')) - expandedPath = expandedPath.slice(0, -1); - let folder = Gio.File.new_for_path(expandedPath); - - let enumerator = folder.enumerate_children('standard::*', Gio.FileQueryInfoFlags.NONE, null); - let fileInfo; - while ((fileInfo = enumerator.next_file(null)) !== null) { - let fileName = fileInfo.get_display_name(); - let fileType = fileInfo.get_file_type(); - - let item = { - parentPath: expandedPath, - name: fileName, - type: fileType === Gio.FileType.DIRECTORY ? 'folder' : 'file', - icon: getFileIcon(fileInfo), - }; - - // Add file extension for files - if (fileType === Gio.FileType.REGULAR) { - let fileExtension = fileName.split('.').pop(); - item.type = `${fileExtension}`; - } - - contents.push(item); - contents.sort((a, b) => { - const aIsFolder = a.type.startsWith('folder'); - const bIsFolder = b.type.startsWith('folder'); - if (aIsFolder && !bIsFolder) { - return -1; - } else if (!aIsFolder && bIsFolder) { - return 1; - } else { - return a.name.localeCompare(b.name); // Sort alphabetically within folders and files - } - }); - } - } catch (e) { - if (!silent) console.log(e); - } - return contents; -} diff --git a/config/ags/modules/overview/overview_hyprland.js b/config/ags/modules/overview/overview_hyprland.js deleted file mode 100644 index 034d6c81..00000000 --- a/config/ags/modules/overview/overview_hyprland.js +++ /dev/null @@ -1,423 +0,0 @@ -// TODO -// - Make client destroy/create not destroy and recreate the whole thing -// - Active ws hook optimization: only update when moving to next group -// -const { Gdk, Gtk } = imports.gi; -const { Gravity } = imports.gi.Gdk; -import { SCREEN_HEIGHT, SCREEN_WIDTH } from '../../variables.js'; -import App from 'resource:///com/github/Aylur/ags/app.js'; -import Variable from 'resource:///com/github/Aylur/ags/variable.js'; -import Widget from 'resource:///com/github/Aylur/ags/widget.js'; -import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; - -import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js'; -const { execAsync, exec } = Utils; -import { setupCursorHoverGrab } from '../.widgetutils/cursorhover.js'; -import { dumpToWorkspace, swapWorkspace } from "./actions.js"; -import { substitute } from "../.miscutils/icons.js"; - -const NUM_OF_WORKSPACES_SHOWN = userOptions.overview.numOfCols * userOptions.overview.numOfRows; -const TARGET = [Gtk.TargetEntry.new('text/plain', Gtk.TargetFlags.SAME_APP, 0)]; -const POPUP_CLOSE_TIME = 100; // ms - -const overviewTick = Variable(false); - -export default () => { - const clientMap = new Map(); - let workspaceGroup = 0; - const ContextMenuWorkspaceArray = ({ label, actionFunc, thisWorkspace }) => Widget.MenuItem({ - label: `${label}`, - setup: (menuItem) => { - let submenu = new Gtk.Menu(); - submenu.className = 'menu'; - - const offset = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN) * NUM_OF_WORKSPACES_SHOWN; - const startWorkspace = offset + 1; - const endWorkspace = startWorkspace + NUM_OF_WORKSPACES_SHOWN - 1; - for (let i = startWorkspace; i <= endWorkspace; i++) { - let button = new Gtk.MenuItem({ - label: `Workspace ${i}` - }); - button.connect("activate", () => { - // execAsync([`${onClickBinary}`, `${thisWorkspace}`, `${i}`]).catch(print); - actionFunc(thisWorkspace, i); - overviewTick.setValue(!overviewTick.value); - }); - submenu.append(button); - } - menuItem.set_reserve_indicator(true); - menuItem.set_submenu(submenu); - } - }) - - const Window = ({ address, at: [x, y], size: [w, h], workspace: { id, name }, class: c, title, xwayland }, screenCoords) => { - const revealInfoCondition = (Math.min(w, h) * userOptions.overview.scale > 70); - if (w <= 0 || h <= 0 || (c === '' && title === '') || c.endsWith('-dropterm')) return null; - // Non-primary monitors - if (screenCoords.x != 0) x -= screenCoords.x; - if (screenCoords.y != 0) y -= screenCoords.y; - // Other offscreen adjustments - if (x + w <= 0) x += (Math.floor(x / SCREEN_WIDTH) * SCREEN_WIDTH); - else if (x < 0) { w = x + w; x = 0; } - if (y + h <= 0) x += (Math.floor(y / SCREEN_HEIGHT) * SCREEN_HEIGHT); - else if (y < 0) { h = y + h; y = 0; } - // Truncate if offscreen - if (x + w > SCREEN_WIDTH) w = SCREEN_WIDTH - x; - if (y + h > SCREEN_HEIGHT) h = SCREEN_HEIGHT - y; - - const appIcon = Widget.Icon({ - icon: substitute(c), - size: Math.min(w, h) * userOptions.overview.scale / 2.5, - }); - return Widget.Button({ - attribute: { - address, x, y, w, h, ws: id, - updateIconSize: (self) => { - appIcon.size = Math.min(self.attribute.w, self.attribute.h) * userOptions.overview.scale / 2.5; - }, - }, - className: 'overview-tasks-window', - hpack: 'start', - vpack: 'start', - css: ` - margin-left: ${Math.round(x * userOptions.overview.scale)}px; - margin-top: ${Math.round(y * userOptions.overview.scale)}px; - margin-right: -${Math.round((x + w) * userOptions.overview.scale)}px; - margin-bottom: -${Math.round((y + h) * userOptions.overview.scale)}px; - `, - onClicked: (self) => { - App.closeWindow('overview'); - Utils.timeout(POPUP_CLOSE_TIME, () => Hyprland.messageAsync(`dispatch focuswindow address:${address}`)); - }, - onMiddleClickRelease: () => Hyprland.messageAsync(`dispatch closewindow address:${address}`), - onSecondaryClick: (button) => { - button.toggleClassName('overview-tasks-window-selected', true); - const menu = Widget.Menu({ - className: 'menu', - children: [ - Widget.MenuItem({ - child: Widget.Label({ - xalign: 0, - label: "Close (Middle-click)", - }), - onActivate: () => Hyprland.messageAsync(`dispatch closewindow address:${address}`), - }), - ContextMenuWorkspaceArray({ - label: "Dump windows to workspace", - actionFunc: dumpToWorkspace, - thisWorkspace: Number(id) - }), - ContextMenuWorkspaceArray({ - label: "Swap windows with workspace", - actionFunc: swapWorkspace, - thisWorkspace: Number(id) - }), - ], - }); - menu.connect("deactivate", () => { - button.toggleClassName('overview-tasks-window-selected', false); - }) - menu.connect("selection-done", () => { - button.toggleClassName('overview-tasks-window-selected', false); - }) - menu.popup_at_widget(button.get_parent(), Gravity.SOUTH, Gravity.NORTH, null); // Show menu below the button - button.connect("destroy", () => menu.destroy()); - }, - child: Widget.Box({ - homogeneous: true, - child: Widget.Box({ - vertical: true, - vpack: 'center', - className: 'spacing-v-5', - children: [ - appIcon, - // TODO: Add xwayland tag instead of just having italics - Widget.Revealer({ - transition: 'slide_down', - revealChild: revealInfoCondition, - child: Widget.Label({ - maxWidthChars: 10, // Doesn't matter what number - truncate: 'end', - className: `${xwayland ? 'txt txt-italic' : 'txt'}`, - css: ` - font-size: ${Math.min(SCREEN_WIDTH, SCREEN_HEIGHT) * userOptions.overview.scale / 14.6}px; - margin: 0px ${Math.min(SCREEN_WIDTH, SCREEN_HEIGHT) * userOptions.overview.scale / 10}px; - `, - // If the title is too short, include the class - label: (title.length <= 1 ? `${c}: ${title}` : title), - }) - }) - ] - }) - }), - tooltipText: `${c}: ${title}`, - setup: (button) => { - setupCursorHoverGrab(button); - - button.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, TARGET, Gdk.DragAction.MOVE); - button.drag_source_set_icon_name(substitute(c)); - // button.drag_source_set_icon_gicon(icon); - - button.connect('drag-begin', (button) => { // On drag start, add the dragging class - button.toggleClassName('overview-tasks-window-dragging', true); - }); - button.connect('drag-data-get', (_w, _c, data) => { // On drag finish, give address - data.set_text(address, address.length); - button.toggleClassName('overview-tasks-window-dragging', false); - }); - }, - }); - } - - const Workspace = (index) => { - // const fixed = Widget.Fixed({ - // attribute: { - // put: (widget, x, y) => { - // fixed.put(widget, x, y); - // }, - // move: (widget, x, y) => { - // fixed.move(widget, x, y); - // }, - // } - // }); - const fixed = Widget.Box({ - attribute: { - put: (widget, x, y) => { - if (!widget.attribute) return; - // Note: x and y are already multiplied by userOptions.overview.scale - const newCss = ` - margin-left: ${Math.round(x)}px; - margin-top: ${Math.round(y)}px; - margin-right: -${Math.round(x + (widget.attribute.w * userOptions.overview.scale))}px; - margin-bottom: -${Math.round(y + (widget.attribute.h * userOptions.overview.scale))}px; - `; - widget.css = newCss; - fixed.pack_start(widget, false, false, 0); - }, - move: (widget, x, y) => { - if (!widget) return; - if (!widget.attribute) return; - // Note: x and y are already multiplied by userOptions.overview.scale - const newCss = ` - margin-left: ${Math.round(x)}px; - margin-top: ${Math.round(y)}px; - margin-right: -${Math.round(x + (widget.attribute.w * userOptions.overview.scale))}px; - margin-bottom: -${Math.round(y + (widget.attribute.h * userOptions.overview.scale))}px; - `; - widget.css = newCss; - }, - } - }) - const WorkspaceNumber = ({ index, ...rest }) => Widget.Label({ - className: 'overview-tasks-workspace-number', - label: `${index}`, - css: ` - margin: ${Math.min(SCREEN_WIDTH, SCREEN_HEIGHT) * userOptions.overview.scale * userOptions.overview.wsNumMarginScale}px; - font-size: ${SCREEN_HEIGHT * userOptions.overview.scale * userOptions.overview.wsNumScale}px; - `, - setup: (self) => self.hook(Hyprland.active.workspace, (self) => { - // Update when going to new ws group - const currentGroup = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN); - self.label = `${currentGroup * NUM_OF_WORKSPACES_SHOWN + index}`; - }), - ...rest, - }) - const widget = Widget.Box({ - className: 'overview-tasks-workspace', - vpack: 'center', - css: ` - min-width: ${SCREEN_WIDTH * userOptions.overview.scale}px; - min-height: ${SCREEN_HEIGHT * userOptions.overview.scale}px; - `, - children: [Widget.EventBox({ - hexpand: true, - vexpand: true, - onPrimaryClick: () => { - App.closeWindow('overview'); - Utils.timeout(POPUP_CLOSE_TIME, () => Hyprland.messageAsync(`dispatch workspace ${index}`)); - }, - setup: (eventbox) => { - eventbox.drag_dest_set(Gtk.DestDefaults.ALL, TARGET, Gdk.DragAction.COPY); - eventbox.connect('drag-data-received', (_w, _c, _x, _y, data) => { - const offset = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN) * NUM_OF_WORKSPACES_SHOWN; - Hyprland.messageAsync(`dispatch movetoworkspacesilent ${index + offset},address:${data.get_text()}`) - overviewTick.setValue(!overviewTick.value); - }); - }, - child: Widget.Overlay({ - child: Widget.Box({}), - overlays: [ - WorkspaceNumber({ index: index, hpack: 'start', vpack: 'start' }), - fixed - ] - }), - })], - }); - const offset = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN) * NUM_OF_WORKSPACES_SHOWN; - fixed.attribute.put(WorkspaceNumber(offset + index), 0, 0); - widget.clear = () => { - const offset = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN) * NUM_OF_WORKSPACES_SHOWN; - clientMap.forEach((client, address) => { - if (!client) return; - if ((client.attribute.ws <= offset || client.attribute.ws > offset + NUM_OF_WORKSPACES_SHOWN) || - (client.attribute.ws == offset + index)) { - client.destroy(); - client = null; - clientMap.delete(address); - } - }); - } - widget.set = (clientJson, screenCoords) => { - let c = clientMap.get(clientJson.address); - if (c) { - if (c.attribute?.ws !== clientJson.workspace.id) { - c.destroy(); - c = null; - clientMap.delete(clientJson.address); - } - else if (c) { - c.attribute.w = clientJson.size[0]; - c.attribute.h = clientJson.size[1]; - c.attribute.updateIconSize(c); - fixed.attribute.move(c, - Math.max(0, clientJson.at[0] * userOptions.overview.scale), - Math.max(0, clientJson.at[1] * userOptions.overview.scale) - ); - return; - } - } - const newWindow = Window(clientJson, screenCoords); - if (newWindow === null) return; - // clientMap.set(clientJson.address, newWindow); - fixed.attribute.put(newWindow, - Math.max(0, newWindow.attribute.x * userOptions.overview.scale), - Math.max(0, newWindow.attribute.y * userOptions.overview.scale) - ); - clientMap.set(clientJson.address, newWindow); - }; - widget.unset = (clientAddress) => { - const offset = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN) * NUM_OF_WORKSPACES_SHOWN; - let c = clientMap.get(clientAddress); - if (!c) return; - c.destroy(); - c = null; - clientMap.delete(clientAddress); - }; - widget.show = () => { - fixed.show_all(); - } - return widget; - }; - - const arr = (s, n) => { - const array = []; - for (let i = 0; i < n; i++) - array.push(s + i); - - return array; - }; - - const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) => Widget.Box({ - children: arr(startWorkspace, workspaces).map(Workspace), - attribute: { - monitorMap: [], - getMonitorMap: (box) => { - execAsync('hyprctl -j monitors').then(monitors => { - box.attribute.monitorMap = JSON.parse(monitors).reduce((acc, item) => { - acc[item.id] = { x: item.x, y: item.y }; - return acc; - }, {}); - }); - }, - update: (box) => { - const offset = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN) * NUM_OF_WORKSPACES_SHOWN; - if (!App.getWindow(windowName).visible) return; - Hyprland.messageAsync('j/clients').then(clients => { - const allClients = JSON.parse(clients); - const kids = box.get_children(); - kids.forEach(kid => kid.clear()); - for (let i = 0; i < allClients.length; i++) { - const client = allClients[i]; - const childID = client.workspace.id - (offset + startWorkspace); - if (offset + startWorkspace <= client.workspace.id && - client.workspace.id <= offset + startWorkspace + workspaces) { - const screenCoords = box.attribute.monitorMap[client.monitor]; - if (kids[childID]) { - kids[childID].set(client, screenCoords); - } - continue; - } - } - kids.forEach(kid => kid.show()); - }).catch(print); - }, - updateWorkspace: (box, id) => { - const offset = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN) * NUM_OF_WORKSPACES_SHOWN; - if (!( // Not in range, ignore - offset + startWorkspace <= id && - id <= offset + startWorkspace + workspaces - )) return; - // if (!App.getWindow(windowName).visible) return; - Hyprland.messageAsync('j/clients').then(clients => { - const allClients = JSON.parse(clients); - const kids = box.get_children(); - for (let i = 0; i < allClients.length; i++) { - const client = allClients[i]; - if (client.workspace.id != id) continue; - const screenCoords = box.attribute.monitorMap[client.monitor]; - kids[id - (offset + startWorkspace)]?.set(client, screenCoords); - } - kids[id - (offset + startWorkspace)]?.show(); - }).catch(print); - }, - }, - setup: (box) => { - box.attribute.getMonitorMap(box); - box - .hook(overviewTick, (box) => box.attribute.update(box)) - .hook(Hyprland, (box, clientAddress) => { - const offset = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN) * NUM_OF_WORKSPACES_SHOWN; - const kids = box.get_children(); - const client = Hyprland.getClient(clientAddress); - if (!client) return; - const id = client.workspace.id; - - box.attribute.updateWorkspace(box, id); - kids[id - (offset + startWorkspace)]?.unset(clientAddress); - }, 'client-removed') - .hook(Hyprland, (box, clientAddress) => { - const client = Hyprland.getClient(clientAddress); - if (!client) return; - box.attribute.updateWorkspace(box, client.workspace.id); - }, 'client-added') - .hook(Hyprland.active.workspace, (box) => { - // Full update when going to new ws group - const previousGroup = box.attribute.workspaceGroup; - const currentGroup = Math.floor((Hyprland.active.workspace.id - 1) / NUM_OF_WORKSPACES_SHOWN); - if (currentGroup !== previousGroup) { - box.attribute.update(box); - box.attribute.workspaceGroup = currentGroup; - } - }) - .hook(App, (box, name, visible) => { // Update on open - if (name == 'overview' && visible) box.attribute.update(box); - }) - }, - }); - - return Widget.Revealer({ - revealChild: true, - transition: 'slide_down', - transitionDuration: userOptions.animations.durationLarge, - child: Widget.Box({ - vertical: true, - className: 'overview-tasks', - children: Array.from({ length: userOptions.overview.numOfRows }, (_, index) => - OverviewRow({ - startWorkspace: 1 + index * userOptions.overview.numOfCols, - workspaces: userOptions.overview.numOfCols, - }) - ) - }), - }); -} \ No newline at end of file diff --git a/config/ags/modules/overview/searchbuttons.js b/config/ags/modules/overview/searchbuttons.js deleted file mode 100644 index f5892f31..00000000 --- a/config/ags/modules/overview/searchbuttons.js +++ /dev/null @@ -1,163 +0,0 @@ -const { Gtk } = imports.gi; -import App from 'resource:///com/github/Aylur/ags/app.js'; -import Widget from 'resource:///com/github/Aylur/ags/widget.js'; -import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; -const { execAsync, exec } = Utils; -import { searchItem } from './searchitem.js'; -import { execAndClose, couldBeMath, launchCustomCommand } from './miscfunctions.js'; - -export const DirectoryButton = ({ parentPath, name, type, icon }) => { - const actionText = Widget.Revealer({ - revealChild: false, - transition: "crossfade", - transitionDuration: userOptions.animations.durationLarge, - child: Widget.Label({ - className: 'overview-search-results-txt txt txt-small txt-action', - label: 'Open', - }) - }); - const actionTextRevealer = Widget.Revealer({ - revealChild: false, - transition: "slide_left", - transitionDuration: userOptions.animations.durationSmall, - child: actionText, - }); - return Widget.Button({ - className: 'overview-search-result-btn', - onClicked: () => { - App.closeWindow('overview'); - execAsync(['bash', '-c', `xdg-open '${parentPath}/${name}'`, `&`]).catch(print); - }, - child: Widget.Box({ - children: [ - Widget.Box({ - vertical: false, - children: [ - Widget.Box({ - className: 'overview-search-results-icon', - homogeneous: true, - child: Widget.Icon({ - icon: icon, - }), - }), - Widget.Label({ - className: 'overview-search-results-txt txt txt-norm', - label: name, - }), - Widget.Box({ hexpand: true }), - actionTextRevealer, - ] - }) - ] - }), - setup: (self) => self - .on('focus-in-event', (button) => { - actionText.revealChild = true; - actionTextRevealer.revealChild = true; - }) - .on('focus-out-event', (button) => { - actionText.revealChild = false; - actionTextRevealer.revealChild = false; - }) - , - }) -} - -export const CalculationResultButton = ({ result, text }) => searchItem({ - materialIconName: '󱖦 ', - name: `Math result`, - actionName: "Copy", - content: `${result}`, - onActivate: () => { - App.closeWindow('overview'); - execAsync(['wl-copy', `${result}`]).catch(print); - }, -}); - -export const DesktopEntryButton = (app) => { - const actionText = Widget.Revealer({ - revealChild: false, - transition: "crossfade", - transitionDuration: userOptions.animations.durationLarge, - child: Widget.Label({ - className: 'overview-search-results-txt txt txt-small txt-action', - label: 'Launch', - }) - }); - const actionTextRevealer = Widget.Revealer({ - revealChild: false, - transition: "slide_left", - transitionDuration: userOptions.animations.durationSmall, - child: actionText, - }); - return Widget.Button({ - className: 'overview-search-result-btn', - onClicked: () => { - App.closeWindow('overview'); - app.launch(); - }, - child: Widget.Box({ - children: [ - Widget.Box({ - vertical: false, - children: [ - Widget.Box({ - className: 'overview-search-results-icon', - homogeneous: true, - child: Widget.Icon({ - icon: app.iconName, - }), - }), - Widget.Label({ - className: 'overview-search-results-txt txt txt-norm', - label: app.name, - }), - Widget.Box({ hexpand: true }), - actionTextRevealer, - ] - }) - ] - }), - setup: (self) => self - .on('focus-in-event', (button) => { - actionText.revealChild = true; - actionTextRevealer.revealChild = true; - }) - .on('focus-out-event', (button) => { - actionText.revealChild = false; - actionTextRevealer.revealChild = false; - }) - , - }) -} - -export const ExecuteCommandButton = ({ command, terminal = false }) => searchItem({ - materialIconName: `${terminal ? 'terminal' : ' '}`, - name: `Run command`, - actionName: `Execute ${terminal ? 'in terminal' : ''}`, - content: `${command}`, - onActivate: () => execAndClose(command, terminal), - extraClassName: 'techfont', -}) - -export const CustomCommandButton = ({ text = '' }) => searchItem({ - materialIconName: ' ', - name: 'Action', - actionName: 'Run', - content: `${text}`, - onActivate: () => { - App.closeWindow('overview'); - launchCustomCommand(text); - }, -}); - -export const SearchButton = ({ text = '' }) => searchItem({ - materialIconName: '󰜏 ', - name: 'Search the web', - actionName: 'Go', - content: `${text}`, - onActivate: () => { - App.closeWindow('overview'); - execAsync(['bash', '-c', `xdg-open '${userOptions.search.engineBaseUrl}${text} ${['', ...userOptions.search.excludedSites].join(' -site:')}' &`]).catch(print); - }, -}); \ No newline at end of file diff --git a/config/ags/modules/overview/searchitem.js b/config/ags/modules/overview/searchitem.js deleted file mode 100644 index 2a3303a4..00000000 --- a/config/ags/modules/overview/searchitem.js +++ /dev/null @@ -1,65 +0,0 @@ -import Widget from 'resource:///com/github/Aylur/ags/widget.js'; - -export const searchItem = ({ materialIconName, name, actionName, content, onActivate, extraClassName = '', ...rest }) => { - const actionText = Widget.Revealer({ - revealChild: false, - transition: "crossfade", - transitionDuration: userOptions.animations.durationLarge, - child: Widget.Label({ - className: 'overview-search-results-txt txt txt-small txt-action', - label: `${actionName}`, - }) - }); - const actionTextRevealer = Widget.Revealer({ - revealChild: false, - transition: "slide_left", - transitionDuration: userOptions.animations.durationSmall, - child: actionText, - }) - return Widget.Button({ - className: `overview-search-result-btn txt ${extraClassName}`, - onClicked: onActivate, - child: Widget.Box({ - children: [ - Widget.Box({ - vertical: false, - children: [ - Widget.Label({ - className: `icon-material overview-search-results-icon`, - label: `${materialIconName}`, - }), - Widget.Box({ - vertical: true, - children: [ - Widget.Label({ - hpack: 'start', - className: 'overview-search-results-txt txt-smallie txt-subtext', - label: `${name}`, - truncate: "end", - }), - Widget.Label({ - hpack: 'start', - className: 'overview-search-results-txt txt-norm', - label: `${content}`, - truncate: "end", - }), - ] - }), - Widget.Box({ hexpand: true }), - actionTextRevealer, - ], - }) - ] - }), - setup: (self) => self - .on('focus-in-event', (button) => { - actionText.revealChild = true; - actionTextRevealer.revealChild = true; - }) - .on('focus-out-event', (button) => { - actionText.revealChild = false; - actionTextRevealer.revealChild = false; - }) - , - }); -} diff --git a/config/ags/modules/overview/windowcontent.js b/config/ags/modules/overview/windowcontent.js deleted file mode 100644 index 7a19dd3c..00000000 --- a/config/ags/modules/overview/windowcontent.js +++ /dev/null @@ -1,262 +0,0 @@ -const { Gdk, Gtk } = imports.gi; -import App from 'resource:///com/github/Aylur/ags/app.js'; -import Widget from 'resource:///com/github/Aylur/ags/widget.js'; -import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; - -import Applications from 'resource:///com/github/Aylur/ags/service/applications.js'; -const { execAsync, exec } = Utils; -import { execAndClose, expandTilde, hasUnterminatedBackslash, couldBeMath, launchCustomCommand, ls } from './miscfunctions.js'; -import { - CalculationResultButton, CustomCommandButton, DirectoryButton, - DesktopEntryButton, ExecuteCommandButton, SearchButton -} from './searchbuttons.js'; -import { checkKeybind } from '../.widgetutils/keybind.js'; - -// Add math funcs -const { abs, sin, cos, tan, cot, asin, acos, atan, acot } = Math; -const pi = Math.PI; -// trigonometric funcs for deg -const sind = x => sin(x * pi / 180); -const cosd = x => cos(x * pi / 180); -const tand = x => tan(x * pi / 180); -const cotd = x => cot(x * pi / 180); -const asind = x => asin(x) * 180 / pi; -const acosd = x => acos(x) * 180 / pi; -const atand = x => atan(x) * 180 / pi; -const acotd = x => acot(x) * 180 / pi; - -const MAX_RESULTS = 10; -const OVERVIEW_SCALE = 0.18; // = overview workspace box / screen size -const OVERVIEW_WS_NUM_SCALE = 0.0; -const OVERVIEW_WS_NUM_MARGIN_SCALE = 0.07; -const TARGET = [Gtk.TargetEntry.new('text/plain', Gtk.TargetFlags.SAME_APP, 0)]; - -function iconExists(iconName) { - let iconTheme = Gtk.IconTheme.get_default(); - return iconTheme.has_icon(iconName); -} - -const OptionalOverview = async () => { - try { - return (await import('./overview_hyprland.js')).default(); - } catch { - return Widget.Box({}); - // return (await import('./overview_hyprland.js')).default(); - } -}; - -const overviewContent = await OptionalOverview(); - -export const SearchAndWindows = () => { - var _appSearchResults = []; - - const ClickToClose = ({ ...props }) => Widget.EventBox({ - ...props, - onPrimaryClick: () => App.closeWindow('overview'), - onSecondaryClick: () => App.closeWindow('overview'), - onMiddleClick: () => App.closeWindow('overview'), - }); - const resultsBox = Widget.Box({ - className: 'overview-search-results', - vertical: true, - vexpand: true, - }); - const resultsRevealer = Widget.Revealer({ - transitionDuration: userOptions.animations.durationLarge, - revealChild: false, - transition: 'slide_down', - // duration: 200, - hpack: 'center', - child: resultsBox, - }); - const entryPromptRevealer = Widget.Revealer({ - transition: 'crossfade', - transitionDuration: userOptions.animations.durationLarge, - revealChild: true, - hpack: 'center', - child: Widget.Label({ - className: 'overview-search-prompt txt-small txt', - label: 'Type to search' - }), - }); - - const entryIconRevealer = Widget.Revealer({ - transition: 'crossfade', - transitionDuration: userOptions.animations.durationLarge, - revealChild: false, - hpack: 'end', - child: Widget.Label({ - className: 'txt txt-large icon-material overview-search-icon', - label: ' ', - }), - }); - - const entryIcon = Widget.Box({ - className: 'overview-search-prompt-box', - setup: box => box.pack_start(entryIconRevealer, true, true, 0), - }); - - const entry = Widget.Entry({ - className: 'overview-search-box txt-small txt', - hpack: 'center', - onAccept: (self) => { // This is when you hit Enter - const text = self.text; - if (text.length == 0) return; - const isAction = text.startsWith('>'); - const isDir = (['/', '~'].includes(entry.text[0])); - - if (couldBeMath(text)) { // Eval on typing is dangerous, this is a workaround - try { - const fullResult = eval(text.replace(/\^/g, "**")); - // copy - execAsync(['wl-copy', `${fullResult}`]).catch(print); - App.closeWindow('overview'); - return; - } catch (e) { - // console.log(e); - } - } - if (isDir) { - App.closeWindow('overview'); - execAsync(['bash', '-c', `xdg-open "${expandTilde(text)}"`, `&`]).catch(print); - return; - } - if (_appSearchResults.length > 0) { - App.closeWindow('overview'); - _appSearchResults[0].launch(); - return; - } - else if (text[0] == '>') { // Custom commands - App.closeWindow('overview'); - launchCustomCommand(text); - return; - } - // Fallback: Execute command - if (!isAction && exec(`bash -c "command -v ${text.split(' ')[0]}"`) != '') { - if (text.startsWith('sudo')) - execAndClose(text, true); - else - execAndClose(text, false); - } - - else { - App.closeWindow('overview'); - execAsync(['bash', '-c', `xdg-open '${userOptions.search.engineBaseUrl}${text} ${['', ...userOptions.search.excludedSites].join(' -site:')}' &`]).catch(print); - } - }, - onChange: (entry) => { // this is when you type - const isAction = entry.text[0] == '>'; - const isDir = (['/', '~'].includes(entry.text[0])); - resultsBox.get_children().forEach(ch => ch.destroy()); - - // check empty if so then dont do stuff - if (entry.text == '') { - resultsRevealer.revealChild = false; - overviewContent.revealChild = true; - entryPromptRevealer.revealChild = true; - entryIconRevealer.revealChild = false; - entry.toggleClassName('overview-search-box-extended', false); - return; - } - const text = entry.text; - resultsRevealer.revealChild = true; - overviewContent.revealChild = false; - entryPromptRevealer.revealChild = false; - entryIconRevealer.revealChild = true; - entry.toggleClassName('overview-search-box-extended', true); - _appSearchResults = Applications.query(text); - - // Calculate - if (couldBeMath(text)) { // Eval on typing is dangerous; this is a small workaround. - try { - const fullResult = eval(text.replace(/\^/g, "**")); - resultsBox.add(CalculationResultButton({ result: fullResult, text: text })); - } catch (e) { - // console.log(e); - } - } - if (isDir) { - var contents = []; - contents = ls({ path: text, silent: true }); - contents.forEach((item) => { - resultsBox.add(DirectoryButton(item)); - }) - } - if (isAction) { // Eval on typing is dangerous, this is a workaround. - resultsBox.add(CustomCommandButton({ text: entry.text })); - } - // Add application entries - let appsToAdd = MAX_RESULTS; - _appSearchResults.forEach(app => { - if (appsToAdd == 0) return; - resultsBox.add(DesktopEntryButton(app)); - appsToAdd--; - }); - - // Fallbacks - // if the first word is an actual command - if (!isAction && !hasUnterminatedBackslash(text) && exec(`bash -c "command -v ${text.split(' ')[0]}"`) != '') { - resultsBox.add(ExecuteCommandButton({ command: entry.text, terminal: entry.text.startsWith('sudo') })); - } - - // Add fallback: search - resultsBox.add(SearchButton({ text: entry.text })); - resultsBox.show_all(); - }, - }); - return Widget.Box({ - vertical: true, - children: [ - ClickToClose({ // Top margin. Also works as a click-outside-to-close thing - child: Widget.Box({ - className: 'bar-height', - }) - }), - Widget.Box({ - hpack: 'center', - children: [ - entry, - Widget.Box({ - className: 'overview-search-icon-box', - setup: (box) => { - box.pack_start(entryPromptRevealer, true, true, 0) - }, - }), - entryIcon, - ] - }), - overviewContent, - resultsRevealer, - ], - setup: (self) => self - .hook(App, (_b, name, visible) => { - if (name == 'overview' && !visible) { - resultsBox.children = []; - entry.set_text(''); - } - }) - .on('key-press-event', (widget, event) => { // Typing - const keyval = event.get_keyval()[1]; - const modstate = event.get_state()[1]; - if (checkKeybind(event, userOptions.keybinds.overview.altMoveLeft)) - entry.set_position(Math.max(entry.get_position() - 1, 0)); - else if (checkKeybind(event, userOptions.keybinds.overview.altMoveRight)) - entry.set_position(Math.min(entry.get_position() + 1, entry.get_text().length)); - else if (checkKeybind(event, userOptions.keybinds.overview.deleteToEnd)) { - const text = entry.get_text(); - const pos = entry.get_position(); - const newText = text.slice(0, pos); - entry.set_text(newText); - entry.set_position(newText.length); - } - else if (!(modstate & Gdk.ModifierType.CONTROL_MASK)) { // Ctrl not held - if (keyval >= 32 && keyval <= 126 && widget != entry) { - Utils.timeout(1, () => entry.grab_focus()); - entry.set_text(entry.text + String.fromCharCode(keyval)); - entry.set_position(-1); - } - } - }) - , - }); -}; diff --git a/config/ags/services/brightness.js b/config/ags/services/brightness.js new file mode 100644 index 00000000..861a7e30 --- /dev/null +++ b/config/ags/services/brightness.js @@ -0,0 +1,71 @@ +import { bash, sh } from "../functions/utils.js"; + +const get = (args) => Number(Utils.exec(`brightnessctl ${args}`)); +const screen = await bash`ls -w1 /sys/class/backlight | head -1`; +const kbd = await bash`ls -w1 /sys/class/leds | head -1`; + +class Brightness extends Service { + static { + Service.register( + this, + {}, + { + screen: ["float", "rw"], + kbd: ["int", "rw"], + }, + ); + } + + #kbdMax = get(`--device ${kbd} max`); + #kbd = get(`--device ${kbd} get`); + #screenMax = get("max"); + #screen = get("get") / get("max"); + + get kbd() { + return this.#kbd; + } + get screen() { + return this.#screen; + } + + set kbd(value) { + if (value < 0 || value > this.#kbdMax) return; + + sh(`brightnessctl -d ${kbd} s ${value} -q`).then(() => { + this.#kbd = value; + this.changed("kbd"); + }); + } + + set screen(percent) { + if (percent < 0) percent = 0; + + if (percent > 1) percent = 1; + + sh(`brightnessctl set ${Math.floor(percent * 100)}% -q`).then(() => { + this.#screen = percent; + this.changed("screen"); + }); + } + + constructor() { + super(); + + const screenPath = `/sys/class/backlight/${screen}/brightness`; + const kbdPath = `/sys/class/leds/${kbd}/brightness`; + + Utils.monitorFile(screenPath, async (f) => { + const v = await Utils.readFileAsync(f); + this.#screen = Number(v) / this.#screenMax; + this.changed("screen"); + }); + + Utils.monitorFile(kbdPath, async (f) => { + const v = await Utils.readFileAsync(f); + this.#kbd = Number(v) / this.#kbdMax; + this.changed("kbd"); + }); + } +} + +export default new Brightness(); diff --git a/config/ags/services/configuration.js b/config/ags/services/configuration.js new file mode 100644 index 00000000..7403c8f6 --- /dev/null +++ b/config/ags/services/configuration.js @@ -0,0 +1,79 @@ +// @ts-nocheck +import { Variable as Var } from "resource:///com/github/Aylur/ags/variable.js"; +import { deepMerge } from "../functions/utils.js"; +import { replacePlaceholders, reverseReplace } from "../functions/utils.js"; +export const configPath = App.configDir + "/config.json"; + +class Conf extends Var { + static { + Service.register(this); + } + + constructor(key, callback = () => null, replaceData = {}) { + super(""); + const config = JSON.parse(Utils.readFile(configPath) || "{}"); + this.key = key; + this.replaceData = replaceData; + this.setValue( + replacePlaceholders( + this.key.includes(".") + ? this.#accessNestedJson(config, this.key) + : config[this.key], + this.replaceData, + ), + ); + this.connect("changed", callback); + } + + key = ""; + replaceData = {}; + + #accessNestedJson(data, keys) { + const keysArray = keys.split("."); + let result = data; + for (const key of keysArray) { + if (key in result) { + result = result[key]; + } else { + return null; + } + } + return result; + } + + #createNestedJson(key, newvalue) { + const keysarray = key.split("."); + let result = {}; + let temp = result; + for (let i = 0; i < keysarray.length - 1; i++) { + temp[keysarray[i]] = {}; + temp = temp[keysarray[i]]; + } + temp[keysarray[keysarray.length - 1]] = newvalue; + return result; + } + + updateValue(value) { + super.setValue(value); + let json = {}; + if (!this.key.includes(".")) { + json[this.key] = value; + } else { + json = this.#createNestedJson( + this.key, + reverseReplace(value, this.replaceData), + ); + } + this.#setConfig(json); + } + + #setConfig(value) { + const configs = JSON.parse(Utils.readFile(configPath) || "{}"); + + const updatedConfig = deepMerge(configs, value); + const configString = JSON.stringify(updatedConfig, null, 2); // this.#betterStringify(updatedConfig); + Utils.writeFile(configString, configPath); + } +} + +export default (keyz, call, replace) => new Conf(keyz, call, replace); diff --git a/config/ags/services/network_speed.js b/config/ags/services/network_speed.js new file mode 100644 index 00000000..51d288fc --- /dev/null +++ b/config/ags/services/network_speed.js @@ -0,0 +1,108 @@ +class NetworkSpeedService extends Service { + static { + Service.register( + this, + { + "upload-updated": ["float"], + "download-updated": ["float"], + }, + { + "upload-speed": ["float", "r"], + "download-speed": ["float", "r"], + interval: ["float", "rw"], + }, + ); + } + + #interval = 1000; + #lastTotalDownBytes = 0; + #lastTotalUpBytes = 0; + #downloadSpeed = 0; + #uploadSpeed = 0; + + get interval() { + return this.#interval; + } + + set interval(value) { + this.#interval = value; + } + + get download_speed() { + return this.#downloadSpeed; + } + + get upload_speed() { + return this.#uploadSpeed; + } + + constructor() { + super(); + + this.#onChange(); + } + + #onChange() { + Utils.interval(this.#interval, () => { + const content = Utils.exec("cat /proc/net/dev"); + const lines = content.split("\n"); + + // Caculate the sum of all interfaces' traffic line by line. + let totalDownBytes = 0; + let totalUpBytes = 0; + + for (let i = 0; i < lines.length; ++i) { + const fields = lines[i].trim().split(/\W+/); + if (fields.length <= 2) { + continue; + } + + // Skip virtual interfaces. + const interfce = fields[0]; + const currentInterfaceDownBytes = Number.parseInt(fields[1]); + const currentInterfaceUpBytes = Number.parseInt(fields[9]); + if ( + interfce === "lo" || + // Created by python-based bandwidth manager "traffictoll". + interfce.match(/^ifb[0-9]+/) || + // Created by lxd container manager. + interfce.match(/^lxdbr[0-9]+/) || + interfce.match(/^virbr[0-9]+/) || + interfce.match(/^br[0-9]+/) || + interfce.match(/^vnet[0-9]+/) || + interfce.match(/^tun[0-9]+/) || + interfce.match(/^tap[0-9]+/) || + isNaN(currentInterfaceDownBytes) || + isNaN(currentInterfaceUpBytes) + ) { + continue; + } + + totalDownBytes += currentInterfaceDownBytes; + totalUpBytes += currentInterfaceUpBytes; + } + + if (this.#lastTotalDownBytes === 0) { + this.#lastTotalDownBytes = totalDownBytes; + } + if (this.#lastTotalUpBytes === 0) { + this.#lastTotalUpBytes = totalUpBytes; + } + this.#downloadSpeed = + (totalDownBytes - this.#lastTotalDownBytes) / this.#interval; + this.#uploadSpeed = + (totalUpBytes - this.#lastTotalUpBytes) / this.#interval; + this.emit("changed"); + this.notify("download-speed"); + this.notify("upload-speed"); + this.emit("upload-updated", this.#uploadSpeed); + this.emit("download-updated", this.#downloadSpeed); + + this.#lastTotalDownBytes = totalDownBytes; + this.#lastTotalUpBytes = totalUpBytes; + }); + } +} +const service = new NetworkSpeedService(); + +export default service; diff --git a/config/ags/services/powermenu.js b/config/ags/services/powermenu.js new file mode 100644 index 00000000..bca6b7f5 --- /dev/null +++ b/config/ags/services/powermenu.js @@ -0,0 +1,54 @@ +const options = { + lock: "hyprlock", + sleep: "systemctl suspend", + reboot: "systemctl reboot", + logout: "pkill -u user", + shutdown: "shutdown now", +}; + +class PowerMenu extends Service { + static { + Service.register( + this, + {}, + { + title: ["string"], + cmd: ["string"], + }, + ); + } + + #title = ""; + #cmd = ""; + + get title() { + return this.#title; + } + + get cmd() { + return this.#cmd; + } + + action(action) { + [this.#cmd, this.#title] = { + lock: [options.lock, "Lock"], + sleep: [options.sleep, "Sleep"], + reboot: [options.reboot, "Reboot"], + logout: [options.logout, "Log Out"], + shutdown: [options.shutdown, "Shutdown"], + }[action]; + + this.notify("cmd"); + this.notify("title"); + this.emit("changed"); + App.closeWindow("powermenu__window"); + App.openWindow("verification__window"); + } + + // readonly shutdown = () => { + // this.action("shutdown") + // } +} + +const powermenu = new PowerMenu(); +export default powermenu; diff --git a/config/ags/services/screen_record.js b/config/ags/services/screen_record.js new file mode 100644 index 00000000..c44b5020 --- /dev/null +++ b/config/ags/services/screen_record.js @@ -0,0 +1,94 @@ +import GLib from "gi://GLib"; +import { sh, bash } from "../functions/utils.js"; + +const now = () => GLib.DateTime.new_now_local().format("%Y-%m-%d_%H-%M-%S"); + +class Recorder extends Service { + static { + Service.register( + this, + {}, + { + timer: ["int"], + recording: ["boolean"], + }, + ); + } + + #recordings = Utils.HOME + "/Videos/Screencasting"; + #screenshots = Utils.HOME + "/Pictures/Screenshots"; + #file = ""; + #interval = 0; + + recording = false; + timer = 0; + + async start() { + if (this.recording) return; + + Utils.ensureDirectory(this.#recordings); + this.#file = `${this.#recordings}/${now()}.mp4`; + sh( + `wf-recorder -g "${await sh("slurp")}" -f ${this.#file} --pixel-format yuv420p`, + ); + + this.recording = true; + this.changed("recording"); + + this.timer = 0; + this.#interval = Utils.interval(1000, () => { + this.changed("timer"); + this.timer++; + }); + } + + async stop() { + if (!this.recording) return; + + await bash("killall -INT wf-recorder"); + this.recording = false; + this.changed("recording"); + GLib.source_remove(this.#interval); + + Utils.notify({ + iconName: "video-x-generic-symbolic", + summary: "Screenrecord", + body: this.#file, + actions: { + "Show in Files": () => sh(`xdg-open ${this.#recordings}`), + View: () => sh(`xdg-open ${this.#file}`), + }, + }); + } + + async screenshot(full = false) { + const file = `${this.#screenshots}/${now()}.png`; + Utils.ensureDirectory(this.#screenshots); + + if (full) { + await sh(`grim ${file}`); + } else { + const size = await sh("slurp -b#00000066 -w 0"); + if (!size) return; + + await sh(`grim -g "${size}" ${file}`); + } + + bash(`wl-copy < ${file}`); + + Utils.notify({ + image: file, + summary: "Screenshot", + body: file, + actions: { + "Show in Files": () => sh(`xdg-open ${this.#screenshots}`), + View: () => sh(`xdg-open ${file}`), + Edit: () => sh(`swappy -f ${file}`), + }, + timeout: 5000, + }); + } +} +const service = new Recorder(); + +export default service; diff --git a/config/ags/style/colors.scss b/config/ags/style/colors.scss new file mode 100644 index 00000000..60d0756a --- /dev/null +++ b/config/ags/style/colors.scss @@ -0,0 +1,48 @@ +$background: #111318; +$error: #ffb4ab; +$error_container: #93000a; +$inverse_on_surface: #2e3035; +$inverse_primary: #3f5f90; +$inverse_surface: #e1e2e9; +$on_background: #e1e2e9; +$on_error: #690005; +$on_error_container: #ffdad6; +$on_primary: #06305f; +$on_primary_container: #d5e3ff; +$on_primary_fixed: #001b3c; +$on_primary_fixed_variant: #254777; +$on_secondary: #273141; +$on_secondary_container: #d9e3f8; +$on_secondary_fixed: #121c2b; +$on_secondary_fixed_variant: #3e4758; +$on_surface: #e1e2e9; +$on_surface_variant: #c4c6cf; +$on_tertiary: #3e2845; +$on_tertiary_container: #f8d8fe; +$on_tertiary_fixed: #28132f; +$on_tertiary_fixed_variant: #563e5d; +$outline: #8e9099; +$outline_variant: #43474e; +$primary: #a8c8ff; +$primary_container: #254777; +$primary_fixed: #d5e3ff; +$primary_fixed_dim: #a8c8ff; +$scrim: #000000; +$secondary: #bdc7dc; +$secondary_container: #bdc7dc; +$secondary_fixed: #d9e3f8; +$secondary_fixed_dim: #bdc7dc; +$shadow: #000000; +$surface: #111318; +$surface_bright: #37393e; +$surface_container: #1d2024; +$surface_container_high: #282a2f; +$surface_container_highest: #33353a; +$surface_container_low: #191c20; +$surface_container_lowest: #0c0e13; +$surface_dim: #111318; +$surface_variant: #43474e; +$tertiary: #dbbce1; +$tertiary_container: #563e5d; +$tertiary_fixed: #f8d8fe; +$tertiary_fixed_dim: #dbbce1; diff --git a/config/ags/style/common.scss b/config/ags/style/common.scss new file mode 100644 index 00000000..47caabad --- /dev/null +++ b/config/ags/style/common.scss @@ -0,0 +1,338 @@ +* { + all: unset; + font-size: 14px; + font-family: "Ubuntu Nerd Font"; +} + +.window-content { + margin: $window_margin; + box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3); + border-radius: $border-radius; + background-color: $background_color; + color: $on_background; + border: if($window_border, + 1px solid transparentize($on_background, 0.7), + none); +} + +.entry-box { + border-radius: $border_radius; + padding: 0px 8px; + min-height: 35px; + background-color: $primary; + color: $background; + font-weight: 600; + + image { + color: $background; + font-size: 16px; + } + + entry { + padding-left: 10px; + } +} + +scrolledwindow { + .item { + background-color: $on_secondary; + padding: 4px; + color: $on_background; + margin-left: 10px; + margin-right: 10px; + + image { + padding-right: 6px; + } + + &:last-child { + margin-bottom: 10px; + } + + .checkmark { + color: $primary; + } + + &:hover { + background-color: $primary_container; + } + + &:active { + background-color: transparent; + } + + &:focus { + background-color: $primary; + color: $background; + + label { + color: $background; + } + } + } +} + +button { + font-weight: 600; + border-radius: $border_radius; + box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4); + + &:hover { + background-color: $primary_container; + } +} + +.panel-button { + .panel-control-center { + &.empty { + color: transparentize($color: $on_background, $amount: 0.6); + } + } + + .panel-battery.charging { + color: $primary; + } + + &.active { + .panel-battery { + color: $background; + } + + .panel-control-center.empty { + color: $background; + } + } + + .timer.vert { + font-size: 12px; + } + + background-color: transparentize(if($dark_mode, $background, $on_secondary), + 1-$bar_button_opacity ); + color: $on_background; + padding: $panel_button_padding; + font-weight: 600; + // border-radius: divide-each($bar_border_radius, 1.5); + border-radius: $bar_button_border_radius; + // margin: $bar_padding; + // margin-top: nth($list: $bar_padding, $n: 1); + // margin-bottom: nth($list: $bar_padding, $n: 3); + box-shadow: if($bar_button_shadow, 1px 1px 2px rgba(0, 0, 0, 0.4), none); + + &:hover { + background-color: $primary_container; + } + + &.active { + background-color: $primary; + color: $background; + } +} + +.toggle-button { + background-color: $on_secondary; + color: $on_background; + box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4); + border-radius: divide-each($border_radius, 1.5); + + &:hover { + background-color: $primary_container; + } + + .icon { + margin-right: 8px; + } + + button { + box-shadow: unset; + border-radius: divide-each($border_radius, 1.5); + padding: 10px; + + &:first-child { + border-top-right-radius: 0px; + border-bottom-right-radius: 0px; + } + + &:last-child { + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; + } + + &:hover { + background-color: $primary_container; + } + } + + &.active { + background-color: $primary; + color: $background; + + button:hover { + background-color: transparent; + } + } +} + +.menu { + background-color: $on_secondary; + margin: 0px 10px; + min-width: 280px; + border-radius: $border_radius; + border-top-left-radius: 0px; + border-top-right-radius: 0px; + + .title-box { + margin: 10px; + margin-bottom: 8px; + + .icon { + margin-right: 6px; + } + + .title { + font-size: 15px; + font-weight: 600; + } + } + + .content.vertical { + margin: 8px 0px; + + >*:first-child>* { + image { + margin-right: 6px; + } + + &:first-child { + margin-top: 0px; + } + + &:last-child { + margin-bottom: 0px; + } + + margin: 3px 10px; + border: 1px solid transparentize($color: $on_background, $amount: 0.8); + box-shadow: unset; + padding: 6px; + border-radius: divide-each($border_radius, 2); + } + } +} + +separator { + min-height: 1px; + background-color: transparentize($color: $on_background, $amount: 0.8); +} + +scale { + border-radius: $border_radius; + box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4); + + trough { + background-color: transparentize($color: $on_secondary, $amount: 0.3); + + border-radius: $border_radius; + min-height: 20px; + + highlight { + background-color: $primary; + border-radius: $border_radius; + } + } +} + +scrollbar { + background-color: $on_secondary; + border-radius: divide-each($border_radius, 2); + + slider { + min-width: 6px; + border-radius: divide-each($border_radius, 2); + background-color: $primary; + } +} + +levelbar { + trough { + box-shadow: 1px 1px 2px transparentize($color: rgb(0, 0, 0), $amount: 0.7); + border-radius: $border_radius; + + block { + &:first-child { + border-radius: $border_radius; + border-top-right-radius: 0px; + border-bottom-right-radius: 0px; + } + + &:last-child { + border-radius: $border_radius; + border-top-left-radius: 0px; + border-bottom-left-radius: 0px; + } + + &.empty { + background-color: $on_secondary; + } + + &.filled { + background-color: $primary; + } + } + } +} + +menuitem { + background-color: $on_secondary; + border-radius: divide-each($border_radius, 1.6); + margin: 4px 6px; + padding: 4px 15px; + box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3); + + &:hover { + background-color: $primary_container; + } + + &:first-child { + margin-top: 6px; + } + + &:last-child { + margin-bottom: 6px; + } + + label { + font-size: 13px; + font-weight: 500; + } +} + +menu { + background-color: $background; + border-radius: divide-each($border_radius, 1.5); + color: $on_background; +} + +.splash-text { + font-size: 14px; + color: $on_background; + font-weight: 600; +} + +tooltip { + background-color: $background; + color: $on_background; + border-radius: divide-each($border_radius, 2); +} + +switch { + background-color: transparentize($color: $on_background, $amount: 0.8); + border-radius: $border_radius; + color: transparent; + + slider { + background-color: $primary; + border-radius: $border_radius; + min-width: 12px; + } +} diff --git a/config/ags/style/functions.scss b/config/ags/style/functions.scss new file mode 100644 index 00000000..4c71c140 --- /dev/null +++ b/config/ags/style/functions.scss @@ -0,0 +1,13 @@ +@function divide-each($value, $divider) { + $new-value: ( + ); + +@each $e in $value { + $new-value: append($new-value, $e / $divider); +} + +@return $new-value; +} + +//transparentize +$background_color: transparentize($background, 1-$window_opacity); diff --git a/config/ags/style/main.scss b/config/ags/style/main.scss new file mode 100644 index 00000000..3f02b9ce --- /dev/null +++ b/config/ags/style/main.scss @@ -0,0 +1,20 @@ +@import "./colors.scss"; +@import "./vars.scss"; +@import "./functions.scss"; +@import "./common.scss"; +@import "./widgets/applauncher.scss"; +@import "./widgets/audio-popup.scss"; +@import "./widgets/bar.scss"; +@import "./widgets/battery-popup.scss"; +@import "./widgets/control-center.scss"; +@import "./widgets/datemenu.scss"; +@import "./widgets/media.scss"; +@import "./widgets/systray.scss"; +@import "./widgets/network-popup.scss"; +@import "./widgets/network-speed.scss"; +@import "./widgets/notifications.scss"; +@import "./widgets/osd.scss"; +@import "./widgets/powermenu.scss"; +@import "./widgets/system-monitor.scss"; +@import "./widgets/wallpaper-picker.scss"; +@import "./widgets/workspaces.scss"; diff --git a/config/ags/style/vars.scss b/config/ags/style/vars.scss new file mode 100644 index 00000000..55ee92e7 --- /dev/null +++ b/config/ags/style/vars.scss @@ -0,0 +1,19 @@ +$window_margin: 12px 12px 6px 12px ; +$border_radius: 6px 6px 6px 6px ; +$bar_border_radius: 0px 0px 0px 0px ; +$bar_margin: 6px 3px 3px 3px ; +$workspace_active_width: 20px; +$dark_mode: true; +$osd_regular_margin: 0px 12px 60px 0px; +$osd_progress_margin: 12px 12px 2px 12px; +$bar_opacity: 0; +$bar_button_opacity: 0.6; +$panel_button_padding: 4px 8px 4px 8px; +$bar_padding: 3px 3px 3px 3px ; +$bar_shadow: false; +$bar_button_shadow: false; +$bar_button_border_radius: 6px 6px 6px 6px ; +$system_monitor_margin: 12px 12px 12px 12px; +$bar_border: false; +$window_opacity: 0.6; +$window_border: false; diff --git a/config/ags/style/widgets/applauncher.scss b/config/ags/style/widgets/applauncher.scss new file mode 100644 index 00000000..4ece135a --- /dev/null +++ b/config/ags/style/widgets/applauncher.scss @@ -0,0 +1,5 @@ +.applauncher__container { + .entry-box { + margin: 10px; + } +} diff --git a/config/ags/style/widgets/audio-popup.scss b/config/ags/style/widgets/audio-popup.scss new file mode 100644 index 00000000..ed3abd70 --- /dev/null +++ b/config/ags/style/widgets/audio-popup.scss @@ -0,0 +1,58 @@ +.audio__container { + padding: 5px; + + .volume { + margin: 5px; + } + + .microphone { + margin: 5px; + } + + .app-mixer { + scale { + margin-top: 4px; + + trough { + min-height: 10px; + } + } + } + + .menu { + min-width: 300px; + border-radius: $border_radius; + margin: 5px; + + .content.vertical { + >*:first-child>* { + &:last-child { + margin-bottom: 8px; + } + } + + >button { + image { + margin-right: 6px; + } + + margin: 8px 10px; + margin-bottom: 0px; + border: 1px solid transparentize($color: $on_background, $amount: 0.8); + box-shadow: unset; + padding: 6px; + border-radius: divide-each($border_radius, 2); + } + } + } + + .arrow { + padding: 3px; + border-radius: divide-each($border_radius, 2); + background-color: $on_secondary; + + &:hover { + background-color: $primary_container; + } + } +} diff --git a/config/ags/style/widgets/bar.scss b/config/ags/style/widgets/bar.scss new file mode 100644 index 00000000..e3953d2b --- /dev/null +++ b/config/ags/style/widgets/bar.scss @@ -0,0 +1,21 @@ +.bar__container { + background-color: transparentize($color: $background, + $amount: 1 - $bar_opacity ); + margin: $bar_margin; + border-radius: $bar_border_radius; + box-shadow: if($bar_shadow, 2px 2px 5px rgba(0, 0, 0, 0.3), none); + padding: $bar_padding; + border: if($bar_border, 1px solid transparentize($on_background, 0.7), none); + + .start { + .panel-button:first-child { + // margin-left: nth($list: $bar_padding, $n: 2); + } + } + + .end { + .panel-button:last-child { + // margin-right: nth($list: $bar_padding, $n: 4); + } + } +} diff --git a/config/ags/style/widgets/battery-popup.scss b/config/ags/style/widgets/battery-popup.scss new file mode 100644 index 00000000..6522838f --- /dev/null +++ b/config/ags/style/widgets/battery-popup.scss @@ -0,0 +1,52 @@ +.battery-popup__container { + min-width: 300px; + padding: 10px; + + .battery-info__container { + .percent { + font-size: 30px; + color: $on_primary; + font-weight: 600; + margin-left: 10px; + } + + levelbar { + trough { + min-height: 50px; + } + } + + .time-remaining { + color: $on_background; + font-size: 13px; + margin-top: 4px; + margin-bottom: 10px; + font-style: italic; + } + } + + .power-profile__container { + label { + font-size: 13px; + font-weight: 600; + margin-bottom: 6px; + } + + .item { + box-shadow: 1px 1px 2px transparentize($color: rgb(0, 0, 0), $amount: 0.7); + border-radius: divide-each($border_radius, 1.5); + color: $on_background; + background-color: $on_secondary; + min-height: 24px; + + &:hover { + background-color: $primary_container; + } + + &.active { + background-color: $primary; + color: $background; + } + } + } +} diff --git a/config/ags/style/widgets/control-center.scss b/config/ags/style/widgets/control-center.scss new file mode 100644 index 00000000..b19e5eaa --- /dev/null +++ b/config/ags/style/widgets/control-center.scss @@ -0,0 +1,90 @@ +.control-center__container { + .brightness-box { + padding: 10px; + } + + .notifications__container { + padding: 10px 0px; + + .placeholder { + image { + font-size: 24px; + } + + label { + margin-top: 6px; + font-size: 14px; + } + } + + .header { + padding: 0px 10px; + padding-right: 13px; + margin-bottom: 5px; + + label { + font-size: 18px; + font-weight: 600; + } + + button { + border-radius: divide-each($border_radius, 2); + background-color: $on_secondary; + padding: 10px; + + &:hover { + background-color: $primary_container; + } + } + } + + .notification { + margin: 5px 10px; + margin-right: 13px; + background-color: $on_secondary; + + .actions button { + background-color: transparentize($color: $on_background, $amount: 0.9); + + &:hover { + background-color: $primary_container; + } + } + + .content { + .description { + min-width: 235px; + } + } + } + } + + .qs-buttons { + padding: 10px; + + .qs-button { + background-color: $on_secondary; + color: $on_background; + padding: 6px 4px; + + &:active { + background-color: $primary; + color: $on_background; + } + + &:hover { + background-color: $primary_container; + } + + .label { + font-weight: 500; + font-size: 12px; + } + + &.active { + background-color: $primary; + color: $background; + } + } + } +} diff --git a/config/ags/style/widgets/datemenu.scss b/config/ags/style/widgets/datemenu.scss new file mode 100644 index 00000000..79349d73 --- /dev/null +++ b/config/ags/style/widgets/datemenu.scss @@ -0,0 +1,27 @@ +.datemenu__container { + padding: 10px; + + .clock { + font-size: 35px; + font-weight: 500; + } + + .date { + font-size: 18px; + font-weight: 400; + margin-bottom: 12px; + } + + calendar { + font-weight: 500; + border: unset; + border-radius: unset; + + &:selected { + background-color: $primary; + border-radius: 0; + color: $background; + border-radius: 6px; + } + } +} diff --git a/config/ags/style/widgets/media.scss b/config/ags/style/widgets/media.scss new file mode 100644 index 00000000..c813fbe2 --- /dev/null +++ b/config/ags/style/widgets/media.scss @@ -0,0 +1,46 @@ +.media__container { + .player { + margin-top: 0px; + padding: 10px; + + scale.position { + margin-bottom: 6px; + + trough { + min-height: 15px; + } + } + + .title { + font-size: 16px; + font-weight: 600; + } + + .artist { + font-size: 14px; + } + + .img { + min-width: 100px; + min-height: 100px; + background-size: cover; + background-position: center; + border-radius: $border_radius; + margin-right: 1em; + } + + .position { + font-weight: 600; + } + + .length { + font-weight: 600; + } + + button { + padding: 4px; + box-shadow: none; + border-radius: divide-each($border_radius, 2); + } + } +} diff --git a/config/ags/style/widgets/network-popup.scss b/config/ags/style/widgets/network-popup.scss new file mode 100644 index 00000000..2df99a1d --- /dev/null +++ b/config/ags/style/widgets/network-popup.scss @@ -0,0 +1,4 @@ +.network-info__container { + padding: 10px; + min-width: 350px; +} diff --git a/config/ags/style/widgets/network-speed.scss b/config/ags/style/widgets/network-speed.scss new file mode 100644 index 00000000..71b04de3 --- /dev/null +++ b/config/ags/style/widgets/network-speed.scss @@ -0,0 +1,17 @@ +.network-speed { + font-weight: 600; + // margin-left: 3px; + + .label { + font-size: 10px; + + &.vert { + font-size: 9px; + } + } + + .unit { + font-size: 8px; + margin-right: 3px; + } +} diff --git a/config/ags/style/widgets/notifications.scss b/config/ags/style/widgets/notifications.scss new file mode 100644 index 00000000..731c9793 --- /dev/null +++ b/config/ags/style/widgets/notifications.scss @@ -0,0 +1,85 @@ +.notification { + box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3); + margin: $window_margin; + margin-bottom: 6px; + border-radius: $border-radius; + background-color: $background_color; + color: $on_background; + + &:hover button.close-button { + background-color: $primary_container; + } + + &.critical { + box-shadow: 0.9em 0.9em $error; + } + + button.close-button { + box-shadow: unset; + margin-top: 0.2em; + margin-left: 0.5em; + min-width: 1.2em; + min-height: 1.2em; + + image { + font-size: 16px; + } + + &:hover { + background-color: $primary_container; + } + } + + .content { + margin: 0.7em; + + .title { + font-size: 15px; + font-weight: 600; + } + + .time { + font-size: 15px; + font-weight: 600; + color: transparentize($on_background, 0.2); + } + + .description { + min-width: 300px; + margin-top: 0.5em; + font-size: 0.9em; + font-style: italic; + color: transparentize($on_background, 0.2); + } + + .icon { + margin-right: 10px; + } + } +} + +.actions { + margin: 0.7em; + margin-bottom: 0.7em; + margin-top: 5px; + + button { + border-radius: divide-each($border_radius, 1.7); + padding: 4px; + margin: 0px 6px; + background-color: $background; + font-size: 1.2em; + + &:hover { + background-color: $primary_container; + } + + &:first-child { + margin-left: 0; + } + + &:last-child { + margin-right: 0; + } + } +} diff --git a/config/ags/style/widgets/osd.scss b/config/ags/style/widgets/osd.scss new file mode 100644 index 00000000..65fa8a2b --- /dev/null +++ b/config/ags/style/widgets/osd.scss @@ -0,0 +1,36 @@ +.osd { + background-color: $background_color; + border-radius: divide-each($border_radius, .5); + + &.regular { + box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3); + margin: $osd_regular_margin; + min-width: 90px; + padding: 8px; + color: $on_background; + + label { + font-weight: 600; + } + } + + &.progress { + box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3); + margin: $osd_progress_margin; + padding: 4px; + + .icon { + color: $background; + } + + .fill { + background-color: $primary; + border-radius: divide-each($border_radius, 1.5); + } + } + + .progress { + background-color: transparentize($color: $on_secondary, $amount: 0.3); + border-radius: divide-each($border_radius, 1.5); + } +} diff --git a/config/ags/style/widgets/powermenu.scss b/config/ags/style/widgets/powermenu.scss new file mode 100644 index 00000000..0c622496 --- /dev/null +++ b/config/ags/style/widgets/powermenu.scss @@ -0,0 +1,74 @@ +.powermenu__container { + padding: 10px; + + button { + background-color: $on_secondary; + + &:focus { + background-color: $primary; + color: $on_primary; + + &:hover { + background-color: $primary; + color: $primary_container; + } + } + + &:hover { + background-color: $primary_container; + } + + .system-button { + border-radius: $border_radius; + padding: 25px; + + image { + font-size: 50px; + } + + label { + margin-top: 6px; + } + } + } +} + +.verification__container { + padding: 10px; + + .text-box { + .title { + font-size: 28px; + font-weight: 600; + } + + .desc { + margin-top: 4px; + font-size: 18px; + font-weight: 500; + } + } + + .buttons { + margin-top: 10px; + + button { + background-color: $on_secondary; + padding: 10px 40px; + + &:focus { + background-color: $primary; + color: $on_primary; + + &:hover { + background-color: $primary; + color: $primary_container; + } + } + + &:hover { + background-color: $primary_container; + } + } + } +} diff --git a/config/ags/style/widgets/system-monitor.scss b/config/ags/style/widgets/system-monitor.scss new file mode 100644 index 00000000..f3d45192 --- /dev/null +++ b/config/ags/style/widgets/system-monitor.scss @@ -0,0 +1,89 @@ +.system-monitor__container { + padding: 10px; + padding-top: 0px; + min-width: 220px; + + border-radius: $border_radius; + margin: $system_monitor_margin; + + .day-dots { + .fill { + min-height: 15px; + min-width: 15px; + border-radius: divide-each($border_radius, 1.5); + background-color: $primary; + border: solid 1px $primary; + } + + .empty { + min-width: 15px; + min-height: 15px; + border-radius: divide-each($border_radius, 1.5); + border: solid 1px $primary; + } + } + + .day { + font-size: 50px; + font-family: "Roboto Condensed"; + font-weight: 600; + color: $primary; + margin-bottom: 8px; + } + + .day-number { + font-size: 30px; + font-family: "Roboto Condensed"; + font-weight: 600; + color: transparentize($color: $on_background, $amount: 0.2); + } + + .month { + font-size: 28px; + font-family: "Dancing Script"; + color: transparentize($color: $on_background, $amount: 0.2); + } + + .cpu-box { + min-width: 120px; + } + + .label { + font-size: 14px; + color: $on_background; + } + + separator { + min-height: 2px; + background-color: $primary; + } + + .value { + font-weight: 600; + font-size: 16px; + color: $on_background; + } + + .progress { + min-width: 55px; + min-height: 55px; + font-size: 8px; + margin: 4px; + background-color: $on_secondary; + color: $primary; + + box { + min-height: 55px; + min-width: 55px; + background-color: $on_secondary; + margin: 15px; + border-radius: 99px; + } + + image { + font-size: 16px; + // margin: 5px; + // margin-left: 6px; + } + } +} diff --git a/config/ags/style/widgets/systray.scss b/config/ags/style/widgets/systray.scss new file mode 100644 index 00000000..27a80494 --- /dev/null +++ b/config/ags/style/widgets/systray.scss @@ -0,0 +1,6 @@ +.systray__container { + .entry-box { + margin: 10px; + } +} + diff --git a/config/ags/style/widgets/wallpaper-picker.scss b/config/ags/style/widgets/wallpaper-picker.scss new file mode 100644 index 00000000..4c805536 --- /dev/null +++ b/config/ags/style/widgets/wallpaper-picker.scss @@ -0,0 +1,127 @@ +.wallpaper-picker__container { + .item { + padding: 10px; + } + + .entry-box { + margin: 10px; + margin-right: 0px; + } + + .path { + margin-left: 10px; + font-size: 12px; + font-style: italic; + } + + .folder-button { + background-color: $on_secondary; + padding: 0px 10px; + margin: 10px 0px; + margin-right: 10px; + + &:hover { + background-color: $primary_container; + } + } +} + +popover { + background-color: $background; + color: $on_background; + + >*>* { + padding: 6px; + } +} + +dialog { + background-color: $background_color; + color: $on_background; + + .dialog-action-box { + background-color: $background_color; + + button { + padding: 10px; + margin-right: 5px; + margin-left: 5px; + border: 1px solid $primary; + } + } + + scrolledwindow { + treeview { + padding: 6px; + color: $on_background; + + &:disabled { + color: transparentize($color: $on_background, $amount: 0.5); + } + + &:selected { + background-color: $primary; + color: $background; + } + + button { + // padding: 10px; + padding: 10px; + } + } + } + + #pathbarbox { + stack { + .popup.toggle { + padding: 10px; + } + + .linked.path-bar { + button { + background-color: transparentize($color: $background, $amount: 0.2); + border-left: 0.25px solid transparentize($color: $on_background, $amount: 0.8); + border-right: 0.25px solid transparentize($color: $on_background, $amount: 0.4); + color: $on_background; + padding: 10px; + + &:checked { + background-color: transparentize($color: $primary, $amount: 0.2); + color: $background; + } + + &:hover { + background-color: transparentize($color: $primary_container, + $amount: 0.3); + color: $on_background; + } + } + } + } + } + + placessidebar { + background-color: $background_color; + + row { + padding: 10px; + + &:selected { + background-color: $primary; + color: $background; + + &:hover { + color: $on_background; + } + } + + &:hover { + background-color: $primary_container; + } + + image { + padding-right: 10px; + } + } + } +} diff --git a/config/ags/style/widgets/workspaces.scss b/config/ags/style/widgets/workspaces.scss new file mode 100644 index 00000000..9ae34c73 --- /dev/null +++ b/config/ags/style/widgets/workspaces.scss @@ -0,0 +1,60 @@ +.workspace__container { + background-color: transparentize(if($dark_mode, $background, $on_secondary), + 1 - $bar_button_opacity ); + color: $on_background; + // margin-top: nth($list: $bar_padding, $n: 1); + // margin-bottom: nth($list: $bar_padding, $n: 3); + // margin-right: 3px; + border-radius: $bar_button_border_radius; + padding: $panel_button_padding; + box-shadow: if($bar_button_shadow, 1px 1px 2px rgba(0, 0, 0, 0.4), none); + + .workspace-button { + min-height: 10px; + min-width: 10px; + border: solid 2px $on_background; + border-radius: $bar_button_border_radius; + padding: 2px; + + .fill { + border-radius: divide-each($bar_button_border_radius, 2); + } + + &:hover { + border-color: $primary; + } + + &.active { + border-color: $primary; + + .fill { + &.hort { + min-width: $workspace_active_width; + } + + &.vert { + min-width: 0px; + min-height: $workspace_active_width; + } + } + } + + &.occupied { + &:hover { + .fill { + background-color: $primary; + } + } + + .fill { + background-color: $on_background; + } + + &.active { + .fill { + background-color: $primary; + } + } + } + } +} diff --git a/config/ags/user/style.css b/config/ags/user/style.css deleted file mode 100644 index 402bf22f..00000000 --- a/config/ags/user/style.css +++ /dev/null @@ -1,189 +0,0 @@ -*:not(popover) { - all: unset; -} - - -widget { - border-radius: 0.818rem; - -gtk-outline-radius: 0.818rem; -} - -.overview-window { - margin-top: 2.727rem; -} - -.overview-search-box { - transition: 300ms cubic-bezier(0, 0.55, 0.45, 1); - border-radius: 1.705rem; - -gtk-outline-radius: 1.705rem; - border-top: 1px solid #DB4740; - border-left: 1px solid #DB4740; - border-right: 1px solid #DB4740; - border-bottom: 1px solid #DB4740; - /* box-shadow: 0px 2px 3px alpha(@color0, 0.45); */ - margin: 0.476rem; - min-width: 13.636rem; - min-height: 3.409rem; - padding: 0rem 1.364rem; - padding-right: 2.864rem; - background-color: #000000; - color: @text-color; - caret-color: inherit; - font-weight: bolder; -} -.overview-search-box selection { - background-color: #000000; - color: #ffffff; -} - -.overview-search-box-extended { - min-width: 25.909rem; - caret-color: #FDD9FD; -} - -.overview-search-prompt { - color: #ffffff; -} - -.overview-search-icon { - margin: 0rem 1.023rem; -} - -.overview-search-prompt-box { - margin-left: -18.545rem; - margin-right: 0.544rem; -} - -.overview-search-icon-box { - margin-left: -18.545rem; - margin-right: 0.544rem; -} - -.overview-search-results { - border-radius: 1.705rem; - -gtk-outline-radius: 1.705rem; - border-top: 1px solid #DB4740; - border-left: 1px solid #DB4740; - border-right: 1px solid #DB4740; - border-bottom: 1px solid #DB4740; - box-shadow: 0px 2px 3px #DB4740; - margin: 0.476rem; - min-width: 28.773rem; - padding: 0.682rem; - background-color: #000000; - color: #ffffff; - font-weight: bold; -} - -.overview-search-results-icon { - margin: 0rem 0.682rem; - font-size: 2.386rem; - min-width: 2.386rem; - min-height: 2.386rem; -} - -.overview-search-results-txt { - margin-right: 0.682rem; -} - -.overview-search-results-txt-cmd { - margin-right: 0.682rem; - font-family: "JetBrains Mono NF", "JetBrains Mono Nerd Font", "JetBrains Mono NL", "SpaceMono NF", "SpaceMono Nerd Font", monospace; - font-size: 1.227rem; -} - -.overview-search-result-btn { - border-radius: 1.159rem; - -gtk-outline-radius: 1.159rem; - padding: 0.341rem; - min-width: 2.386rem; - min-height: 2.386rem; - caret-color: transparent; -} - -.overview-search-result-btn:hover, -.overview-search-result-btn:focus { - background-color: #3d3d3d; - color: #3d3d3d; -} - -.overview-search-result-btn:active { - background-color: #3d3d3d; - color: #9A7D7F; -} - -.overview-tasks { - border-radius: 1.705rem; - -gtk-outline-radius: 1.705rem; - border-top: 1px solid #DB4740; - border-left: 1px solid #DB4740; - border-right: 1px solid #DB4740; - border-bottom: 1px solid #DB4740; - box-shadow: 0px 2px 3px #A5857B; - margin: 0.476rem; - padding: 0.341rem; - /* background-color: rgba(49, 50, 68, 0.8); */ - background-color: #000000; - color: #EBDFED; -} - -.overview-tasks-workspace { - border-radius: 1.159rem; - -gtk-outline-radius: 1.159rem; - margin: 0.341rem; - background-color: transparent; - /*background-image: url('../../rofi/.current_wallpaper'); */ - background-size: cover; - background-position: center; - border: 0.068rem solid #9A7D7F; -} - -.overview-tasks-workspace-number { - font-family: "Open Sans", "Noto Sans", sans-serif; - color: #CFC2D3; -} - -.overview-tasks-window { - border-radius: 1.159rem; - -gtk-outline-radius: 1.159rem; - transition: 300ms cubic-bezier(0.1, 1, 0, 1); - background-color: transparent; - /* background-color: @color_a3; */ - /* background-color: rgba(46, 40, 50, 0.8); */ - color: #EBDFED; - border: 0.068rem solid #3d3d3d; -} - -.overview-tasks-window:hover, -.overview-tasks-window:focus { - background-color: #DB4740; -} - -.overview-tasks-window:active { - background-color: #DB4740; -} - -.overview-tasks-window-selected { - background-color: #DB4740; -} - -.overview-tasks-window-dragging { - opacity: 0.2; -} - -.growingRadial { - transition: 300ms cubic-bezier(0.2, 0, 0, 1); -} - -.fadingRadial { - transition: 50ms cubic-bezier(0.2, 0, 0, 1); -} - -.sidebar-pinned { - margin: 0rem; - border-radius: 0rem; - border-bottom-right-radius: 1.705rem; - border: 0rem solid; -} - -/*# sourceMappingURL=style.css.map */ diff --git a/config/ags/user_options.js b/config/ags/user_options.js deleted file mode 100644 index 9105decb..00000000 --- a/config/ags/user_options.js +++ /dev/null @@ -1,21 +0,0 @@ - -const userConfigOptions = { - // For every option, see ~/.config/ags/modules/.configuration/user_options.js - // (vscode users ctrl+click this: file://./modules/.configuration/user_options.js) - // (vim users: `:vsp` to split window, move cursor to this path, press `gf`. `Ctrl-w` twice to switch between) - // options listed in this file will override the default ones in the above file - // Here's an example - 'overview':{ - 'scale': 0.15, - 'numOfRows': 2 - }, - 'keybinds': { - 'sidebar': { - 'pin': "Ctrl+p", - 'nextTab': "Ctrl+Page_Down", - 'prevTab': "Ctrl+Page_Up", - }, - }, -} - -export default userConfigOptions; diff --git a/config/ags/variables.js b/config/ags/variables.js deleted file mode 100644 index ec4aedec..00000000 --- a/config/ags/variables.js +++ /dev/null @@ -1,21 +0,0 @@ -const { Gtk } = imports.gi; -import Variable from 'resource:///com/github/Aylur/ags/variable.js'; -import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; -const { exec, execAsync } = Utils; - -Gtk.IconTheme.get_default().append_search_path(`${App.configDir}/assets/icons`); - -// Screen size -export const SCREEN_WIDTH = Number(exec(`bash -c "xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1 | head -1" | awk '{print $1}'`)); -export const SCREEN_HEIGHT = Number(exec(`bash -c "xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f2 | head -1" | awk '{print $1}'`)); - -// Mode switching -export const currentShellMode = Variable('normal', {}) // normal, focus -globalThis['currentMode'] = currentShellMode; -globalThis['cycleMode'] = () => { - if (currentShellMode.value === 'normal') { - currentShellMode.value = 'focus'; - } else { - currentShellMode.value = 'normal'; - } -} diff --git a/config/ags/vars.js b/config/ags/vars.js new file mode 100644 index 00000000..d1664c6c --- /dev/null +++ b/config/ags/vars.js @@ -0,0 +1,200 @@ +import GLib from "gi://GLib"; +import Conf from "./services/configuration.js"; +import { cpWallpaper } from "./functions/wallpaper.js"; +import { setTheme } from "./functions/theme/init.js"; +import { setScssVariable } from "./functions/theme/ags.js"; +import { sendBatch } from "./functions/utils.js"; +import { setGapsOut } from "./functions/theme/hyprland.js"; +import { isVertical } from "./functions/utils.js"; +import setGtk from "./functions/theme/gtk.js"; + +export const HOME = Utils.HOME; + +export const clock = Variable(GLib.DateTime.new_now_local(), { + poll: [1000, () => GLib.DateTime.new_now_local()], +}); + +export const capsLockState = Variable( + Utils.exec(`brightnessctl -d input3::capslock g`), +); + +const divide = ([total, free]) => free / total; + +export const cpu = Variable(0, { + poll: [ + 2000, + "top -b -n 1", + (out) => + divide([ + 100, + out + .split("\n") + .find((line) => line.includes("Cpu(s)")) + .split(/\s+/)[1] + .replace(",", "."), + ]), + ], +}); + +export const ram = Variable(0, { + poll: [ + 2000, + "free", + (out) => + divide( + out + .split("\n") + .find((line) => line.includes("Mem:")) + .split(/\s+/) + .splice(1, 2), + ), + ], +}); + +export const configs = { + wallpaper: { + folder: Conf("wallpaper.folder", () => null, { home: HOME }), + current: Conf("wallpaper.current", (self) => { + cpWallpaper(self.value); + }), + }, + theme: { + dark_mode: Conf("theme.dark_mode", setTheme), + border_radius: Conf("theme.border_radius", (self) => { + setScssVariable({ + key: "border_radius", + value: self.value, + }); + sendBatch([`decoration:rounding ${self.value.split(",")[0].trim()}`]); + }), + window: { + margin: Conf("theme.window.margin", (self) => { + setScssVariable({ + key: "window_margin", + value: self.value, + }); + setGapsOut(); + }), + opacity: Conf("theme.window.opacity", (self) => { + setScssVariable({ + key: "window_opacity", + value: self.value, + need_format: false, + }); + setGtk(); + }), + border: Conf("theme.window.border", (self) => { + setScssVariable({ + key: "window_border", + value: self.value, + need_format: false, + }); + }), + }, + bar: { + position: Conf("theme.bar.position", (self) => { + sendBatch([ + ...App.windows.flatMap( + (win) => + `layerrule animation ${win.animation === "slide top" ? `slide ${self.value}` : win.animation}, ${win.name}`, + ), + `animation workspaces,1,7,menu_decel,${isVertical(self.value) ? `slidevert` : "slide"}`, + ]); + setGapsOut(); + setScssVariable({ bar_pos: self.value }); + }), + border: Conf("theme.bar.border", (self) => { + setScssVariable({ + key: "bar_border", + value: self.value, + need_format: false, + }); + }), + opacity: Conf("theme.bar.opacity", (self) => { + setScssVariable({ + key: "bar_opacity", + value: self.value, + need_format: false, + }); + }), + button_opacity: Conf("theme.bar.button_opacity", (self) => { + setScssVariable({ + key: "bar_button_opacity", + value: self.value, + need_format: false, + }); + }), + shadow: Conf("theme.bar.shadow", (self) => { + setScssVariable({ + key: "bar_shadow", + value: self.value, + need_format: false, + }); + }), + button_padding: Conf("theme.bar.button_padding", (self) => { + setScssVariable({ key: "panel_button_padding", value: self.value }); + }), + button_spacing: Conf("theme.bar.button_spacing"), + button_shadow: Conf("theme.bar.button_shadow", (self) => { + setScssVariable({ + key: "bar_button_shadow", + value: self.value, + need_format: false, + }); + }), + button_border_radius: Conf("theme.bar.button_border_radius", (self) => { + setScssVariable({ + key: "bar_button_border_radius", + value: self.value, + }); + }), + margin: Conf("theme.bar.margin", (self) => { + setScssVariable({ key: "bar_margin", value: self.value }); + }), + padding: Conf("theme.bar.padding", (self) => { + setScssVariable({ key: "bar_padding", value: self.value }); + }), + border_radius: Conf("theme.bar.border_radius", (self) => { + setScssVariable({ key: "bar_border_radius", value: self.value }); + }), + launcher_icon: Conf("theme.bar.launcher_icon"), + workspace_active_width: Conf( + "theme.bar.workspace_active_width", + (self) => { + setScssVariable({ + key: "workspace_active_width", + value: self.value, + need_format: true, + four_values: false, + }); + }, + ), + }, + }, + osd: { + regular: { + position: Conf("osd.regular.position"), + vertical: Conf("osd.regular.vertical"), + margin: Conf("osd.regular.margin", (self) => { + setScssVariable({ key: "osd_regular_margin", value: self.value }); + }), + capslock: Conf("osd.regular.capslock"), + mic: Conf("osd.regular.mic"), + }, + progress: { + position: Conf("osd.progress.position"), + vertical: Conf("osd.progress.vertical"), + margin: Conf("osd.progress.margin", (self) => { + setScssVariable({ key: "osd_progress_margin", value: self.value }); + }), + brightness: Conf("osd.progress.brightness"), + volume: Conf("osd.progress.volume"), + }, + }, + system_monitor: { + position: Conf("system_monitor.position"), + margin: Conf("system_monitor.margin", (self) => { + setScssVariable("system_monitor_margin", self.value); + }), + }, +}; diff --git a/config/ags/widget/FileChooserDialog.js b/config/ags/widget/FileChooserDialog.js new file mode 100644 index 00000000..69bdb7d9 --- /dev/null +++ b/config/ags/widget/FileChooserDialog.js @@ -0,0 +1,3 @@ +import Gtk from "gi://Gtk"; + +export default Widget.subclass(Gtk.FileChooserDialog); diff --git a/config/ags/widget/PanelButton.js b/config/ags/widget/PanelButton.js new file mode 100644 index 00000000..20055b97 --- /dev/null +++ b/config/ags/widget/PanelButton.js @@ -0,0 +1,27 @@ +export default ({ window = "", child, setup, ...rest }) => + Widget.Button({ + child: Widget.Box({ hpack: "center", child }), + setup: (self) => { + let open = false; + + self.toggleClassName("panel-button"); + self.toggleClassName(window); + + self.hook(App, (_, win, visible) => { + if (win !== window) return; + + if (open && !visible) { + open = false; + self.toggleClassName("active", false); + } + + if (visible) { + open = true; + self.toggleClassName("active"); + } + }); + + if (setup) setup(self); + }, + ...rest, + }); diff --git a/config/ags/widget/PopupWindow.js b/config/ags/widget/PopupWindow.js new file mode 100644 index 00000000..e75a6233 --- /dev/null +++ b/config/ags/widget/PopupWindow.js @@ -0,0 +1,141 @@ +export const Padding = (name) => + Widget.EventBox({ + hexpand: true, + vexpand: true, + can_focus: false, + child: Widget.Box({}), + setup: (w) => w.on("button-press-event", () => App.toggleWindow(name)), + }); + +const Layout = (name, child) => ({ + center: () => + Widget.CenterBox( + {}, + Padding(name), + Widget.CenterBox({ vertical: true }, Padding(name), child, Padding(name)), + Padding(name), + ), + top: () => + Widget.CenterBox( + {}, + Padding(name), + Widget.Box({ vertical: true }, child, Padding(name)), + Padding(name), + ), + right: () => + Widget.Box( + {}, + Padding(name), + Widget.Box( + { + hexpand: false, + vertical: true, + }, + child, + ), + ), + "top-right": () => + Widget.Box( + {}, + Padding(name), + Widget.Box( + { + hexpand: false, + vertical: true, + }, + child, + Padding(name), + ), + ), + "top-center": () => + Widget.Box( + {}, + Padding(name), + Widget.Box( + { + hexpand: false, + vertical: true, + }, + child, + Padding(name), + ), + Padding(name), + ), + "top-left": () => + Widget.Box( + {}, + Widget.Box( + { + hexpand: false, + vertical: true, + }, + child, + Padding(name), + ), + Padding(name), + ), + "bottom-left": () => + Widget.Box( + {}, + Widget.Box( + { + hexpand: false, + vertical: true, + }, + Padding(name), + child, + ), + Padding(name), + ), + "bottom-center": () => + Widget.Box( + {}, + Padding(name), + Widget.Box( + { + hexpand: false, + vertical: true, + }, + Padding(name), + child, + ), + Padding(name), + ), + "bottom-right": () => + Widget.Box( + {}, + Padding(name), + Widget.Box( + { + hexpand: false, + vertical: true, + }, + Padding(name), + child, + ), + ), +}); + +export default ({ + name, + child, + animation = "popin 80%", + layout = "center", + ...props +}) => { + const win = Widget.Window({ + name, + visible: false, + layer: "overlay", + keymode: "exclusive", + anchor: ["top", "bottom", "right", "left"], + child: Layout(name, child)[layout](), + setup: (w) => w.keybind("Escape", () => App.closeWindow(name)), + ...props, + }); + Object.assign(win, { + animation: animation, + }); + + return win; +}; diff --git a/config/ags/widget/ToggleButton.js b/config/ags/widget/ToggleButton.js new file mode 100644 index 00000000..8436ab6a --- /dev/null +++ b/config/ags/widget/ToggleButton.js @@ -0,0 +1,128 @@ +export const opened = Variable(""); + +export const Row = (toggles, menus) => + Widget.Box({ + vertical: true, + children: [ + Widget.Box({ + homogeneous: true, + class_name: "row horizontal", + spacing: 6, + children: toggles.map((w) => w()), + }), + ...menus.map((w) => w()), + ], + }); + +export const Arrow = (name, activate) => { + let deg = 0; + let iconOpened = false; + const icon = Widget.Icon("pan-end-symbolic").hook(opened, () => { + if ( + (opened.value === name && !iconOpened) || + (opened.value !== name && iconOpened) + ) { + const step = opened.value === name ? 10 : -10; + iconOpened = !iconOpened; + for (let i = 0; i < 9; ++i) { + Utils.timeout(15 * i, () => { + deg += step; + icon.setCss(`-gtk-icon-transform: rotate(${deg}deg);`); + }); + } + } + }); + + return Widget.Button({ + child: icon, + class_name: "arrow", + on_clicked: () => { + opened.value = opened.value === name ? "" : name; + if (typeof activate === "function") activate(); + }, + }); +}; + +export const ArrowToggleButton = ({ + name, + icon, + label, + activate, + deactivate, + activateOnArrow = true, + connection: [service, condition], +}) => + Widget.Box({ + class_name: "toggle-button", + setup: (self) => + self.hook(service, () => { + self.toggleClassName("active", condition()); + }), + children: [ + Widget.Button({ + child: Widget.Box({ + hexpand: true, + children: [ + Widget.Icon({ + class_name: "icon", + size: 18, + icon, + }), + Widget.Label({ + class_name: "label", + max_width_chars: 10, + truncate: "end", + label, + }), + ], + }), + on_clicked: () => { + if (condition()) { + deactivate(); + if (opened.value === name) opened.value = ""; + } else { + activate(); + } + }, + }), + Arrow(name, activateOnArrow && activate), + ], + }); + +export const Menu = ({ parentWindowName, name, icon, title, content }) => { + App.connect("window-toggled", (_, name, visible) => { + if (name === parentWindowName && !visible) + Utils.timeout(500, () => (opened.value = "")); + }); + + return Widget.Revealer({ + transition: "slide_down", + reveal_child: opened.bind().as((v) => v === name), + child: Widget.Box({ + class_names: ["menu", name], + vertical: true, + children: [ + Widget.Box({ + class_name: "title-box", + children: [ + Widget.Icon({ + class_name: "icon", + icon, + }), + Widget.Label({ + class_name: "title", + truncate: "end", + label: title, + }), + ], + }), + Widget.Separator(), + Widget.Box({ + vertical: true, + class_name: "content vertical", + children: content, + }), + ], + }), + }); +}; diff --git a/config/ags/widget/applauncher/PanelButton.js b/config/ags/widget/applauncher/PanelButton.js new file mode 100644 index 00000000..d7056c5f --- /dev/null +++ b/config/ags/widget/applauncher/PanelButton.js @@ -0,0 +1,28 @@ +import PanelButton from "../PanelButton.js"; +import { WINDOW_NAME } from "./Window.js"; +import { configs } from "../../vars.js"; + +export default () => + PanelButton({ + window: WINDOW_NAME, + on_clicked: () => { + App.toggleWindow(WINDOW_NAME); + }, + child: configs.theme.bar.launcher_icon.bind().as((icon) => { + const isGtkIcon = Utils.lookUpIcon(icon); + + if (isGtkIcon) { + return Widget.Icon({ + icon: icon, + hpack: "center", + xalign: 0, + }); + } else { + return Widget.Label({ + label: icon, + hpack: "center", + xalign: 0, + }); + } + }), + }); diff --git a/config/ags/widget/applauncher/Window.js b/config/ags/widget/applauncher/Window.js new file mode 100644 index 00000000..961a75b2 --- /dev/null +++ b/config/ags/widget/applauncher/Window.js @@ -0,0 +1,99 @@ +import PopupWindow from "../PopupWindow.js"; +const { query } = await Service.import("applications"); +export const WINDOW_NAME = "applauncher__window"; + +const AppItem = (app) => + Widget.Button({ + class_name: "item", + on_clicked: () => { + App.closeWindow(WINDOW_NAME); + app.launch(); + }, + attribute: { app }, + child: Widget.Box({ + children: [ + Widget.Icon({ + icon: app.icon_name || "", + size: 30, + }), + Widget.Label({ + class_name: "title", + label: app.name, + xalign: 0, + vpack: "center", + truncate: "end", + }), + ], + }), + }); + +const Container = ({ width = 500, height = 500, spacing = 12 }) => { + let applications = query("").map(AppItem); + + const list = Widget.Box({ + vertical: true, + children: applications, + spacing, + }); + + function repopulate() { + applications = query("").map(AppItem); + list.children = applications; + } + + const entry = Widget.Box({ + class_name: "entry-box", + children: [ + Widget.Icon({ icon: "search-symbolic" }), + Widget.Entry({ + hexpand: true, + on_accept: () => { + const results = applications.filter((item) => item.visible); + if (results[0]) { + App.toggleWindow(WINDOW_NAME); + results[0].attribute.app.launch(); + } + }, + on_change: ({ text }) => + applications.forEach((item) => { + item.visible = item.attribute.app.match(text ?? ""); + }), + setup: (self) => + self.hook(App, (_, windowName, visible) => { + if (windowName !== WINDOW_NAME) return; + if (visible) { + self.text = ""; + self.grab_focus(); + } + }), + }), + ], + }); + + return Widget.Box({ + vertical: true, + class_names: ["applauncher__container", "window-content"], + children: [ + entry, + Widget.Scrollable({ + hscroll: "never", + css: `min-width: ${width}px;` + `min-height: ${height}px;`, + child: list, + }), + ], + setup: (self) => + self.hook(App, (_, windowName, visible) => { + if (windowName !== WINDOW_NAME) return; + if (visible) { + repopulate(); + } + }), + }); +}; + +export default () => + PopupWindow({ + name: WINDOW_NAME, + animation: "popin 80%", + child: Container({ height: 350, width: 350 }), + }); diff --git a/config/ags/widget/audio/PanelButton.js b/config/ags/widget/audio/PanelButton.js new file mode 100644 index 00000000..4975dfa1 --- /dev/null +++ b/config/ags/widget/audio/PanelButton.js @@ -0,0 +1,34 @@ +import "../PanelButton.js"; +import PanelButton from "../PanelButton.js"; +import { WINDOW_NAME } from "./Window.js"; +const audio = await Service.import("audio"); + +const icons = { + muted: "audio-volume-muted-symbolic", + low: "audio-volume-low-symbolic", + medium: "audio-volume-medium-symbolic", + high: "audio-volume-high-symbolic", + overamplified: "audio-volume-overamplified-symbolic", +}; + +export default () => + PanelButton({ + window: WINDOW_NAME, + on_scroll_up: () => (audio.speaker.volume += 0.02), + on_scroll_down: () => (audio.speaker.volume -= 0.02), + on_clicked: () => { + App.toggleWindow(WINDOW_NAME); + }, + child: Widget.Icon().hook(audio.speaker, (self) => { + const vol = audio.speaker.is_muted ? 0 : audio.speaker.volume; + const { muted, low, medium, high, overamplified } = icons; + const cons = [ + [101, overamplified], + [67, high], + [34, medium], + [1, low], + [0, muted], + ]; + self.icon = cons.find(([n]) => n <= vol * 100)?.[1] || ""; + }), + }); diff --git a/config/ags/widget/audio/Window.js b/config/ags/widget/audio/Window.js new file mode 100644 index 00000000..55c4b08f --- /dev/null +++ b/config/ags/widget/audio/Window.js @@ -0,0 +1,190 @@ +import { icon, layoutPos, sh } from "../../functions/utils.js"; +import { configs } from "../../vars.js"; +import PopupWindow from "../PopupWindow.js"; +import { Arrow, Menu, Row } from "../ToggleButton.js"; +const audio = await Service.import("audio"); +const { bar } = configs.theme; + +export const WINDOW_NAME = "audio__window"; + +const VolumeIndicator = (type = "speaker") => + Widget.Icon({ + icon: audio[type] + .bind("icon_name") + .as((i) => icon(i || "", "microphone-sensitivity-high-symbolic")), + tooltipText: audio[type] + .bind("volume") + .as((vol) => `Volume: ${Math.floor(vol * 100)}%`), + size: 18, + }); + +const VolumeSlider = (type = "speaker") => + Widget.Slider({ + hexpand: true, + draw_value: false, + on_change: ({ value, dragging }) => { + if (dragging) { + audio[type].volume = value; + audio[type].is_muted = false; + } + }, + value: audio[type].bind("volume"), + class_name: audio[type].bind("is_muted").as((m) => (m ? "muted" : "")), + }); + +export const Volume = () => + Widget.Box({ + class_name: "volume", + spacing: 6, + children: [ + VolumeIndicator("speaker"), + VolumeSlider("speaker"), + Widget.Box({ + vpack: "center", + child: Arrow("sink-selector"), + }), + Widget.Box({ + vpack: "center", + child: Arrow("app-mixer"), + visible: audio.bind("apps").as((a) => a.length > 0), + }), + ], + }); + +export const Microphone = () => + Widget.Box({ + class_name: "microphone", + visible: audio.bind("recorders").as((a) => a.length > 0), + spacing: 6, + children: [VolumeIndicator("microphone"), VolumeSlider("microphone")], + }); + +const MixerItem = (stream) => + Widget.Box( + { + hexpand: true, + class_name: "mixer-item horizontal", + }, + Widget.Icon({ + tooltip_text: stream.bind("name").as((n) => n || ""), + icon: stream.bind("name").as((n) => { + return Utils.lookUpIcon(n || "") ? n || "" : "audio-x-generic-symbolic"; + }), + }), + Widget.Box( + { vertical: true }, + Widget.Label({ + xalign: 0, + truncate: "end", + max_width_chars: 18, + label: stream.bind("description").as((d) => d || ""), + }), + Widget.Slider({ + hexpand: true, + draw_value: false, + value: stream.bind("volume"), + on_change: ({ value }) => (stream.volume = value), + }), + ), + ); + +const SinkItem = (stream) => + Widget.Button({ + hexpand: true, + on_clicked: () => (audio.speaker = stream), + child: Widget.Box({ + children: [ + Widget.Icon({ + icon: icon(stream.icon_name || "", "audio-x-generic-symbolic"), + tooltip_text: stream.icon_name || "", + }), + Widget.Label( + (stream.description || "").split(" ").slice(0, 4).join(" "), + ), + Widget.Icon({ + icon: "audio-x-generic-symbolic", + hexpand: true, + hpack: "end", + visible: audio.speaker.bind("stream").as((s) => s === stream.stream), + }), + ], + }), + }); + +const SettingsButton = () => + Widget.Button({ + on_clicked: () => { + sh("pavucontrol"); + }, + hexpand: true, + child: Widget.Box({ + children: [ + Widget.Icon("emblem-system-symbolic"), + Widget.Label("Settings"), + ], + }), + }); + +export const AppMixer = () => + Menu({ + parentWindowName: WINDOW_NAME, + name: "app-mixer", + icon: "mixer-symbolic", + title: "App Mixer", + content: [ + Widget.Box({ + vertical: true, + class_name: "vertical mixer-item-box", + children: audio.bind("apps").as((a) => a.map(MixerItem)), + }), + Widget.Separator(), + SettingsButton(), + ], + }); + +export const SinkSelector = () => + Menu({ + name: "sink-selector", + parentWindowName: WINDOW_NAME, + icon: "audio-headphones-symbolic", + title: "Sink Selector", + content: [ + Widget.Box({ + vertical: true, + children: audio.bind("speakers").as((a) => a.map(SinkItem)), + }), + Widget.Separator(), + SettingsButton(), + ], + }); + +const Container = () => + Widget.Box({ + class_names: ["audio__container", "window-content"], + spacing: 8, + vertical: true, + children: [ + Row([Volume], [AppMixer, SinkSelector]), + Widget.Separator({ + visible: audio.bind("recorders").as((a) => a.length > 0), + }), + Microphone(), + ], + }); + +const AudioWindow = () => + PopupWindow({ + name: WINDOW_NAME, + animation: "slide top", + layout: layoutPos(bar.position.value, "top-right"), + child: Container(), + }); + +export default function() { + App.addWindow(AudioWindow()); + + bar.position.connect("changed", () => { + App.removeWindow(WINDOW_NAME); + App.addWindow(AudioWindow()); + }); +} diff --git a/config/ags/widget/bar/Window.js b/config/ags/widget/bar/Window.js new file mode 100644 index 00000000..eb8d791b --- /dev/null +++ b/config/ags/widget/bar/Window.js @@ -0,0 +1,127 @@ +import BatteryPanelButton from "../battery/PanelButton.js"; +import DatePanelButton from "../datemenu/PanelButton.js"; +import NetworkSpeedIndicator from "../network_speed/PanelButton.js"; +import AppLauncherPanelButton from "../applauncher/PanelButton.js"; +import WorkspacesPanelButton from "../workspaces/PanelButton.js"; +import ClientPanelButton from "../client/PanelButton.js"; +import ControlCenterPanelButton from "../control_center/PanelButton.js"; +import ScreenRecordPanelButton from "../screen_record/PanelButton.js"; +import NetworkPanelButton from "../network/PanelButton.js"; +import AudioPanelButton from "../audio/PanelButton.js"; +import { configs } from "../../vars.js"; +import { isVertical } from "../../functions/utils.js"; +const hyprland = await Service.import("hyprland"); + +const WINDOW_NAME = "bar__window"; + +const getAnchor = () => ({ + left: ["left", "top", "bottom"], + right: ["right", "top", "bottom"], + top: ["top", "left", "right"], + bottom: ["bottom", "left", "right"], +}); + +const startChildren = () => [ + AppLauncherPanelButton(), + DatePanelButton(), + WorkspacesPanelButton(), +]; + +const start = () => + Widget.Box({ + class_name: "start", + spacing: configs.theme.bar.button_spacing.bind(), + vertical: configs.theme.bar.position.bind().as(isVertical), + // vpack: configs.theme.bar.position + // .bind() + // .as((pos) => (pos === "left" ? "end" : "fill")), + vexpand: true, + + // children: configs.theme.bar.position + // .bind() + // .as((pos) => + // pos === "left" ? startChildren().reverse() : startChildren(), + // ), + children: startChildren(), + }); + +const center = () => + Widget.Box({ + children: [ClientPanelButton()], + vertical: configs.theme.bar.position.bind().as(isVertical), + }); + +const endChildren = () => [ + ScreenRecordPanelButton(), + NetworkSpeedIndicator(), + NetworkPanelButton(), + AudioPanelButton(), + BatteryPanelButton(), + ControlCenterPanelButton(), +]; + +const end = () => + Widget.Box({ + class_name: "end", + spacing: configs.theme.bar.button_spacing.bind(), + hpack: "end", + // vpack: configs.theme.bar.position + // .bind() + // .as((pos) => (pos === "left" ? "start" : "end")), + vpack: "end", + vertical: configs.theme.bar.position.bind().as(isVertical), + children: endChildren(), + // children: configs.theme.bar.position + // .bind() + // .as((pos) => (pos === "left" ? endChildren().reverse() : endChildren())), + }); + +const BarWindow = () => { + const win = Widget.Window({ + name: "bar__window", + exclusivity: "exclusive", + visible: false, + anchor: configs.theme.bar.position.bind().as((pos) => getAnchor()[pos]), + // anchor, + child: Widget.CenterBox({ + vertical: configs.theme.bar.position.bind().as(isVertical), + class_names: ["bar__container", "window-content"], + start_widget: start(), + // start_widget: configs.theme.bar.position + // .bind() + // .as((p) => (p === "left" ? end() : start())), + center_widget: center(), + // end_widget: configs.theme.bar.position + // .bind() + // .as((p) => (p === "left" ? start() : end())), + end_widget: end(), + }), + }); + + Object.assign(win, { + animation: `slide`, + }); + + return win; +}; + +export default function() { + App.addWindow(BarWindow()); + Utils.timeout(100, () => { + App.openWindow(WINDOW_NAME); + }); + + configs.theme.bar.position.connect("changed", (self) => { + App.toggleWindow(WINDOW_NAME); + Utils.timeout(300, () => { + App.removeWindow(WINDOW_NAME); + App.addWindow(BarWindow()); + Utils.timeout(100, () => { + hyprland.message( + `keyword layerrule animation slide ${self.value}, ${WINDOW_NAME}`, + ); + App.openWindow(WINDOW_NAME); + }); + }); + }); +} diff --git a/config/ags/widget/battery/PanelButton.js b/config/ags/widget/battery/PanelButton.js new file mode 100644 index 00000000..ba81065d --- /dev/null +++ b/config/ags/widget/battery/PanelButton.js @@ -0,0 +1,32 @@ +import { isVertical } from "../../functions/utils.js"; +import { configs } from "../../vars.js"; +import PanelButton from "../PanelButton.js"; +import { WINDOW_NAME } from "./Window.js"; +const battery = await Service.import("battery"); + +export default () => + PanelButton({ + window: WINDOW_NAME, + on_clicked: () => { + App.toggleWindow(WINDOW_NAME); + }, + child: Widget.Box({ + class_name: "panel-battery", + vertical: configs.theme.bar.position.bind().as(isVertical), + setup: (self) => { + self.hook(battery, () => { + self.toggleClassName("charging", battery.charging); + }); + }, + spacing: 4, + children: [ + Widget.Icon({ + icon: battery.bind("icon_name"), + }), + Widget.Label({ + label: battery.bind("percent").as((p) => `${Math.round(p)}%`), + visible: battery.bind("charging"), + }), + ], + }), + }); diff --git a/config/ags/widget/battery/Window.js b/config/ags/widget/battery/Window.js new file mode 100644 index 00000000..69021fc1 --- /dev/null +++ b/config/ags/widget/battery/Window.js @@ -0,0 +1,146 @@ +import { layoutPos } from "../../functions/utils.js"; +import { configs } from "../../vars.js"; +import PopupWindow from "../PopupWindow.js"; + +const powerProfiles = await Service.import("powerprofiles"); +const battery = await Service.import("battery"); +export const WINDOW_NAME = "battery__window"; +const { bar } = configs.theme; + +function formatTimeUntilCharged(seconds) { + const hours = Math.floor(seconds / 3600); + const minutes = Math.floor((seconds % 3600) / 60); + + let result = ""; + if (hours > 0) { + result += hours + " hour"; + if (hours > 1) result += "s"; + } + if (minutes > 0) { + if (result !== "") result += " "; + result += minutes + " minute"; + if (minutes > 1) result += "s"; + } + + return result; +} +const TimeRemaining = () => + Widget.Label({ + class_name: "time-remaining", + hpack: "start", + label: Utils.merge( + [battery.bind("time-remaining"), battery.bind("charging")], + (tr, charging) => { + const hoursMinutes = formatTimeUntilCharged(tr); + + if (charging) { + return hoursMinutes === "" + ? "Charging..." + : `${hoursMinutes} until fully charged`; + } else { + return hoursMinutes === "" + ? "Not charging" + : `About ${hoursMinutes} left`; + } + }, + ), + }); + +const Item = (profile) => + Widget.Button({ + class_name: "item", + on_clicked: () => { + powerProfiles.active_profile = profile; + }, + setup: (self) => { + self.hook(powerProfiles, (btn) => { + btn.toggleClassName("active", powerProfiles.active_profile == profile); + }); + }, + child: Widget.Box({ + hexpand: true, + spacing: 6, + vpack: "center", + hpack: "center", + children: [ + Widget.Icon({ icon: `power-profile-${profile}-symbolic`, size: 16 }), + ], + }), + }); + +const PowerProfileContainer = () => + Widget.Box({ + vertical: true, + class_name: "power-profile__container", + children: [ + Widget.Label({ + hpack: "start", + label: "Power Profile", + }), + Widget.Box({ + spacing: 6, + vertical: false, + homogeneous: true, + setup: (self) => { + self.hook(powerProfiles, (box) => { + box.children = powerProfiles.profiles.map((profile) => + Item(profile.Profile), + ); + }); + }, + }), + ], + }); + +const PercentLabel = () => + Widget.Box({ + halign: "start", + children: [ + Widget.Label({ + class_name: "percent", + label: battery.bind("percent").as((p) => `${Math.round(p)}%`), + }), + ], + }); + +const LevelBar = () => + Widget.Overlay({ + child: Widget.LevelBar({ + bar_mode: "discrete", + max_value: 10, + value: battery.bind("percent").as((p) => p / 10), + }), + overlays: [PercentLabel()], + }); + +const BatteryInfo = () => + Widget.Box({ + class_name: "battery-info__container", + vertical: true, + children: [LevelBar(), TimeRemaining()], + }); + +const Container = () => + Widget.Box({ + class_names: ["battery-popup__container", "window-content"], + vertical: true, + hexpand: false, + children: [BatteryInfo(), PowerProfileContainer()], + }); + +const BatteryWindow = () => + PopupWindow({ + name: WINDOW_NAME, + animation: "slide top", + layout: layoutPos(bar.position.value, "top-right"), + child: Container(), + }); + +export default function() { + App.addWindow(BatteryWindow()); + + bar.position.connect("changed", () => { + App.removeWindow(WINDOW_NAME); + App.addWindow(BatteryWindow()); + }); +} diff --git a/config/ags/widget/client/PanelButton.js b/config/ags/widget/client/PanelButton.js new file mode 100644 index 00000000..5817d84b --- /dev/null +++ b/config/ags/widget/client/PanelButton.js @@ -0,0 +1,46 @@ +import { icon } from "../../functions/utils.js"; +import { configs } from "../../vars.js"; +import PanelButton from "../PanelButton.js"; + +const hyprland = await Service.import("hyprland"); +const apps = await Service.import("applications"); + +const ClientIcon = () => + Widget.Icon({ + icon: hyprland.active.bind("client").as((client) => { + const app = apps.list.find((app) => app.match(client.class)); + return icon( + (client.class === "" ? "desktop" : app?.icon_name) + "-symbolic", + app?.icon_name, + ); + }), + }); + +export default () => + PanelButton({ + tooltip_text: hyprland.active.client + .bind("class") + .as((v) => (v === "" ? "Desktop" : v)), + child: Widget.Box({ + spacing: 4, + vpack: "center", + children: [ + ClientIcon(), + Widget.Label({ + vpack: "center", + label: hyprland.active.client + .bind("title") + .as((t) => + t === "" + ? "Desktop" + : t.includes("Mozilla") + ? "Mozilla Firefox" + : t, + ), + visible: configs.theme.bar.position + .bind() + .as((p) => (p !== "left") & (p !== "right")), + }), + ], + }), + }); diff --git a/config/ags/widget/control_center/Brightness.js b/config/ags/widget/control_center/Brightness.js new file mode 100644 index 00000000..60507aba --- /dev/null +++ b/config/ags/widget/control_center/Brightness.js @@ -0,0 +1,18 @@ +import brightness from "../../services/brightness.js"; + +export default () => + Widget.Box({ + spacing: 6, + vpack: "center", + class_name: "brightness-box", + children: [ + Widget.Icon({ icon: "display-brightness-symbolic", size: 18 }), + Widget.Slider({ + draw_value: false, + hexpand: true, + min: 0.1, + value: brightness.bind("screen"), + on_change: ({ value }) => (brightness.screen = value), + }), + ], + }); diff --git a/config/ags/widget/control_center/Media.js b/config/ags/widget/control_center/Media.js new file mode 100644 index 00000000..32543439 --- /dev/null +++ b/config/ags/widget/control_center/Media.js @@ -0,0 +1,153 @@ +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"; + +function lengthStr(length) { + const min = Math.floor(length / 60); + const sec = Math.floor(length % 60); + const sec0 = sec < 10 ? "0" : ""; + return `${min}:${sec0}${sec}`; +} + +const Player = (player) => { + const img = Widget.Box({ + class_name: "img", + vpack: "start", + css: player.bind("cover_path").transform( + (p) => ` + background-image: url('${p}'); + `, + ), + }); + + const title = Widget.Label({ + class_name: "title", + wrap: true, + max_width_chars: 20, + truncate: "end", + hpack: "start", + label: player.bind("track_title"), + }); + + const artist = Widget.Label({ + class_name: "artist", + wrap: true, + hpack: "start", + label: player.bind("track_artists").transform((a) => a.join(", ")), + }); + + const positionSlider = Widget.Slider({ + class_name: "position", + draw_value: false, + on_change: ({ value }) => (player.position = value * player.length), + visible: player.bind("length").as((l) => l > 0), + hexpand: false, + setup: (self) => { + function update() { + const value = player.position / player.length; + self.value = value > 0 ? value : 0; + } + self.hook(player, update); + self.hook(player, update, "position"); + self.poll(1000, update); + }, + }); + + const positionLabel = Widget.Label({ + class_name: "position", + hpack: "start", + setup: (self) => { + const update = (_, time) => { + self.label = lengthStr(time || player.position); + self.visible = player.length > 0; + }; + + self.hook(player, update, "position"); + self.poll(1000, update); + }, + }); + + const lengthLabel = Widget.Label({ + class_name: "length", + hpack: "end", + visible: player.bind("length").transform((l) => l > 0), + label: player.bind("length").transform(lengthStr), + }); + + const icon = Widget.Icon({ + class_name: "icon", + hexpand: true, + hpack: "end", + vpack: "start", + tooltip_text: player.identity || "", + icon: player.bind("entry").transform((entry) => { + const name = `${entry}-symbolic`; + return Utils.lookUpIcon(name) ? name : FALLBACK_ICON; + }), + }); + + const playPause = Widget.Button({ + class_name: "play-pause", + on_clicked: () => player.playPause(), + visible: player.bind("can_play"), + child: Widget.Icon({ + icon: player.bind("play_back_status").transform((s) => { + switch (s) { + case "Playing": + return PAUSE_ICON; + case "Paused": + case "Stopped": + return PLAY_ICON; + } + }), + }), + }); + + const prev = Widget.Button({ + on_clicked: () => player.previous(), + visible: player.bind("can_go_prev"), + child: Widget.Icon(PREV_ICON), + }); + + const next = Widget.Button({ + on_clicked: () => player.next(), + visible: player.bind("can_go_next"), + child: Widget.Icon(NEXT_ICON), + }); + + return Widget.Box( + { class_names: ["player", "window-content"] }, + img, + Widget.Box( + { + vertical: true, + hexpand: true, + }, + Widget.Box([title, icon]), + artist, + Widget.Box({ vexpand: true }), + positionSlider, + Widget.CenterBox({ + start_widget: positionLabel, + center_widget: Widget.Box([prev, playPause, next]), + end_widget: lengthLabel, + }), + ), + ); +}; + +export function Media() { + return Widget.Box({ + vertical: true, + class_name: "media__container", + css: "min-height: 2px; min-width: 2px;", // small hack to make it visible + vexpand: false, + visible: players.as((p) => p.length > 0), + children: players.as((p) => p.map(Player)), + }); +} diff --git a/config/ags/widget/control_center/Notifications.js b/config/ags/widget/control_center/Notifications.js new file mode 100644 index 00000000..645bdf05 --- /dev/null +++ b/config/ags/widget/control_center/Notifications.js @@ -0,0 +1,109 @@ +import Notification from "../notifications/notifications.js"; + +const notifications = await Service.import("notifications"); +const notifs = notifications.bind("notifications"); + +const Animated = (n) => + Widget.Revealer({ + transition_duration: 200, + transition: "slide_left", + child: Notification(n), + setup: (self) => + Utils.timeout(200, () => { + if (!self.is_destroyed) self.reveal_child = true; + }), + }); + +const ClearButton = () => + Widget.Button({ + onClicked: () => notifications.clear(), + child: Widget.Icon({ + icon: notifications + .bind("notifications") + .as((n) => `user-trash-${n.length > 0 ? "full-" : ""}symbolic`), + }), + }); + +const Header = () => + Widget.Box({ + class_name: "header", + children: [ + Widget.Label({ label: "Notifications", xalign: 0, hexpand: true }), + ClearButton(), + ], + }); + +const NotificationList = () => { + const map = new Map(); + const box = Widget.Box({ + vertical: true, + children: notifications.notifications.map((n) => { + const w = Animated(n); + map.set(n.id, w); + return w; + }), + visible: notifs.as((n) => n.length > 0), + }); + + function remove(_, id) { + const n = map.get(id); + if (n) { + n.reveal_child = false; + Utils.timeout(200, () => { + n.destroy(); + map.delete(id); + }); + } + } + + return box.hook(notifications, remove, "closed").hook( + notifications, + (_, id) => { + if (id !== undefined) { + if (map.has(id)) remove(null, id); + + const n = notifications.getNotification(id); + + const w = Animated(n); + map.set(id, w); + box.children = [w, ...box.children]; + } + }, + "notified", + ); +}; + +const Placeholder = () => + Widget.Box({ + class_name: "placeholder", + vertical: true, + vpack: "center", + hpack: "center", + vexpand: true, + hexpand: true, + visible: notifs.as((n) => n.length === 0), + children: [ + Widget.Icon("notifications-disabled-symbolic"), + Widget.Label("Your inbox is empty"), + ], + }); + +export default ({ width = 250, height = 100 }) => + Widget.Box({ + class_name: "notifications__container", + css: `min-width: ${width}px; min-height: ${height}px;`, + vertical: true, + children: [ + Header(), + Widget.Scrollable({ + vexpand: true, + hscroll: "never", + class_name: "notification-scrollable", + child: Widget.Box({ + class_name: "notification-list vertical", + vertical: true, + children: [NotificationList(), Placeholder()], + }), + }), + ], + }); diff --git a/config/ags/widget/control_center/PanelButton.js b/config/ags/widget/control_center/PanelButton.js new file mode 100644 index 00000000..86d94cea --- /dev/null +++ b/config/ags/widget/control_center/PanelButton.js @@ -0,0 +1,25 @@ +import PanelButton from "../PanelButton.js"; +import { WINDOW_NAME } from "./Window.js"; +const notifications = await Service.import("notifications"); + +const NotificationIcon = () => + Widget.Icon({ + class_name: "panel-control-center", + setup: (self) => { + self.hook(notifications, () => { + self.toggleClassName("empty", notifications.notifications.length == 0); + self.icon = notifications.dnd + ? "notifications-disabled-symbolic" + : "notifications-symbolic"; + }); + }, + }); + +export default () => + PanelButton({ + window: WINDOW_NAME, + child: NotificationIcon(), + on_clicked: () => { + App.toggleWindow(WINDOW_NAME); + }, + }); diff --git a/config/ags/widget/control_center/Window.js b/config/ags/widget/control_center/Window.js new file mode 100644 index 00000000..abc047bb --- /dev/null +++ b/config/ags/widget/control_center/Window.js @@ -0,0 +1,50 @@ +import PopupWindow from "../PopupWindow.js"; +import BrightnessSlider from "./Brightness.js"; +import QSButtonContainer from "./buttons/Container.js"; +import NotificationContainer from "./Notifications.js"; +import { Media } from "./Media.js"; +import { configs } from "../../vars.js"; +import { layoutPos } from "../../functions/utils.js"; + +export const WINDOW_NAME = "control-center__window"; +const { bar } = configs.theme; + +const Container = ({ width = 350 }) => + Widget.Box({ + vertical: true, + vexpand: true, + hexpand: false, + children: [ + Widget.Box({ + class_names: ["control-center__container", "window-content"], + css: `min-width: ${width}px;`, + hexpand: false, + vexpand: true, + vertical: true, + children: [ + BrightnessSlider(), + Widget.Separator(), + QSButtonContainer(), + Widget.Separator(), + NotificationContainer({}), + ], + }), + Media(), + ], + }); + +const ControlCenterWindow = () => + PopupWindow({ + name: WINDOW_NAME, + animation: "slide top", + layout: layoutPos(bar.position.value, "top-right"), + child: Container({}), + }); +export default function() { + App.addWindow(ControlCenterWindow()); + + bar.position.connect("changed", () => { + App.removeWindow(WINDOW_NAME); + App.addWindow(ControlCenterWindow()); + }); +} diff --git a/config/ags/widget/control_center/buttons/Container.js b/config/ags/widget/control_center/buttons/Container.js new file mode 100644 index 00000000..c89b2276 --- /dev/null +++ b/config/ags/widget/control_center/buttons/Container.js @@ -0,0 +1,28 @@ +import Dnd from "./dnd.js"; +import Wallpaper from "./wallpaper.js"; +import DarkMode from "./dark_mode.js"; +import Screenshot from "./screenshot.js"; +import ScreenRecord from "./screen_record.js"; +import ColorPicker from "./color_picker.js"; +import MicAccess from "./mic_access.js"; +import PowerMenu from "./power_menu.js"; + +export default () => + Widget.Box({ + vertical: true, + spacing: 8, + class_name: "qs-buttons", + homogeneous: true, + children: [ + Widget.Box({ + spacing: 8, + homogeneous: true, + children: [Dnd(), Wallpaper(), DarkMode(), Screenshot()], + }), + Widget.Box({ + spacing: 8, + homogeneous: true, + children: [ScreenRecord(), ColorPicker(), MicAccess(), PowerMenu()], + }), + ], + }); diff --git a/config/ags/widget/control_center/buttons/color_picker.js b/config/ags/widget/control_center/buttons/color_picker.js new file mode 100644 index 00000000..a2f69885 --- /dev/null +++ b/config/ags/widget/control_center/buttons/color_picker.js @@ -0,0 +1,28 @@ +import QsButton from "./qs_button.js"; +import { WINDOW_NAME } from "../Window.js"; + +const wlCopy = (color) => Utils.execAsync(["wl-copy", color]).catch(print); + +export default () => + QsButton({ + label: "Color Picker", + icon: "color-select-symbolic", + on_clicked: () => { + App.toggleWindow(WINDOW_NAME); + Utils.timeout(200, () => { + Utils.execAsync("hyprpicker") + .then((color) => { + if (!color) return; + + wlCopy(color); + Utils.notify({ + iconName: "color-select-symbolic", + summary: "Color Picker", + body: color, + timeout: 5000, + }); + }) + .catch(print); + }); + }, + }); diff --git a/config/ags/widget/control_center/buttons/dark_mode.js b/config/ags/widget/control_center/buttons/dark_mode.js new file mode 100644 index 00000000..9d243ae3 --- /dev/null +++ b/config/ags/widget/control_center/buttons/dark_mode.js @@ -0,0 +1,16 @@ +import QsButton from "./qs_button.js"; +import { configs } from "../../../vars.js"; + +export default () => + QsButton({ + icon: "night-symbolic", + label: "Dark Mode", + setup: (self) => { + self.hook(configs.theme.dark_mode, () => { + self.toggleClassName("active", configs.theme.dark_mode.value); + }); + }, + on_clicked: () => { + configs.theme.dark_mode.updateValue(!configs.theme.dark_mode.value); + }, + }); diff --git a/config/ags/widget/control_center/buttons/dnd.js b/config/ags/widget/control_center/buttons/dnd.js new file mode 100644 index 00000000..a01c803a --- /dev/null +++ b/config/ags/widget/control_center/buttons/dnd.js @@ -0,0 +1,16 @@ +import QsButton from "./qs_button.js"; +const notifications = await Service.import("notifications"); + +export default () => + QsButton({ + icon: notifications + .bind("dnd") + .as((dnd) => `notifications-${dnd ? "disabled-" : ""}symbolic`), + label: "DND", + setup: (self) => { + self.hook(notifications, () => { + self.toggleClassName("active", notifications.dnd); + }); + }, + on_clicked: () => (notifications.dnd = !notifications.dnd), + }); diff --git a/config/ags/widget/control_center/buttons/mic_access.js b/config/ags/widget/control_center/buttons/mic_access.js new file mode 100644 index 00000000..31aade5b --- /dev/null +++ b/config/ags/widget/control_center/buttons/mic_access.js @@ -0,0 +1,22 @@ +const { microphone } = await Service.import("audio"); +import QsButton from "./qs_button.js"; + +const Icon = () => + microphone.is_muted || microphone.stream?.is_muted + ? "microphone-disabled-symbolic" + : "microphone-sensitivity-high-symbolic"; + +export default () => + QsButton({ + icon: Utils.watch(Icon(), microphone, Icon), + label: "Mic Access", + on_clicked: () => (microphone.is_muted = !microphone.is_muted), + setup: (self) => { + self.hook(microphone, () => { + self.toggleClassName( + "active", + !(microphone.is_muted || microphone.stream?.is_muted), + ); + }); + }, + }); diff --git a/config/ags/widget/control_center/buttons/power_menu.js b/config/ags/widget/control_center/buttons/power_menu.js new file mode 100644 index 00000000..001216d9 --- /dev/null +++ b/config/ags/widget/control_center/buttons/power_menu.js @@ -0,0 +1,13 @@ +import { WINDOW_NAME } from "../Window.js"; +import { WINDOW_NAME as POWERMENU_WINDOW } from "../../powermenu/PowerMenuWindow.js"; +import QsButton from "./qs_button.js"; + +export default () => + QsButton({ + icon: "system-shutdown-symbolic", + label: "Powermenu", + on_clicked: () => { + App.toggleWindow(WINDOW_NAME); + App.toggleWindow(POWERMENU_WINDOW); + }, + }); diff --git a/config/ags/widget/control_center/buttons/qs_button.js b/config/ags/widget/control_center/buttons/qs_button.js new file mode 100644 index 00000000..28c80560 --- /dev/null +++ b/config/ags/widget/control_center/buttons/qs_button.js @@ -0,0 +1,23 @@ +export default ({ icon, label, ...rest }) => + Widget.Button({ + class_name: "qs-button", + tooltip_text: label, + child: Widget.Box({ + vertical: true, + spacing: 4, + children: [ + Widget.Icon({ + icon: icon, + size: 18, + }), + Widget.Label({ + class_name: "label", + label: label, + maxWidthChars: 9, + wrap: true, + truncate: "end", + }), + ], + }), + ...rest, + }); diff --git a/config/ags/widget/control_center/buttons/screen_record.js b/config/ags/widget/control_center/buttons/screen_record.js new file mode 100644 index 00000000..3be118c1 --- /dev/null +++ b/config/ags/widget/control_center/buttons/screen_record.js @@ -0,0 +1,22 @@ +import QsButton from "./qs_button.js"; +import recorder from "../../../services/screen_record.js"; +import { WINDOW_NAME } from "../Window.js"; + +export default () => + QsButton({ + icon: "video-symbolic", + label: "Screen Record", + on_clicked: () => { + App.toggleWindow(WINDOW_NAME); + if (recorder.recording) { + recorder.stop(); + } else { + recorder.start(); + } + }, + setup: (self) => { + self.hook(recorder, () => { + self.toggleClassName("active", recorder.recording); + }); + }, + }); diff --git a/config/ags/widget/control_center/buttons/screenshot.js b/config/ags/widget/control_center/buttons/screenshot.js new file mode 100644 index 00000000..3530d109 --- /dev/null +++ b/config/ags/widget/control_center/buttons/screenshot.js @@ -0,0 +1,44 @@ +import QsButton from "./qs_button.js"; +import { WINDOW_NAME } from "../Window.js"; +import recorder from "../../../services/screen_record.js"; + +export default () => { + const menu = Widget.Menu({ + hpack: "start", + children: [ + Widget.MenuItem({ + hexpand: true, + on_activate: () => { + App.toggleWindow(WINDOW_NAME); + Utils.timeout(200, () => { + recorder.screenshot(true); + }); + }, + child: Widget.Label("Full", { + hexpand: true, + xalign: 0, + justification: "left", + }), + }), + Widget.MenuItem({ + hexpand: true, + on_activate: () => { + App.toggleWindow(WINDOW_NAME); + recorder.screenshot(); + }, + child: Widget.Label("Partial", { + hexpand: true, + xalign: 0, + justification: "left", + }), + }), + ], + }); + return QsButton({ + icon: "gnome-screenshot-symbolic", + label: "Screenshot", + on_primary_click: (_, event) => { + menu.popup_at_pointer(event); + }, + }); +}; diff --git a/config/ags/widget/control_center/buttons/wallpaper.js b/config/ags/widget/control_center/buttons/wallpaper.js new file mode 100644 index 00000000..fed1878b --- /dev/null +++ b/config/ags/widget/control_center/buttons/wallpaper.js @@ -0,0 +1,13 @@ +import { WINDOW_NAME } from "../Window.js"; +import { WINDOW_NAME as WALLPAPER_PICKER_WINDOW } from "../../wallpaper_picker/Window.js"; +import QsButton from "./qs_button.js"; + +export default () => + QsButton({ + icon: "emblem-photos-symbolic", + label: "Wallpaper", + on_clicked: () => { + App.toggleWindow(WINDOW_NAME); + App.toggleWindow(WALLPAPER_PICKER_WINDOW); + }, + }); diff --git a/config/ags/widget/datemenu/PanelButton.js b/config/ags/widget/datemenu/PanelButton.js new file mode 100644 index 00000000..1a30d24c --- /dev/null +++ b/config/ags/widget/datemenu/PanelButton.js @@ -0,0 +1,28 @@ +import { isVertical } from "../../functions/utils.js"; +import { clock, configs } from "../../vars.js"; +import PanelButton from "../PanelButton.js"; +import { WINDOW_NAME } from "./Window.js"; + +export default () => + PanelButton({ + window: WINDOW_NAME, + // child: Widget.Label({ label: clock.bind().as((t) => t.format("%H:%M")) }), + child: Widget.Box({ + vertical: configs.theme.bar.position.bind().as(isVertical), + children: [ + Widget.Label({ label: clock.bind().as((t) => t.format("%I")) }), + Widget.Label({ + label: ":", + visible: configs.theme.bar.position + .bind() + .as((pos) => !isVertical(pos)), + }), + Widget.Label({ label: clock.bind().as((t) => t.format("%M")) }), + Widget.Label({ label: " " }), + Widget.Label({ label: clock.bind().as((t) => t.format("%p")) }), + ], + }), + on_clicked: () => { + App.toggleWindow(WINDOW_NAME); + }, + }); diff --git a/config/ags/widget/datemenu/Window.js b/config/ags/widget/datemenu/Window.js new file mode 100644 index 00000000..5f5b15f5 --- /dev/null +++ b/config/ags/widget/datemenu/Window.js @@ -0,0 +1,41 @@ +import { layoutPos } from "../../functions/utils.js"; +import { clock, configs } from "../../vars.js"; +import PopupWindow from "../PopupWindow.js"; + +export const WINDOW_NAME = "datemenu__window"; + +const { bar } = configs.theme; + +const Container = () => + Widget.Box({ + vertical: true, + class_names: ["datemenu__container", "window-content"], + children: [ + Widget.Label({ + label: clock.bind().as((t) => t.format("%T")), + class_name: "clock", + }), + Widget.Label({ + label: clock.bind().as((dt) => dt.format("%d/%m/%Y")), + class_name: "date", + }), + Widget.Calendar(), + ], + }); + +const DateMenuWindow = () => + PopupWindow({ + name: WINDOW_NAME, + layout: layoutPos(bar.position.value, "top-left"), + animation: "slide top", + child: Container(), + }); + +export default function() { + App.addWindow(DateMenuWindow()); + + bar.position.connect("changed", () => { + App.removeWindow(WINDOW_NAME); + App.addWindow(DateMenuWindow()); + }); +} diff --git a/config/ags/widget/hyprsplash/Window.js b/config/ags/widget/hyprsplash/Window.js new file mode 100644 index 00000000..866ebca0 --- /dev/null +++ b/config/ags/widget/hyprsplash/Window.js @@ -0,0 +1,21 @@ +import { isVertical } from "../../functions/utils.js"; +import { configs } from "../../vars.js"; + +const Text = () => + Widget.Label({ + class_name: "splash-text", + label: Utils.exec("hyprctl splash"), + }); + +export default () => + Widget.Window({ + name: "hyprsplash__window", + layer: "bottom", + anchor: configs.theme.bar.position + .bind() + .as((v) => (v === "bottom" ? ["top"] : ["bottom"])), + margins: configs.theme.window.margin + .bind() + .as((v) => v.split(",").map(Number)), + child: Text(), + }); diff --git a/config/ags/widget/network/Bluetooth.js b/config/ags/widget/network/Bluetooth.js new file mode 100644 index 00000000..e8063827 --- /dev/null +++ b/config/ags/widget/network/Bluetooth.js @@ -0,0 +1,63 @@ +import { ArrowToggleButton, Menu } from "../ToggleButton.js"; +const bluetooth = await Service.import("bluetooth"); + +export const BluetoothToggle = () => + ArrowToggleButton({ + name: "bluetooth", + icon: bluetooth + .bind("enabled") + .as((on) => `bluetooth-${on ? "active" : "disabled"}-symbolic`), + label: Utils.watch("Disabled", bluetooth, () => { + if (!bluetooth.enabled) return "Disabled"; + + if (bluetooth.connected_devices.length === 1) + return bluetooth.connected_devices[0].alias; + + return `${bluetooth.connected_devices.length} Connected`; + }), + connection: [bluetooth, () => bluetooth.enabled], + deactivate: () => (bluetooth.enabled = false), + activate: () => (bluetooth.enabled = true), + }); + +const DeviceItem = (device) => + Widget.Box({ + children: [ + Widget.Icon(device.icon_name + "-symbolic"), + Widget.Label(device.name), + Widget.Label({ + label: `${device.battery_percentage}%`, + visible: device.bind("battery_percentage").as((p) => p > 0), + }), + Widget.Box({ hexpand: true }), + Widget.Spinner({ + active: device.bind("connecting"), + visible: device.bind("connecting"), + }), + Widget.Switch({ + active: device.connected, + visible: device.bind("connecting").as((p) => !p), + setup: (self) => + self.on("notify::active", () => { + device.setConnection(self.active); + }), + }), + ], + }); + +export const BluetoothDevices = () => + Menu({ + name: "bluetooth", + icon: "bluetooth-disabled-symbolic", + title: "Bluetooth", + content: [ + Widget.Box({ + class_name: "bluetooth-devices", + hexpand: true, + vertical: true, + children: bluetooth + .bind("devices") + .as((ds) => ds.filter((d) => d.name).map(DeviceItem)), + }), + ], + }); diff --git a/config/ags/widget/network/PanelButton.js b/config/ags/widget/network/PanelButton.js new file mode 100644 index 00000000..88d8bc2c --- /dev/null +++ b/config/ags/widget/network/PanelButton.js @@ -0,0 +1,31 @@ +const network = await Service.import("network"); +const bluetooth = await Service.import("bluetooth"); +import { isVertical } from "../../functions/utils.js"; +import { configs } from "../../vars.js"; +import PanelButton from "../PanelButton.js"; +import { WINDOW_NAME } from "./Window.js"; + +const WifiIndicator = () => + Widget.Icon().hook(network, (self) => { + const icon = network[network.primary || "wifi"]?.icon_name; + self.icon = icon || ""; + self.visible = !!icon; + }); + +const BluetoothIndicator = () => + Widget.Icon("bluetooth-active-symbolic").hook(bluetooth, (self) => { + self.visible = bluetooth.enabled; + }); + +export default () => + PanelButton({ + window: WINDOW_NAME, + child: Widget.Box({ + spacing: 4, + vertical: configs.theme.bar.position.bind().as(isVertical), + children: [WifiIndicator(), BluetoothIndicator()], + }), + on_clicked: () => { + App.toggleWindow(WINDOW_NAME); + }, + }); diff --git a/config/ags/widget/network/Wifi.js b/config/ags/widget/network/Wifi.js new file mode 100644 index 00000000..ccd6ec35 --- /dev/null +++ b/config/ags/widget/network/Wifi.js @@ -0,0 +1,56 @@ +import { ArrowToggleButton, Menu } from "../ToggleButton.js"; +const { wifi } = await Service.import("network"); +import { WINDOW_NAME } from "./Window.js"; + +export const NetworkToggle = () => + ArrowToggleButton({ + name: "network", + icon: wifi.bind("icon_name"), + label: wifi.bind("ssid").as((ssid) => ssid || "Not Connected"), + connection: [wifi, () => wifi.enabled], + deactivate: () => (wifi.enabled = false), + activate: () => { + wifi.enabled = true; + wifi.scan(); + }, + }); + +export const WifiSelection = () => + Menu({ + name: "network", + parentWindowName: WINDOW_NAME, + icon: wifi.bind("icon_name"), + title: "Wifi Selection", + content: [ + Widget.Box({ + vertical: true, + setup: (self) => + self.hook( + wifi, + () => + (self.children = wifi.access_points.map((ap) => + Widget.Button({ + on_clicked: () => { + Utils.execAsync(`nmcli device wifi connect ${ap.bssid}`); + }, + child: Widget.Box({ + children: [ + Widget.Icon(ap.iconName), + Widget.Label(ap.ssid || ""), + Widget.Icon({ + icon: "object-select-symbolic", + hexpand: true, + hpack: "end", + setup: (self) => + Utils.idle(() => { + if (!self.is_destroyed) self.visible = ap.active; + }), + }), + ], + }), + }), + )), + ), + }), + ], + }); diff --git a/config/ags/widget/network/Window.js b/config/ags/widget/network/Window.js new file mode 100644 index 00000000..d0f3c8ae --- /dev/null +++ b/config/ags/widget/network/Window.js @@ -0,0 +1,35 @@ +import PopupWindow from "../PopupWindow.js"; +import { WifiSelection, NetworkToggle } from "./Wifi.js"; +import { BluetoothDevices, BluetoothToggle } from "./Bluetooth.js"; +import { Row } from "../ToggleButton.js"; +import { configs } from "../../vars.js"; +import { layoutPos } from "../../functions/utils.js"; +export const WINDOW_NAME = "network__window"; +const { bar } = configs.theme; + +const Container = () => + Widget.Box({ + class_names: ["network-info__container", "window-content"], + hexpand: false, + vertical: true, + children: [ + Row([NetworkToggle, BluetoothToggle], [WifiSelection, BluetoothDevices]), + ], + }); + +const NetworkWindow = () => + PopupWindow({ + name: WINDOW_NAME, + layout: layoutPos(bar.position.value, "top-right"), + animation: "slide top", + child: Container(), + }); + +export default function() { + App.addWindow(NetworkWindow()); + + bar.position.connect("changed", () => { + App.removeWindow(WINDOW_NAME); + App.addWindow(NetworkWindow()); + }); +} diff --git a/config/ags/widget/network_speed/PanelButton.js b/config/ags/widget/network_speed/PanelButton.js new file mode 100644 index 00000000..97f5a120 --- /dev/null +++ b/config/ags/widget/network_speed/PanelButton.js @@ -0,0 +1,37 @@ +import { isVertical } from "../../functions/utils.js"; +import networkspeed from "../../services/network_speed.js"; +import { configs } from "../../vars.js"; +import PanelButton from "../PanelButton.js"; + +// networkspeed.interval = 3000; + +const NetworkSpeedLabel = (inMB = true) => + Widget.Label({ class_name: "label" }) + .hook(networkspeed, (self) => { + let downloadSpeed = networkspeed.download_speed; + let uploadSpeed = networkspeed.upload_speed; + let speed = downloadSpeed >= uploadSpeed ? downloadSpeed : uploadSpeed; + if (inMB) { + speed = (speed / 1000).toFixed(2); + } + const unit = downloadSpeed >= uploadSpeed ? "" : ""; + self.label = `${speed} ${unit}`; + }) + .hook(configs.theme.bar.position, (self) => { + self.toggleClassName( + "vert", + isVertical(configs.theme.bar.position.value), + ); + }); + +export default () => + PanelButton({ + class_name: "network-speed", + child: Widget.Box({ + vertical: true, + children: [ + NetworkSpeedLabel(), + Widget.Label({ class_name: "unit", label: "MB/s" }), + ], + }), + }); diff --git a/config/ags/widget/notifications/PopupWindow.js b/config/ags/widget/notifications/PopupWindow.js new file mode 100644 index 00000000..43510613 --- /dev/null +++ b/config/ags/widget/notifications/PopupWindow.js @@ -0,0 +1,100 @@ +import Notification from "./notifications.js"; +// import { configs } from "../../vars.js"; + +const notifications = await Service.import("notifications"); +const transition = 900; +const { timeout, idle } = Utils; + +function Animated(id) { + const n = notifications.getNotification(id); + const widget = Notification(n); + + const inner = Widget.Revealer({ + transition: "slide_left", + transition_duration: transition, + child: widget, + }); + + const outer = Widget.Revealer({ + transition: "slide_down", + transition_duration: transition, + child: inner, + }); + + const box = Widget.Box({ + hpack: "end", + child: outer, + }); + + idle(() => { + outer.reveal_child = true; + timeout(transition, () => { + inner.reveal_child = true; + }); + }); + + return Object.assign(box, { + dismiss() { + inner.reveal_child = false; + timeout(transition, () => { + outer.reveal_child = false; + timeout(transition, () => { + box.destroy(); + }); + }); + }, + }); +} + +function PopupList() { + const map = new Map(); + const box = Widget.Box({ + hpack: "end", + vertical: true, + spacing: 8, + css: `min-width: 350px;`, + }); + + function remove(_, id) { + map.get(id)?.dismiss(); + map.delete(id); + } + + return box + .hook( + notifications, + (_, id) => { + if (id !== undefined) { + if (map.has(id)) remove(null, id); + + if (notifications.dnd) return; + + const w = Animated(id); + map.set(id, w); + box.children = [w, ...box.children]; + } + }, + "notified", + ) + .hook(notifications, remove, "dismissed") + .hook(notifications, remove, "closed"); +} + +export default (monitor = "") => { + const win = Widget.Window({ + monitor, + name: `notifications${monitor}`, + anchor: ["bottom", "right"], + class_name: "notifications", + child: Widget.Box({ + css: "padding: 0.1px;", + child: PopupList(), + }), + }); + + Object.assign(win, { + //disable? + animation: "0", + }); + return win; +}; diff --git a/config/ags/widget/notifications/notifications.js b/config/ags/widget/notifications/notifications.js new file mode 100644 index 00000000..b0c5c5e4 --- /dev/null +++ b/config/ags/widget/notifications/notifications.js @@ -0,0 +1,139 @@ +import GLib from "gi://GLib"; + +const time = (time, format = "%I:%M %p") => + GLib.DateTime.new_from_unix_local(time).format(format); + +const NotificationIcon = ({ app_entry, app_icon, image }) => { + if (image) { + return Widget.Box({ + vpack: "start", + hexpand: false, + class_name: "icon img", + css: ` + background-image: url("${image}"); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + min-width: 60px; + min-height: 60px; + `, + }); + } + + let icon = "dialog-information-symbolic"; + + if (Utils.lookUpIcon(app_icon)) icon = app_icon; + + if (Utils.lookUpIcon(app_entry || "")) icon = app_entry || ""; + + return Widget.Box({ + vpack: "start", + hexpand: false, + class_name: "icon", + css: ` + min-width: 60px; + min-height: 60px; + `, + child: Widget.Icon({ + icon, + size: 48, + hpack: "center", + hexpand: true, + vpack: "center", + vexpand: true, + }), + }); +}; + +export default (notification) => { + const content = Widget.Box({ + class_name: "content", + children: [ + NotificationIcon(notification), + Widget.Box({ + hexpand: true, + vertical: true, + children: [ + Widget.Box({ + children: [ + Widget.Label({ + class_name: "title", + xalign: 0, + justification: "left", + hexpand: true, + max_width_chars: 16, + truncate: "end", + wrap: true, + label: notification.summary.trim(), + use_markup: true, + }), + Widget.Label({ + class_name: "time", + vpack: "start", + label: time(notification.time), + }), + Widget.Button({ + class_name: "close-button", + vpack: "start", + child: Widget.Icon("window-close-symbolic"), + on_clicked: notification.close, + }), + ], + }), + Widget.Label({ + class_name: "description", + hexpand: true, + use_markup: true, + xalign: 0, + justification: "left", + label: notification.body.trim(), + max_width_chars: 24, + wrap: true, + }), + ], + }), + ], + }); + + const actionsbox = + notification.actions.length > 0 + ? Widget.Revealer({ + transition: "slide_down", + child: Widget.EventBox({ + child: Widget.Box({ + class_name: "actions horizontal", + children: notification.actions.map((action) => + Widget.Button({ + class_name: "action-button", + on_clicked: () => notification.invoke(action.id), + hexpand: true, + child: Widget.Label(action.label), + }), + ), + }), + }), + }) + : null; + + const eventbox = Widget.EventBox({ + vexpand: false, + on_primary_click: notification.dismiss, + on_hover() { + if (actionsbox) actionsbox.reveal_child = true; + }, + on_hover_lost() { + if (actionsbox) actionsbox.reveal_child = true; + + notification.dismiss(); + }, + child: Widget.Box({ + vertical: true, + children: actionsbox ? [content, actionsbox] : [content], + }), + }); + + return Widget.Box({ + class_name: `notification ${notification.urgency}`, + child: eventbox, + }); +}; diff --git a/config/ags/widget/osd/Progress.js b/config/ags/widget/osd/Progress.js new file mode 100644 index 00000000..5e4e5f00 --- /dev/null +++ b/config/ags/widget/osd/Progress.js @@ -0,0 +1,63 @@ +import GLib from "gi://GLib?version=2.0"; + +function range(length, start = 1) { + return Array.from({ length }, (_, i) => i + start); +} + +export default ({ height = 18, width = 180, vertical = false, child }) => { + const fill = Widget.Box({ + class_name: "fill", + hexpand: vertical, + vexpand: !vertical, + hpack: vertical ? "fill" : "start", + vpack: vertical ? "end" : "fill", + child, + }); + + const container = Widget.Box({ + class_name: "progress", + child: fill, + css: ` + min-width: ${width}px; + min-height: ${height}px; + `, + }); + + let fill_size = 0; + let animations = []; + + return Object.assign(container, { + setValue(value) { + if (value < 0) return; + + if (animations.length > 0) { + for (const id of animations) GLib.source_remove(id); + + animations = []; + } + + const axis = vertical ? "height" : "width"; + const axisv = vertical ? height : width; + const min = vertical ? width : height; + const preferred = (axisv - min) * value + min; + + if (!fill_size) { + fill_size = preferred; + fill.css = `min-${axis}: ${preferred}px;`; + return; + } + + const frames = 100 / 10; + const goal = preferred - fill_size; + const step = goal / frames; + + animations = range(frames, 0).map((i) => + Utils.timeout(5 * i, () => { + fill_size += step; + fill.css = `min-${axis}: ${fill_size}px`; + animations.shift(); + }), + ); + }, + }); +}; diff --git a/config/ags/widget/osd/ProgressOsd.js b/config/ags/widget/osd/ProgressOsd.js new file mode 100644 index 00000000..10a2506e --- /dev/null +++ b/config/ags/widget/osd/ProgressOsd.js @@ -0,0 +1,83 @@ +import brightness from "../../services/brightness.js"; +import { icon } from "../../functions/utils.js"; +import { configs } from "../../vars.js"; +import Progress from "./Progress.js"; +const WINDOW_NAME = "osd__window"; +const DELAY = 3000; + +const audio = await Service.import("audio"); + +const Container = (vertical) => { + const indicator = Widget.Icon({ + class_name: "icon", + size: 40, + vpack: "end", + hpack: "start", + }); + + const progress = Progress({ + vertical, + width: vertical ? 40 : 200, + height: vertical ? 260 : 40, + child: indicator, + }); + + let count = 0; + function show(value, icon) { + indicator.icon = icon; + progress.setValue(value); + App.openWindow(WINDOW_NAME); + count++; + Utils.timeout(DELAY, () => { + count--; + + if (count === 0) App.closeWindow(WINDOW_NAME); + }); + } + + const box = Widget.Box({ + class_name: "osd progress", + children: [progress], + setup: (self) => { + self.hook(configs.osd.progress.brightness, () => { + self.hook( + brightness, + () => { + if (configs.osd.progress.brightness.value) + show(brightness.screen, "display-brightness-symbolic"); + }, + "notify::screen", + ); + }); + + self.hook(configs.osd.progress.volume, () => { + self.hook( + audio.speaker, + () => { + if (configs.osd.progress.volume.value) + show( + audio.speaker.volume, + icon(audio.speaker.icon_name || "", "audio-x-generic-symbolic"), + ); + }, + "notify::volume", + ); + }); + }, + }); + + return box; +}; + +export default () => { + const win = Widget.Window({ + name: WINDOW_NAME, + click_through: true, + anchor: configs.osd.progress.position.bind().as((v) => v.split(" ")), + visible: false, + layer: "overlay", + child: configs.osd.progress.vertical.bind().as(Container), + }); + + return win; +}; diff --git a/config/ags/widget/osd/RegularOsd.js b/config/ags/widget/osd/RegularOsd.js new file mode 100644 index 00000000..56f91386 --- /dev/null +++ b/config/ags/widget/osd/RegularOsd.js @@ -0,0 +1,99 @@ +import { capsLockState, configs } from "../../vars.js"; + +const { microphone } = await Service.import("audio"); +const WINDOW_NAME = "osd__capslock"; +const DELAY = 3000; + +const Container = () => { + const indicator = Widget.Icon({ + class_name: "icon", + size: 60, + vpack: "start", + }); + + const label = Widget.Label({}); + + let count = 0; + function show(label_text, icon) { + indicator.icon = icon; + label.label = label_text; + App.openWindow(WINDOW_NAME); + count++; + Utils.timeout(DELAY, () => { + count--; + + if (count === 0) App.closeWindow(WINDOW_NAME); + }); + } + + const box = Widget.Box({ + class_name: "osd regular", + vertical: configs.osd.regular.vertical.bind(), + children: [indicator, label], + spacing: 6, + setup: (self) => { + self.hook(configs.osd.regular.capslock, () => { + self.hook(capsLockState, () => { + const value = capsLockState.value; + const icon = `capslock-${value === "1" ? "enabled" : "disabled"}-symbolic`; + if (configs.osd.regular.capslock.value) + show(`Capslock ${value === "1" ? "On" : "Off"}`, icon); + }); + }); + + self.hook(configs.osd.regular.mic, () => { + if (configs.osd.regular.mic.value) { + self.hook(microphone, () => { + const value = microphone.is_muted; + const icon = `microphone-${value ? "disabled" : "sensitivity-high"}-symbolic`; + + if (configs.osd.regular.mic.value) + show(`Mic ${!value ? "On" : "Off"}`, icon); + }); + } + }); + }, + }); + + // box.hook(capsLockState, () => { + // const value = capsLockState.value; + // const icon = `capslock-${value === "1" ? "enabled" : "disabled"}-symbolic`; + // if (configs.osd.regular.capslock.value) + // show(`Capslock ${value === "1" ? "On" : "Off"}`, icon); + // }); + // + // box.hook(microphone, () => { + // const value = microphone.is_muted; + // const icon = `microphone-${value ? "disabled" : "sensitivity-high"}-symbolic`; + // + // if (configs.osd.regular.mic.value) + // show(`Capslock ${value === "1" ? "On" : "Off"}`, icon); + // }); + + return box; +}; + +export default () => { + const win = Widget.Window({ + name: WINDOW_NAME, + click_through: true, + anchor: configs.osd.regular.position.bind().as((v) => v.split(" ")), + visible: false, + layer: "overlay", + child: Container(), + // setup: (self) => { + // self.child = Container(); + // self.hook(configs.osd.regular.capslock, () => { + // self.child = Container(); + // }); + // + // self.hook(microphone, () => { + // self.child = Container(); + // }); + // }, + }); + // Object.assign(win, { + // animation: "popin 100%", + // }); + return win; +}; diff --git a/config/ags/widget/powermenu/PowerMenuWindow.js b/config/ags/widget/powermenu/PowerMenuWindow.js new file mode 100644 index 00000000..3cc18c12 --- /dev/null +++ b/config/ags/widget/powermenu/PowerMenuWindow.js @@ -0,0 +1,48 @@ +import powermenu from "../../services/powermenu.js"; +import PopupWindow from "../PopupWindow.js"; + +export const WINDOW_NAME = "powermenu__window"; + +const icons = { + lock: "system-lock-screen-symbolic", + sleep: "weather-clear-night-symbolic", + reboot: "system-reboot-symbolic", + logout: "system-log-out-symbolic", + shutdown: "system-shutdown-symbolic", +}; + +const SysButton = (action, label) => + Widget.Button({ + on_clicked: () => powermenu.action(action), + child: Widget.Box({ + vertical: true, + class_name: "system-button", + children: [ + Widget.Icon(icons[action]), + Widget.Label({ + label, + }), + ], + }), + }); + +const Container = () => + Widget.Box({ + class_names: ["powermenu__container", "window-content"], + spacing: 6, + homogeneous: true, + children: [ + SysButton("lock", "Lock"), + SysButton("sleep", "Sleep"), + SysButton("logout", "Log Out"), + SysButton("reboot", "Reboot"), + SysButton("shutdown", "Shutdown"), + ], + }); + +export default () => + PopupWindow({ + name: WINDOW_NAME, + exclusivity: "ignore", + child: Container(), + }); diff --git a/config/ags/widget/powermenu/VerificationWindow.js b/config/ags/widget/powermenu/VerificationWindow.js new file mode 100644 index 00000000..d56533d3 --- /dev/null +++ b/config/ags/widget/powermenu/VerificationWindow.js @@ -0,0 +1,54 @@ +import powermenu from "../../services/powermenu.js"; +import PopupWindow from "../PopupWindow.js"; + +const WINDOW_NAME = "verification__window"; + +const Container = () => + Widget.Box({ + class_names: ["verification__container", "window-content"], + vertical: true, + children: [ + Widget.Box({ + class_name: "text-box", + vertical: true, + children: [ + Widget.Label({ + class_name: "title", + label: powermenu.bind("title"), + }), + Widget.Label({ + class_name: "desc", + label: "Are you sure?", + }), + ], + }), + Widget.Box({ + class_name: "buttons", + vexpand: true, + vpack: "end", + homogeneous: true, + spacing: 6, + children: [ + Widget.Button({ + child: Widget.Label("No"), + on_clicked: () => App.toggleWindow(WINDOW_NAME), + setup: (self) => + self.hook(App, (_, name, visible) => { + if (name === WINDOW_NAME && visible) self.grab_focus(); + }), + }), + Widget.Button({ + child: Widget.Label("Yes"), + on_clicked: () => Utils.exec(powermenu.cmd), + }), + ], + }), + ], + }); + +export default () => + PopupWindow({ + name: WINDOW_NAME, + exclusivity: "ignore", + child: Container(), + }); diff --git a/config/ags/widget/screen_record/PanelButton.js b/config/ags/widget/screen_record/PanelButton.js new file mode 100644 index 00000000..47d43ef6 --- /dev/null +++ b/config/ags/widget/screen_record/PanelButton.js @@ -0,0 +1,32 @@ +import PanelButton from "../PanelButton.js"; +import recorder from "../../services/screen_record.js"; +import { configs } from "../../vars.js"; +import { isVertical } from "../../functions/utils.js"; + +export default () => + PanelButton({ + on_clicked: () => recorder.stop(), + visible: recorder.bind("recording"), + child: Widget.Box({ + vertical: configs.theme.bar.position.bind().as(isVertical), + children: [ + Widget.Icon("media-record-symbolic"), + Widget.Label({ + class_name: "timer", + label: recorder.bind("timer").as((time) => { + const sec = time % 60; + const min = Math.floor(time / 60); + return `${min}:${sec < 10 ? "0" + sec : sec}`; + }), + setup: (self) => { + self.hook(configs.theme.bar.position, () => { + self.toggleClassName( + "vert", + isVertical(configs.theme.bar.position.value), + ); + }); + }, + }), + ], + }), + }); diff --git a/config/ags/widget/system_monitor/Window.js b/config/ags/widget/system_monitor/Window.js new file mode 100644 index 00000000..22fd7799 --- /dev/null +++ b/config/ags/widget/system_monitor/Window.js @@ -0,0 +1,145 @@ +import { cpu, ram, configs, clock } from "../../vars.js"; + +const CpuProgress = () => + Widget.Box({ + class_name: "cpu-box", + spacing: 4, + children: [ + Widget.CircularProgress({ + class_name: "progress", + value: cpu.bind(), + child: Widget.Icon({ + icon: "applications-electronics-symbolic", + hpack: "center", + }), + }), + Widget.Box({ + vertical: true, + vpack: "center", + children: [ + Widget.Label({ + class_name: "label", + label: "CPU:", + hpack: "start", + }), + Widget.Label({ + class_name: "value", + label: cpu.bind().as((v) => `${(v * 100).toFixed(1)}%`), + }), + ], + }), + ], + }); + +const RamProgress = () => + Widget.Box({ + spacing: 4, + children: [ + Widget.CircularProgress({ + class_name: "progress", + value: ram.bind(), + child: Widget.Icon({ icon: "nvidia-ram-symbolic", hpack: "center" }), + }), + Widget.Box({ + vertical: true, + vpack: "center", + children: [ + Widget.Label({ + class_name: "label", + label: "RAM:", + hpack: "start", + }), + Widget.Label({ + class_name: "value", + label: ram.bind().as((v) => `${(v * 100).toFixed(1)}%`), + }), + ], + }), + ], + }); + +const CpuAndRam = () => + Widget.Box({ + hpack: "center", + children: [CpuProgress(), RamProgress()], + }); + +const Hari = () => + Widget.Label({ + class_name: "day", + hpack: "start", + label: clock.bind().as((t) => t.format("%A").toUpperCase()), + }); + +const Tanggal = () => + Widget.Box({ + vpack: "end", + hpack: "end", + children: [ + Widget.Label({ + class_name: "day-number", + label: clock.bind().as((t) => t.format("%d") + " "), + vpack: "end", + }), + Widget.Label({ + class_name: "month", + vpack: "end", + label: clock.bind().as((t) => t.format("%B")), + }), + ], + }); + +const Date = () => + Widget.Overlay({ + child: Hari(), + overlays: [Tanggal()], + }); + +const DayDots = () => + Widget.Box({ + class_name: "day-dots", + spacing: 8, + hpack: "center", + //I guess this is not efficient? + children: clock.bind().as((t) => { + const format = Number(t.format("%u")); + const last = 7 - format; + return [ + ...Array(format) + .fill() + .map(() => Widget.Box({ class_name: "fill" })), + ...Array(last) + .fill() + .map(() => Widget.Box({ class_name: "empty" })), + ]; + }), + // setup: (self) => { + // const t = GLib.DateTime.new_now_local(); + // const format = Number(t.format("%u")); + // const last = 7 - format; + // self.children = [ + // ...Array(format) + // .fill() + // .map(() => Widget.Box({ class_name: "fill" })), + // ...Array(last) + // .fill() + // .map(() => Widget.Box({ class_name: "empty" })), + // ]; + // }, + }); + +const Container = () => + Widget.Box({ + class_names: ["system-monitor__container", "window-content"], + vertical: true, + spacing: 8, + children: [Date(), DayDots(), Widget.Separator(), CpuAndRam()], + }); + +export default () => + Widget.Window({ + name: "system-monitor__window", + anchor: configs.system_monitor.position.bind().as((v) => v.split(" ")), + layer: "bottom", + child: Container(), + }); diff --git a/config/ags/widget/wallpaper_picker/Window.js b/config/ags/widget/wallpaper_picker/Window.js new file mode 100644 index 00000000..f57f703f --- /dev/null +++ b/config/ags/widget/wallpaper_picker/Window.js @@ -0,0 +1,187 @@ +import PopupWindow from "../PopupWindow.js"; +import FileChooserDialog from "../FileChooserDialog.js"; +import { configs } from "../../vars.js"; + +export const WINDOW_NAME = "wallpaper-picker__window"; + +function updateWallpaper(path) { + configs.wallpaper.current.updateValue(getFilename(path)); +} + +function getWallpaperList(path) { + const imageFormats = [".jpeg", ".jpg", ".webp", ".png"]; + return Utils.exec(`ls ${path} -1`) + .split("\n") + .filter((str) => { + return imageFormats.some((fmt) => str.endsWith(fmt)); + }); +} + +function getFilename(str) { + return str.split("\\").pop().split("/").pop(); +} + +const WallItem = (folder, wall) => + Widget.Button({ + class_name: "item", + on_clicked: () => { + updateWallpaper(`${folder}/${wall}`); + }, + attribute: { wall: `${folder}/${wall}` }, + child: Widget.Box({ + children: [ + Widget.Label({ + class_name: "title", + label: wall, + xalign: 0, + hexpand: true, + vpack: "center", + truncate: "end", + }), + Widget.Label({ + // icon: "object-select-symbolic", + label: "󰄬", + class_name: "checkmark", + setup: (self) => { + self.hook(configs.wallpaper.current, (icon) => { + icon.visible = configs.wallpaper.current.value == wall; + }); + }, + }), + ], + }), + }); + +const WallpaperPicker = ({ width = 500, spacing = 12 }) => { + const list = Widget.Box({ + vertical: true, + spacing, + hexpand: true, + }).hook(configs.wallpaper.folder, (self) => { + const path = configs.wallpaper.folder.value; + self.vpack = "start"; + self.children = getWallpaperList(path).map((item) => WallItem(path, item)); + + if (self.children.length == 0) { + self.vpack = "center"; + self.children = [ + Widget.Label({ + hpack: "center", + label: "There's nothing here.", + css: "font-size: 14px; font-weight: 600;", + }), + ]; + } + }); + + const entry = Widget.Box({ + class_name: "entry-box", + children: [ + Widget.Icon("search-symbolic"), + Widget.Entry({ + hexpand: true, + on_accept: () => { + const results = list.children.filter((item) => item.visible); + if (results[0]) { + updateWallpaper(results[0].attribute.wall); + } + }, + on_change: ({ text }) => + list.children.forEach((item) => { + item.visible = getFilename(item.attribute.wall).match( + text.toLowerCase() ?? "", + ); + }), + setup: (self) => + self.hook(App, (_, windowName, visible) => { + if (windowName !== WINDOW_NAME) return; + + if (visible) { + self.text = ""; + self.grab_focus(); + } + }), + }), + ], + }); + + return Widget.Box({ + class_names: ["wallpaper-picker__container", "window-content"], + vertical: true, + vexpand: true, + children: [ + Widget.Box({ + spacing: 8, + children: [ + entry, + Widget.Button({ + class_name: "folder-button", + on_clicked: () => { + App.toggleWindow(WINDOW_NAME); + App.toggleWindow("wall-filechooser"); + return false; + }, + child: Widget.Icon({ icon: "folder-open-symbolic" }), + }), + ], + }), + Widget.Label({ + class_name: "path", + css: `margin-bottom: ${spacing}px`, + label: configs.wallpaper.folder.bind().as((p) => `Path: ${p}`), + truncate: "end", + max_width_chars: 40, + hpack: "start", + }), + Widget.Scrollable({ + hscroll: "never", + css: `min-width: ${width}px;`, + vexpand: true, + child: Widget.Box({ vexpand: true, children: [list] }), + }), + ], + }); +}; + +export const WallpaperPickerWindow = () => + PopupWindow({ + name: WINDOW_NAME, + layout: "right", + animation: "slide right", + child: WallpaperPicker({ + width: 300, + spacing: 12, + }), + }); + +export const FolderChooserWindow = () => + FileChooserDialog({ + name: "wall-filechooser", + action: 2, + "use-header-bar": false, + "create-folders": false, + setup(win) { + win.on("delete-event", () => { + win.hide(); + App.toggleWindow(WINDOW_NAME); + return true; + }); + + win.add_button("Cancel", 2); + win.add_button("Choose Folder", 1); + + win.on("response", (_, id) => { + if (id == 2) { + win.hide(); + App.toggleWindow(WINDOW_NAME); + } else { + const choosen = win.get_file(); + if (choosen != null) { + configs.wallpaper.folder.updateValue(choosen.get_path()); + win.hide(); + App.toggleWindow(WINDOW_NAME); + } + } + }); + }, + }); diff --git a/config/ags/widget/workspaces/PanelButton.js b/config/ags/widget/workspaces/PanelButton.js new file mode 100644 index 00000000..7111fb52 --- /dev/null +++ b/config/ags/widget/workspaces/PanelButton.js @@ -0,0 +1,79 @@ +import { isVertical } from "../../functions/utils.js"; +import { configs } from "../../vars.js"; + +const hyprland = await Service.import("hyprland"); +const dispatch = (ws) => hyprland.messageAsync(`dispatch workspace ${ws}`); + +const WorkspaceButton = (ws) => + Widget.Button({ + class_name: "workspace-button", + child: Widget.Box({ + class_name: "fill", + hexpand: false, + setup: (self) => { + self.hook(configs.theme.bar.position, () => { + self.toggleClassName( + "vert", + isVertical(configs.theme.bar.position.value), + ); + self.toggleClassName( + "hort", + !isVertical(configs.theme.bar.position.value), + ); + }); + }, + }), + vpack: "center", + hpack: "center", + onClicked: () => dispatch(ws.id), + setup: (self) => { + self.hook(hyprland, () => { + self.toggleClassName("active", hyprland.active.workspace.id == ws.id); + self.toggleClassName( + "occupied", + hyprland.getWorkspace(ws.id)?.windows > 0, + ); + }); + }, + }); + +// Within the default function: +export default () => { + const wsBox = Widget.Box({ + class_names: ["workspace__container"], + spacing: 4, + hexpand: false, + vexpand: false, + vertical: configs.theme.bar.position.bind().as(isVertical), + setup: (self) => { + // Ensure workspaces array exists + if (!hyprland.workspaces) { + hyprland.workspaces = []; // Initialize the workspaces array if it doesn't exist + } + + // Fetch or create workspaces if the array is empty + if (hyprland.workspaces.length === 0) { + // For example: + // hyprland.workspaces = await fetchWorkspacesFromServer(); + // or + // hyprland.workspaces = createInitialWorkspaces(); + } + + // Update the workspace buttons whenever there's a change in workspaces + self.hook( + hyprland, + () => { + // Clear existing buttons + self.children = []; + + // Map existing workspaces to buttons + self.children = hyprland.workspaces.map(WorkspaceButton); + }, + "notify::workspaces", + ); + }, + }); + return Widget.EventBox({ + child: wsBox, + }); +}; diff --git a/config/ags/windows.js b/config/ags/windows.js new file mode 100644 index 00000000..571e7ebe --- /dev/null +++ b/config/ags/windows.js @@ -0,0 +1,42 @@ +import { + FolderChooserWindow, + WallpaperPickerWindow, +} from "./widget/wallpaper_picker/Window.js"; +import AppLauncherWindow from "./widget/applauncher/Window.js"; +import HyprsplashWindow from "./widget/hyprsplash/Window.js"; +import NotificationPopupWindow from "./widget/notifications/PopupWindow.js"; +import VerificationWindow from "./widget/powermenu/VerificationWindow.js"; +import PowerMenuWindow from "./widget/powermenu/PowerMenuWindow.js"; +import SystemMonitorWindow from "./widget/system_monitor/Window.js"; +import ProgressOsd from "./widget/osd/ProgressOsd.js"; +import RegularOsd from "./widget/osd/RegularOsd.js"; +import SetupDatemenuWindow from "./widget/datemenu/Window.js"; +import SetupAudioWindow from "./widget/audio/Window.js"; +import SetupNetworkWindow from "./widget/network/Window.js"; +import SetupBatteryWindow from "./widget/battery/Window.js"; +import SetupControlCenterWindow from "./widget/control_center/Window.js"; +import SetupBarWindow from "./widget/bar/Window.js"; + +App.addIcons(`${App.configDir}/assets`); + +export function setupWindows() { + SetupDatemenuWindow(); + SetupAudioWindow(); + SetupNetworkWindow(); + SetupBatteryWindow(); + SetupControlCenterWindow(); + SetupBarWindow(); +} + +export default [ + WallpaperPickerWindow(), + FolderChooserWindow(), + AppLauncherWindow(), + NotificationPopupWindow(), + PowerMenuWindow(), + VerificationWindow(), + HyprsplashWindow(), + SystemMonitorWindow(), + ProgressOsd(), + RegularOsd(), +]; diff --git a/config/hypr/UserConfigs/Laptops.conf b/config/hypr/UserConfigs/Laptops.conf index 15b932b9..ad618826 100644 --- a/config/hypr/UserConfigs/Laptops.conf +++ b/config/hypr/UserConfigs/Laptops.conf @@ -8,16 +8,16 @@ $RunCMD = $scriptsDir/RunCMD.sh $UserConfigs = $HOME/dotfiles/hypr/UserConfigs #VolumeControl -bindle = ,XF86MonBrightnessUp, exec, swayosd-client --brightness=raise 5 -bindle = ,XF86MonBrightnessDown, exec, swayosd-client --brightness=lower 5 -bindle = ,XF86AudioRaiseVolume, exec, swayosd-client --output-volume 5 -bindle = ,XF86AudioLowerVolume, exec, swayosd-client --output-volume -5 -bindle = ,XF86AudioMute, exec, swayosd-client --output-volume mute-toggle -bindle = ,XF86AudioMicMute, exec, swayosd-client --input-volume mute-toggle # Mic mute key -bind = ,XF86AudioNext, exec, playerctl next -bind = ,XF86AudioPrev, exec, playerctl previous -bind = ,XF86AudioPlay, exec, playerctl play -bind = ,XF86AudioStop, exec, playerctl pause +bind = ,XF86MonBrightnessUp, exec, brightnessctl set +5% +bind = ,XF86MonBrightnessDown, exec, brightnessctl set 5%- +bind = ,XF86AudioRaiseVolume, exec, pamixer -i 5 # Volume Higher key +bind = ,XF86AudioLowerVolume, exec, pamixer -d 5 # Volume lower key +bind = ,XF86AudioMute, exec, pamixer -t # Speaker Mute +bind = ,XF86AudioMicMute, exec, pamixer --default-source -t # Mic mute key +bind = ,XF86AudioNext, exec, playerctl next +bind = ,XF86AudioPrev, exec, playerctl previous +bind = ,XF86AudioPlay, exec, playerctl play +bind = ,XF86AudioStop, exec, playerctl pause # Laptops Other Key bind = , xf86Sleep, exec, systemctl suspend # sleep button diff --git a/config/hypr/UserConfigs/Startup_Apps.conf b/config/hypr/UserConfigs/Startup_Apps.conf index 86ef9bcb..c65427af 100644 --- a/config/hypr/UserConfigs/Startup_Apps.conf +++ b/config/hypr/UserConfigs/Startup_Apps.conf @@ -8,8 +8,8 @@ $SwwwRandom = $RunCMD auto_wall $lock = $RunCMD lockscreen # wallpaper stuff / More wallpaper options below -exec-once = swww query || swww-daemon --format xrgb -exec-once = $SwwwRandom +#exec-once = swww query || swww-daemon --format xrgb +#exec-once = $SwwwRandom # Startup exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP @@ -24,9 +24,9 @@ exec-once = $RunCMD polkit_ exec-once = $RunCMD battery_notify # starup apps -exec-once = waybar & +#exec-once = waybar & exec-once = ags & -exec-once = swaync & +#exec-once = swaync & exec-once = blueman-applet & exec-once = nm-applet --indicator & exec-once = hypridle & diff --git a/config/hypr/UserConfigs/UserKeybinds.conf b/config/hypr/UserConfigs/UserKeybinds.conf index fc049933..468e8ccf 100644 --- a/config/hypr/UserConfigs/UserKeybinds.conf +++ b/config/hypr/UserConfigs/UserKeybinds.conf @@ -38,14 +38,12 @@ bind = $mainMod_SHIFT, Q, exec, $RunCMD toggle_blur bind = $mainMod, space, exec, $RunCMD change_layout bind = SHIFT_ALT, C, exec, $RunCMD clip bind = ALT, E, exec, $RunCMD edit -bind = $mainMod, W, exec, $RunCMD select_wall -bind = SHIFT_ALT,W, exec, $RunCMD random_wall +#bind = $mainMod, W, exec, $RunCMD select_wall +#bind = SHIFT_ALT,W, exec, $RunCMD random_wall bind = $mainMod, F1, exec, $RunCMD keybind bind = $mainMod_SHIFT, N, exec, swaync-client -C -bind = $mainMod, escape, exec, $RunCMD powermenu bind = $mainMod, COMMA, exec, pypr zoom bind = ALT, COMMA, exec, pypr zoom +1 -bind = $mainMod, Tab, exec, pkill rofi || true && ags -t 'overview' # Online Music related keybinds bind = ALT, M, exec, $RunCMD music -m # open rofi music @@ -61,7 +59,27 @@ bind = $mainMod, H, exec, killall -SIGUSR1 waybar # ScreenShot -bind = $mainMod, Z, exec, grim -g "$(slurp)" - | tee ~/Pictures/"$(date '+%d-%b_%H-%M-%S')_${RANDOM}".png | wl-copy -bind = ,Print, exec, grim - | tee ~/Pictures/"$(date '+%d-%b_%H-%M-%S')_${RANDOM}".png | wl-copy +#bind = $mainMod, Z, exec, grim -g "$(slurp)" - | tee ~/Pictures/"$(date '+%d-%b_%H-%M-%S')_${RANDOM}".png | wl-copy +#bind = ,Print, exec, grim - | tee ~/Pictures/"$(date '+%d-%b_%H-%M-%S')_${RANDOM}".png | wl-copy + +# ags related +bind = CTRL SHIFT, R, exec, pkill ags ; ags + +bind = SUPER, R, exec, ags toggle-window applauncher__window + +bind = SUPER_SHIFT, W, exec, ags toggle-window wallpaper-picker__window # wallpaper picker + +bind = CTRL ALT, R, exec, ags -r "recorder.start()" # Recorder + +bind = $mainMod, Z, exec, ags -r "recorder.screenshot()" # Partial +bind = ,Print, exec, ags -r "recorder.screenshot(true)" # Full + +bind = ,Caps_Lock, exec, ags -r 'update_capslock()' + +bind = $mainMod, escape, exec, ags -t powermenu__window # PowerMenu +bind = $mainMod Caps_Lock, H, exec, ags -r 'moveBar("left")' +bind = $mainMod Caps_Lock, J, exec, ags -r 'moveBar("bottom")' +bind = $mainMod Caps_Lock, K, exec, ags -r 'moveBar("top")' +bind = $mainMod Caps_Lock, L, exec, ags -r 'moveBar("right")' diff --git a/config/hypr/UserConfigs/UserSettings.conf b/config/hypr/UserConfigs/UserSettings.conf index 3ba2111c..68496472 100644 --- a/config/hypr/UserConfigs/UserSettings.conf +++ b/config/hypr/UserConfigs/UserSettings.conf @@ -21,7 +21,7 @@ general { sensitivity = 1.00 apply_sens_to_raw = 1 gaps_in = 2 - gaps_out = 2 + gaps_out = 1 border_size = 1 resize_on_border = true diff --git a/config/hypr/initial-boot.sh b/config/hypr/initial-boot.sh index 53914bbc..7abb8c1b 100755 --- a/config/hypr/initial-boot.sh +++ b/config/hypr/initial-boot.sh @@ -16,7 +16,7 @@ effect="--transition-bezier .43,1.19,1,.4 --transition-fps 30 --transition-type if [ ! -f $HOME/cache/.initial_startup_done ]; then # Initial scripts to load in order to have a proper wallpaper - swww init || swww query && $swww "$wallpaper" $effect + #swww init || swww query && $swww "$wallpaper" $effect # initiate GTK dark mode and apply icon and cursor theme gsettings set org.gnome.desktop.interface color-scheme prefer-dark > /dev/null 2>&1 & diff --git a/config/hypr/scripts/Ref.sh b/config/hypr/scripts/Ref.sh index 1b1ff664..6e3a2963 100755 --- a/config/hypr/scripts/Ref.sh +++ b/config/hypr/scripts/Ref.sh @@ -44,3 +44,4 @@ UserConfigs="$HOME/dotfiles/hypr/UserConfigs" config_dir="$HOME/dotfiles/waybar/configs" waybar_config="$HOME/dotfiles/waybar/config" RunCMD="$SCRIPTSDIR/RunCMD.sh" + diff --git a/config/hypr/scripts/System_cmd.sh b/config/hypr/scripts/System_cmd.sh index 59cf12af..d456aca9 100755 --- a/config/hypr/scripts/System_cmd.sh +++ b/config/hypr/scripts/System_cmd.sh @@ -59,7 +59,7 @@ reload_all() { [ -e "$1" ] } - processes=("waybar" "rofi" "swaync") + processes=("waybar" "rofi" "swaync" "ags") for process in "${processes[@]}"; do pid=$(pidof "$process") @@ -68,6 +68,8 @@ reload_all() { fi done + sleep 0.3 + ags & sleep 0.3 waybar & sleep 0.5 diff --git a/config/hypr/scripts/tmux.sh b/config/hypr/scripts/tmux.sh deleted file mode 100755 index e24e0b86..00000000 --- a/config/hypr/scripts/tmux.sh +++ /dev/null @@ -1,19 +0,0 @@ -#! /usr/bin/env bash - -TERMINAL="kitty" - -function tmux_sessions() { - tmux list-session -F '#S' -} - -TMUX_SESSION=$( (echo new; tmux_sessions) | rofi -dmenu -p "󰆍 Tmux") - -if [[ x"new" = x"${TMUX_SESSION}" ]]; then - $TERMINAL -e tmux new-session & - exit 0 -elif [[ -z "${TMUX_SESSION}" ]]; then - exit 1 -else - $TERMINAL -e tmux attach -t "${TMUX_SESSION}" & - exit 0 -fi diff --git a/setup b/setup index aecf6242..d5bc2b9d 100755 --- a/setup +++ b/setup @@ -85,12 +85,20 @@ pkg=( ttf-dejavu ttf-ibm-plex ttf-liberation + ttf-font-awesome + ttf-ubuntu-font-family + ttf-ubuntu-nerd + ttf-mononoki-nerd + gtk3 + ttf-ubuntu-mono-nerd noto-fonts gnu-free-fonts qutebrowser sweet-cursor-theme-git gruvbox-plus-icon-theme-git swayosd-git + hyprpicker + matugen-bin ) # Creating a new `packages` array packages=(