Compare commits

..
5 Commits
9 changed files with 277 additions and 45 deletions

No files matched your search

+2
View File
@@ -70,6 +70,8 @@ _(Note: The shell is configured to automatically restore your last used wallpape
Because this shell uses **Pywal**, you can easily inject the dynamically generated colors into almost any other application on your system.
Pywal applies the colors to config files located in `~/.config/wal/templates`. Examples can be found in this repos templates folder.
Whenever you change the wallpaper via the AGS bar, Pywal updates the color templates inside `~/.cache/wal/`. Here is how to apply them to other apps:
### Manual Updates:
+16 -2
View File
@@ -1,7 +1,7 @@
@use "/tmp/ags-colors.scss" as wal;
$fg-color: wal.$foreground;
$bg-color: rgba(wal.$background, 0.8);
$bg-color: rgba(wal.$background, 1);
$btn-height: 30px;
$btn-radius: 8px;
@@ -14,7 +14,7 @@ window.Bar {
font-weight: bold;
> centerbox {
background: $bg-color;
background: rgba(wal.$background, 1);
border-radius: 10px;
margin: 4px 8px;
padding: 0 8px;
@@ -201,6 +201,20 @@ window.PowerMenu {
background: rgba(wal.$foreground, 0.1);
}
}
.qs-device-name {
font-weight: bold;
}
.qs-device-status {
font-size: 0.9em;
opacity: 0.7;
}
.qs-battery {
font-size: 0.9em;
opacity: 0.7;
}
}
slider {
+21
View File
@@ -0,0 +1,21 @@
var_wallpaper = "{wallpaper}"
var_foreground = "rgba({foreground.rgb},1.0)"
var_background = "rgba({background.rgb},1.0)"
var_color0 = "rgba({color0.rgb},1.0)"
var_color1 = "rgba({color1.rgb},1.0)"
var_color2 = "rgba({color2.rgb},1.0)"
var_color3 = "rgba({color3.rgb},1.0)"
var_color4 = "rgba({color4.rgb},1.0)"
var_color5 = "rgba({color5.rgb},1.0)"
var_color6 = "rgba({color6.rgb},1.0)"
var_color7 = "rgba({color7.rgb},1.0)"
var_color8 = "rgba({color8.rgb},1.0)"
var_color9 = "rgba({color9.rgb},1.0)"
var_color10 = "rgba({color10.rgb},1.0)"
var_color11 = "rgba({color11.rgb},1.0)"
var_color12 = "rgba({color12.rgb},1.0)"
var_color13 = "rgba({color13.rgb},1.0)"
var_color14 = "rgba({color14.rgb},1.0)"
var_color15 = "rgba({color15.rgb},1.0)"
+17
View File
@@ -0,0 +1,17 @@
* {
/* Base Colors */
background: #{background.strip}D9; /* D9 = ~85% opacity. Use 99 for 60% or CC for 80% */
background-solid: {background};
foreground: {foreground};
/* Accent Colors */
color0: {color0};
color1: {color1};
color2: {color2};
color3: {color3};
color4: {color4};
color5: {color5};
color6: {color6};
color7: {color7};
color8: {color8};
}
+22
View File
@@ -0,0 +1,22 @@
[global]
# Define the corner radius in pixels.
# A value of 0 disables rounded corners.
corner_radius = 10
[urgency_low]
background = "{background}CC"
foreground = "{foreground}"
frame_color = "{color2}"
timeout = 10
[urgency_normal]
background = "{background}CC"
foreground = "{foreground}"
frame_color = "{color1}"
timeout = 10
[urgency_critical]
background = "{background}CC"
foreground = "{foreground}"
frame_color = "{color9}"
timeout = 0
+1 -3
View File
@@ -121,9 +121,7 @@ export async function setTheme(wallpaperPath: string) {
// 2. Generate colors with pywal16
try {
// -q: quiet, -i: image, -n: skip setting wallpaper (hyprpaper does it)
await execAsync(
`wal --backend modern-colorthief -q -n -i "${wallpaperPath}"`,
)
await execAsync(`wal --contrast 21.0 -q -n -i "${wallpaperPath}"`)
// Add this line so hyprlock always knows the current wallpaper:
await execAsync([
+3
View File
@@ -3,3 +3,6 @@
#Dunst notification daemon
killall dunst
dunst &
hyprctl reload
+82
View File
@@ -2,6 +2,7 @@ import { Gtk } from "ags/gtk4"
import AstalNetwork from "gi://AstalNetwork?version=0.1"
import AstalBluetooth from "gi://AstalBluetooth?version=0.1"
import AstalWp from "gi://AstalWp?version=0.1"
import AstalPowerProfiles from "gi://AstalPowerProfiles?version=0.1"
import { createBinding, createComputed, createState, For } from "ags"
import { interval } from "ags/time"
import { exec, execAsync } from "ags/process"
@@ -41,6 +42,23 @@ interval(2000, () => setVpns(fetchVpns()))
const vpnActive = vpns((list) => list.some((c) => c.active))
const POWER_PROFILE_ICONS: Record<string, string> = {
"power-saver": "power-profile-power-saver-symbolic",
balanced: "power-profile-balanced-symbolic",
performance: "power-profile-performance-symbolic",
}
const POWER_PROFILE_LABELS: Record<string, string> = {
"power-saver": "Power Saver",
balanced: "Balanced",
performance: "Performance",
}
const powerprofiles = AstalPowerProfiles.get_default()
const activeProfile = createBinding(powerprofiles, "active-profile")
const powerProfiles = powerprofiles.get_profiles().map((p) => p.profile)
const hasPowerProfiles = powerProfiles.length > 0
function NetworkItem() {
const network = AstalNetwork.Network.get_default()
const primary = createBinding(network, "primary")
@@ -190,6 +208,58 @@ function VpnList() {
)
}
function PowerProfileItem() {
return (
<menubutton cssClasses={["qs-item"]} hexpand>
<box spacing={12} valign={Gtk.Align.CENTER}>
<image
iconName={activeProfile(
(p) => POWER_PROFILE_ICONS[p] ?? "power-profile-balanced-symbolic",
)}
cssClasses={["qs-icon"]}
/>
<label
label={activeProfile((p) => POWER_PROFILE_LABELS[p] ?? p)}
halign={Gtk.Align.START}
hexpand
/>
<image iconName="pan-down-symbolic" />
</box>
<popover>
<box orientation={Gtk.Orientation.VERTICAL} spacing={4}>
{powerProfiles.map((name) => (
<button
cssClasses={["qs-item"]}
onClicked={(btn) => {
powerprofiles.set_active_profile(name)
const popover = btn.get_ancestor(
Gtk.Popover.$gtype,
) as Gtk.Popover | null
popover?.popdown()
}}
>
<box spacing={12} valign={Gtk.Align.CENTER}>
<image
iconName={
POWER_PROFILE_ICONS[name] ??
"power-profile-balanced-symbolic"
}
cssClasses={["qs-icon"]}
/>
<label
label={POWER_PROFILE_LABELS[name] ?? name}
halign={Gtk.Align.START}
hexpand
/>
</box>
</button>
))}
</box>
</popover>
</menubutton>
)
}
export default function QuickSettings() {
return (
<menubutton
@@ -213,6 +283,18 @@ export default function QuickSettings() {
<BluetoothItem />
</box>
<VpnList />
<box
orientation={Gtk.Orientation.VERTICAL}
spacing={8}
visible={hasPowerProfiles}
>
<label
label="Power Profile"
cssClasses={["qs-title"]}
halign={Gtk.Align.START}
/>
<PowerProfileItem />
</box>
<box orientation={Gtk.Orientation.VERTICAL} spacing={8}>
<button
cssClasses={["qs-title"]}
+113 -40
View File
@@ -1,9 +1,92 @@
import { execAsync, createSubprocess } from "ags/process"
import { For, createComputed } from "ags"
import { Gdk } from "ags/gtk4"
import { createSubprocess, execAsync } from "ags/process"
import GLib from "gi://GLib?version=2.0"
interface WorkspaceInfo {
address: string
name: string
monitor: string
active: boolean
}
const HIS = GLib.getenv("HYPRLAND_INSTANCE_SIGNATURE")
const sock = `${GLib.getenv("XDG_RUNTIME_DIR")}/hypr/${HIS}/.socket2.sock`
const SOCK = `${GLib.getenv("XDG_RUNTIME_DIR")}/hypr/${HIS}/.socket2.sock`
// Hyprland 0.57 omits the numeric "id" on specialWorkspace, which makes
// AstalHyprland's monitor parsing log Json-CRITICAL errors on every workspace
// switch. Read the IPC JSON directly instead. Only numbered workspaces are
// shown in the bar.
const WORKSPACES_SCRIPT = `
SOCK="${SOCK}"
print_state() {
hyprctl -j monitors | python3 -c '
import json, subprocess, sys
try:
monitors = json.load(sys.stdin)
workspaces = json.loads(subprocess.check_output(["hyprctl", "-j", "workspaces"]))
except Exception:
raise SystemExit(0)
def ident(ws):
return ws.get("address") or ws.get("name") or str(ws.get("id") or "")
seen = set()
out = []
def add(ws, monitor, active):
address = ident(ws)
# only numbered workspaces; special and named ones are not part of the bar
if not address.isdigit():
return
key = (monitor, address)
if key in seen:
return
seen.add(key)
out.append({
"address": address,
"name": ws.get("name") or address,
"monitor": monitor,
"active": active,
})
for monitor in monitors:
name = monitor.get("name") or ""
active = monitor.get("activeWorkspace") or {}
for ws in workspaces:
if ws.get("monitor") == name:
add(ws, name, ident(ws) == ident(active))
# an active workspace always exists, even if it is empty and not listed
add(active, name, True)
print(json.dumps(out))
'
}
print_state
nc -U "$SOCK" | while IFS= read -r line; do
case "$line" in
workspace*|focusedmon*|createworkspace*|destroyworkspace*|moveworkspace*|renameworkspace*|changeworkspaceid*|activespecial*|monitoradded*|monitorremoved*)
print_state
;;
esac
done
`
const workspaces = createSubprocess<WorkspaceInfo[]>(
[],
["sh", "-c", WORKSPACES_SCRIPT],
(out, prev) => {
try {
const parsed = JSON.parse(out)
return Array.isArray(parsed) ? parsed : prev
} catch {
return prev
}
},
)
export default function Workspaces({
gdkmonitor,
@@ -12,48 +95,38 @@ export default function Workspaces({
}) {
const monitorName = gdkmonitor.get_connector()
// Listen to the Hyprland socket for instant workspace updates
const activeWs = createSubprocess(
1,
[
"sh",
"-c",
`
MON="${monitorName}"
print_ws() {
hyprctl monitors -j | python3 -c "import json, sys; mon = sys.argv[1]; data = json.load(sys.stdin); print(next((m.get('activeWorkspace', {}).get('id', 0) for m in data if m.get('name') == mon), 0))" "$MON"
}
print_ws
nc -U ${sock} | while IFS= read -r line; do
case "$line" in
focusedmon*|workspace*|workspacev2*|moveworkspace*|moveworkspacev2*|createworkspace*|destroyworkspace*)
print_ws
;;
esac
done
`,
],
(out, prev) => {
const num = parseInt(out.trim())
if (!isNaN(num) && num > 0) return num
return prev
},
const monitorWorkspaces = workspaces.as((all) =>
all
.filter((ws) => ws.monitor === monitorName)
.sort((a, b) => Number(a.address) - Number(b.address)),
)
return (
<box cssClasses={["workspaces"]} spacing={4}>
{Array.from({ length: 9 }, (_, i) => i + 1).map((i) => (
<button
cssClasses={activeWs((active) =>
active === i ? ["workspace-btn", "active"] : ["workspace-btn"],
)}
onClicked={() => execAsync(`hyprctl dispatch workspace ${i}`)}
>
<label label={`${i}`} />
</button>
))}
<For each={monitorWorkspaces} id={(ws) => ws.address}>
{(ws) => {
// Look the workspace up by identity so the button survives state
// updates and only its props change (keeps the active transition).
const current = createComputed(() =>
workspaces().find(
(w) => w.monitor === monitorName && w.address === ws.address,
),
)
return (
<button
cssClasses={current.as((w) =>
w?.active ? ["workspace-btn", "active"] : ["workspace-btn"],
)}
onClicked={() =>
execAsync(["hyprctl", "dispatch", "workspace", ws.address])
}
>
<label label={current.as((w) => w?.name ?? ws.name)} />
</button>
)
}}
</For>
</box>
)
}