mirror of
https://github.com/xsghetti/HyprCrux.git
synced 2025-07-03 13:50:38 -04:00
updates
This commit is contained in:
parent
1f8cb3c145
commit
610604e80f
253 changed files with 27055 additions and 44 deletions
17
.config/ags/old/lib/battery.js
Normal file
17
.config/ags/old/lib/battery.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
import icons from "./icons.js"
|
||||
|
||||
export default async function init() {
|
||||
const bat = await Service.import("battery")
|
||||
bat.connect("notify::percent", ({ percent, charging }) => {
|
||||
const low = 30
|
||||
if (percent !== low || percent !== low / 2 || !charging)
|
||||
return
|
||||
|
||||
Utils.notify({
|
||||
summary: `${percent}% Battery Percentage`,
|
||||
iconName: icons.battery.warning,
|
||||
urgency: "critical",
|
||||
})
|
||||
})
|
||||
}
|
67
.config/ags/old/lib/experiments.js
Normal file
67
.config/ags/old/lib/experiments.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
|
||||
// these are functionalities that I might include in ags
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { Variable } from "resource:///com/github/Aylur/ags/variable.js"
|
||||
import { App } from "resource:///com/github/Aylur/ags/app.js"
|
||||
import GObject from "gi://GObject?version=2.0"
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
// export function watch(init, objs, callback)
|
||||
// export function watch(init, obj, callback)
|
||||
export function pwatch(
|
||||
init,
|
||||
objs,
|
||||
sigOrFn,
|
||||
callback,
|
||||
) {
|
||||
const v = new Variable(init)
|
||||
const f = typeof sigOrFn === "function" ? sigOrFn : callback ?? (() => v.value)
|
||||
const set = () => v.value = f()
|
||||
|
||||
if (Array.isArray(objs)) {
|
||||
// multiple objects
|
||||
for (const obj of objs) {
|
||||
if (Array.isArray(obj)) {
|
||||
// obj signal pair
|
||||
const [o, s = "changed"] = obj
|
||||
o.connect(s, set)
|
||||
} else {
|
||||
// obj on changed
|
||||
obj.connect("changed", set)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// watch single object
|
||||
const signal = typeof sigOrFn === "string" ? sigOrFn : "changed"
|
||||
objs.connect(signal, set)
|
||||
}
|
||||
|
||||
return v.bind()
|
||||
}
|
||||
export function watch(init, objs, sigOrFn, callback) {
|
||||
print(objs)
|
||||
const v = new Variable(init);
|
||||
const f = typeof sigOrFn === "function" ? sigOrFn : (callback || (() => v.value));
|
||||
const set = () => { v.value = f(); };
|
||||
|
||||
if (Array.isArray(objs)) {
|
||||
// multiple objects
|
||||
for (const obj of objs) {
|
||||
if (Array.isArray(obj)) {
|
||||
// obj signal pair
|
||||
const [o, s = "changed"] = obj;
|
||||
o.connect(s, set);
|
||||
} else {
|
||||
// obj on changed
|
||||
obj.connect("changed", set);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// watch single object
|
||||
const signal = typeof sigOrFn === "string" ? sigOrFn : "changed";
|
||||
objs.connect(signal, set);
|
||||
}
|
||||
|
||||
return v.bind();
|
||||
}
|
133
.config/ags/old/lib/icons.js
Normal file
133
.config/ags/old/lib/icons.js
Normal file
|
@ -0,0 +1,133 @@
|
|||
|
||||
export const substitutes = {
|
||||
"transmission-gtk": "transmission",
|
||||
"blueberry.py": "blueberry",
|
||||
"Caprine": "facebook-messenger",
|
||||
"com.raggesilver.BlackBox-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 default {
|
||||
fallback: {
|
||||
executable: "application-x-executable-symbolic",
|
||||
notification: "dialog-information-symbolic",
|
||||
video: "video-x-generic-symbolic",
|
||||
audio: "audio-x-generic-symbolic",
|
||||
},
|
||||
ui: {
|
||||
close: "window-close-symbolic",
|
||||
colorpicker: "color-select-symbolic",
|
||||
info: "info-symbolic",
|
||||
link: "external-link-symbolic",
|
||||
lock: "system-lock-screen-symbolic",
|
||||
menu: "open-menu-symbolic",
|
||||
refresh: "view-refresh-symbolic",
|
||||
search: "system-search-symbolic",
|
||||
settings: "emblem-system-symbolic",
|
||||
themes: "preferences-desktop-theme-symbolic",
|
||||
tick: "object-select-symbolic",
|
||||
time: "hourglass-symbolic",
|
||||
toolbars: "toolbars-symbolic",
|
||||
warning: "dialog-warning-symbolic",
|
||||
person: "person-symbolic",
|
||||
arrow: {
|
||||
right: "pan-end-symbolic",
|
||||
left: "pan-start-symbolic",
|
||||
down: "pan-down-symbolic",
|
||||
up: "pan-up-symbolic",
|
||||
},
|
||||
},
|
||||
audio: {
|
||||
mic: {
|
||||
muted: "microphone-disabled-symbolic",
|
||||
low: "microphone-sensitivity-low-symbolic",
|
||||
medium: "microphone-sensitivity-medium-symbolic",
|
||||
high: "microphone-sensitivity-high-symbolic",
|
||||
},
|
||||
volume: {
|
||||
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",
|
||||
},
|
||||
type: {
|
||||
headset: "audio-headphones-symbolic",
|
||||
speaker: "audio-speakers-symbolic",
|
||||
card: "audio-card-symbolic",
|
||||
},
|
||||
mixer: "mixer-symbolic",
|
||||
},
|
||||
asusctl: {
|
||||
profile: {
|
||||
Balanced: "power-profile-balanced-symbolic",
|
||||
Quiet: "power-profile-power-saver-symbolic",
|
||||
Performance: "power-profile-performance-symbolic",
|
||||
},
|
||||
mode: {
|
||||
Integrated: "processor-symbolic",
|
||||
Hybrid: "controller-symbolic",
|
||||
},
|
||||
},
|
||||
battery: {
|
||||
charging: "battery-flash-symbolic",
|
||||
warning: "battery-empty-symbolic",
|
||||
},
|
||||
bluetooth: {
|
||||
enabled: "bluetooth-active-symbolic",
|
||||
disabled: "bluetooth-disabled-symbolic",
|
||||
},
|
||||
brightness: {
|
||||
indicator: "display-brightness-symbolic",
|
||||
keyboard: "keyboard-brightness-symbolic",
|
||||
screen: "display-brightness-symbolic",
|
||||
},
|
||||
powermenu: {
|
||||
sleep: "weather-clear-night-symbolic",
|
||||
reboot: "system-reboot-symbolic",
|
||||
logout: "system-log-out-symbolic",
|
||||
shutdown: "system-shutdown-symbolic",
|
||||
},
|
||||
recorder: {
|
||||
recording: "media-record-symbolic",
|
||||
},
|
||||
notifications: {
|
||||
noisy: "org.gnome.Settings-notifications-symbolic",
|
||||
silent: "notifications-disabled-symbolic",
|
||||
message: "chat-bubbles-symbolic",
|
||||
},
|
||||
trash: {
|
||||
full: "user-trash-full-symbolic",
|
||||
empty: "user-trash-symbolic",
|
||||
},
|
||||
mpris: {
|
||||
shuffle: {
|
||||
enabled: "media-playlist-shuffle-symbolic",
|
||||
disabled: "media-playlist-consecutive-symbolic",
|
||||
},
|
||||
loop: {
|
||||
none: "media-playlist-repeat-symbolic",
|
||||
track: "media-playlist-repeat-song-symbolic",
|
||||
playlist: "media-playlist-repeat-symbolic",
|
||||
},
|
||||
playing: "media-playback-pause-symbolic",
|
||||
paused: "media-playback-start-symbolic",
|
||||
stopped: "media-playback-start-symbolic",
|
||||
prev: "media-skip-backward-symbolic",
|
||||
next: "media-skip-forward-symbolic",
|
||||
},
|
||||
system: {
|
||||
cpu: "org.gnome.SystemMonitor-symbolic",
|
||||
ram: "drive-harddisk-solidstate-symbolic",
|
||||
temp: "temperature-symbolic",
|
||||
},
|
||||
color: {
|
||||
dark: "dark-mode-symbolic",
|
||||
light: "light-mode-symbolic",
|
||||
},
|
||||
}
|
19
.config/ags/old/lib/init.js
Normal file
19
.config/ags/old/lib/init.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
// import hyprland from "./hyprland.js"
|
||||
// import tmux from "./tmux"
|
||||
// import gtk from "./gtk"
|
||||
import lowBattery from "./battery.js"
|
||||
// import swww from "./swww"
|
||||
|
||||
export async function init() {
|
||||
try {
|
||||
// gtk()
|
||||
// tmux()
|
||||
lowBattery()
|
||||
// hyprland()
|
||||
// css()
|
||||
// swww()
|
||||
} catch (error) {
|
||||
logError(error)
|
||||
}
|
||||
}
|
120
.config/ags/old/lib/utils.js
Normal file
120
.config/ags/old/lib/utils.js
Normal file
|
@ -0,0 +1,120 @@
|
|||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { substitutes } from "./icons.js"
|
||||
import Gtk from "gi://Gtk?version=3.0"
|
||||
import Gdk from "gi://Gdk"
|
||||
import GLib from "gi://GLib?version=2.0"
|
||||
|
||||
export function config(config) {
|
||||
return config
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns substitute icon || name || fallback icon
|
||||
*/
|
||||
export function icon(name, fallback = name) {
|
||||
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
|
||||
|
||||
print(`no icon substitute "${icon}" for "${name}", fallback: "${fallback}"`)
|
||||
return fallback
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns execAsync(["bash", "-c", cmd])
|
||||
*/
|
||||
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 ""
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns execAsync(cmd)
|
||||
*/
|
||||
export async function sh(cmd) {
|
||||
return Utils.execAsync(cmd).catch(err => {
|
||||
console.error(typeof cmd === "string" ? cmd : cmd.join(" "), err)
|
||||
return ""
|
||||
})
|
||||
}
|
||||
|
||||
export function forMonitors(widget) {
|
||||
const n = Gdk.Display.get_default()?.get_n_monitors() || 1
|
||||
return range(n, 0).map(widget).flat(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns [start...length]
|
||||
*/
|
||||
export function range(length, start = 1) {
|
||||
return Array.from({ length }, (_, i) => i + start)
|
||||
}
|
||||
|
||||
/**
|
||||
* promisified timeout
|
||||
*/
|
||||
export function wait(ms, callback) {
|
||||
return new Promise(resolve => Utils.timeout(ms, () => {
|
||||
resolve(callback())
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns true if all of the `bins` are found
|
||||
*/
|
||||
export function dependencies(...bins) {
|
||||
const missing = bins.filter(bin => {
|
||||
return !Utils.exec(`which ${bin}`)
|
||||
})
|
||||
|
||||
if (missing.length > 0)
|
||||
console.warn("missing dependencies:", missing.join(", "))
|
||||
|
||||
return missing.length === 0
|
||||
}
|
||||
|
||||
/**
|
||||
* run app detached
|
||||
*/
|
||||
export function launchApp(app) {
|
||||
const exe = app.executable
|
||||
.split(/\s+/)
|
||||
.filter(str => !str.startsWith("%") && !str.startsWith("@"))
|
||||
.join(" ")
|
||||
|
||||
bash(`${exe} &`)
|
||||
app.frequency += 1
|
||||
}
|
||||
|
||||
/**
|
||||
* to use with drag and drop
|
||||
*/
|
||||
export function createSurfaceFromWidget(widget) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const cairo = imports.gi.cairo
|
||||
const alloc = widget.get_allocation()
|
||||
const surface = new cairo.ImageSurface(
|
||||
cairo.Format.ARGB32,
|
||||
alloc.width,
|
||||
alloc.height,
|
||||
)
|
||||
const cr = new cairo.Context(surface)
|
||||
cr.setSourceRGBA(255, 255, 255, 0)
|
||||
cr.rectangle(0, 0, alloc.width, alloc.height)
|
||||
cr.fill()
|
||||
widget.draw(cr)
|
||||
return surface
|
||||
}
|
16
.config/ags/old/lib/variables.js
Normal file
16
.config/ags/old/lib/variables.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
import GLib from "gi://GLib"
|
||||
// import options from "options"
|
||||
//
|
||||
// const intval = options.system.fetchInterval.value
|
||||
// const tempPath = options.system.temperature.value
|
||||
|
||||
export const clock = Variable(GLib.DateTime.new_now_local(), {
|
||||
poll: [1000, () => GLib.DateTime.new_now_local()],
|
||||
})
|
||||
|
||||
export const uptime = Variable(0, {
|
||||
poll: [60_000, "cat /proc/uptime", line =>
|
||||
Number.parseInt(line.split(".")[0]) / 60,
|
||||
],
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue