updated theme, changed and optimized other modules

This commit is contained in:
Pascal Thuma committed 2026-03-24 23:04:27 +01:00
1 parent 6aa5a5182d
commit a2a4cbecbc
7 files changed
+327 -59

No files matched your search

+114 -8
View File
@@ -1,6 +1,7 @@
// https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/theme/Adwaita/_colors-public.scss @use "../../.cache/wal/colors.scss" as wal;
$fg-color: #{"@theme_fg_color"};
$bg-color: #{"@theme_bg_color"}; $fg-color: wal.$foreground;
$bg-color: rgba(wal.$background, 0.8);
window.Bar { window.Bar {
background: transparent; background: transparent;
@@ -23,6 +24,7 @@ window.Bar {
button { button {
border-radius: 8px; border-radius: 8px;
margin: 2px; margin: 2px;
transition: all 0.2s ease-in-out;
} }
.workspaces { .workspaces {
@@ -34,8 +36,12 @@ window.Bar {
background: transparent; background: transparent;
&.active { &.active {
background: #{"@theme_selected_bg_color"}; background: wal.$color2;
color: #{"@theme_selected_fg_color"}; color: wal.$background;
}
&:hover:not(.active) {
background: rgba(wal.$color2, 0.2);
} }
} }
} }
@@ -49,6 +55,10 @@ window.Bar {
padding: 0 8px; padding: 0 8px;
min-height: 24px; min-height: 24px;
&:hover {
background: rgba(wal.$foreground, 0.1);
}
.media-art { .media-art {
border-radius: 4px; border-radius: 4px;
-gtk-icon-size: 32px; -gtk-icon-size: 32px;
@@ -56,7 +66,7 @@ window.Bar {
} }
.system-tray { .system-tray {
background: rgba(150, 150, 150, 0.15); // Unified background for the tray background: rgba(wal.$color8, 0.3); // Unified background for the tray
border-radius: 8px; border-radius: 8px;
padding: 0 4px; // Reduced vertical padding padding: 0 4px; // Reduced vertical padding
margin: 2px; margin: 2px;
@@ -68,24 +78,120 @@ window.Bar {
border: none; border: none;
box-shadow: none; box-shadow: none;
&:hover {
background: rgba(wal.$foreground, 0.1);
border-radius: 6px;
}
image { image {
-gtk-icon-size: 16px; -gtk-icon-size: 16px;
} }
} }
} }
.controls-container {
.control-btn { .control-btn {
padding: 2px 8px; padding: 2px 8px;
min-height: 24px; min-height: 24px;
&:hover {
background: rgba(wal.$foreground, 0.1);
}
image { image {
-gtk-icon-size: 16px; -gtk-icon-size: 16px;
} }
} }
.controls-container {
.power-btn { .power-btn {
color: #ff5555; // Distinctive color for power button color: wal.$color1; // Distinctive color for power button
} }
} }
} }
.wallpaper-btn {
padding: 0;
border-radius: 8px;
background: transparent;
transition: all 0.2s ease-in-out;
&:hover {
background: rgba(wal.$foreground, 0.1);
}
picture {
border-radius: 8px;
}
}
window.PowerMenu {
background: transparent;
.power-menu-container {
background: $bg-color;
border-radius: 16px;
padding: 32px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
.power-menu-btn {
padding: 24px;
border-radius: 12px;
background: transparent;
min-width: 120px;
transition: all 0.2s ease-in-out;
&:hover {
background: rgba(wal.$foreground, 0.1);
}
.power-menu-icon {
-gtk-icon-size: 48px;
}
.power-menu-label {
font-size: 1.2em;
font-weight: bold;
}
}
}
}
.quick-settings-menu {
padding: 12px;
min-width: 280px;
.qs-title {
font-weight: bold;
font-size: 1.1em;
margin-bottom: 4px;
color: wal.$foreground;
opacity: 0.8;
}
.qs-item {
background: rgba(150, 150, 150, 0.1);
border-radius: 8px;
padding: 8px 12px;
.qs-icon {
-gtk-icon-size: 20px;
}
.qs-icon-btn {
background: transparent;
border: none;
box-shadow: none;
padding: 4px;
border-radius: 100%;
transition: all 0.2s ease-in-out;
&:hover {
background: rgba(wal.$foreground, 0.1);
}
}
}
slider {
transition: all 0.2s ease-in-out;
}
}
+105
View File
@@ -0,0 +1,105 @@
import app from "ags/gtk4/app"
import { execAsync } from "ags/process"
import GLib from "gi://GLib?version=2.0"
import Gio from "gi://Gio?version=2.0"
const HOME = GLib.getenv("HOME") || ""
const WALLPAPER_DIR = `${HOME}/wallpapers`
/**
* Get a list of all wallpapers in the default wallpapers directory.
*/
export async function getWallpapers(): Promise<string[]> {
try {
const dir = Gio.File.new_for_path(WALLPAPER_DIR)
const iter = dir.enumerate_children(
"standard::name",
Gio.FileQueryInfoFlags.NONE,
null,
)
let info
const files: string[] = []
while ((info = iter.next_file(null))) {
const name = info.get_name()
if (name.match(/\.(jpg|jpeg|png|gif)$/i)) {
files.push(`${WALLPAPER_DIR}/${name}`)
}
}
files.sort()
return files
} catch (error) {
console.error("Failed to read wallpapers directory:", error)
return []
}
}
/**
* Restore the last set wallpaper.
*/
export async function restoreTheme() {
try {
const out = await execAsync(["cat", `${HOME}/.cache/wal/wal`])
const wallpaperPath = out.trim()
if (wallpaperPath) {
console.log(`Restoring theme for wallpaper: ${wallpaperPath}`)
await setTheme(wallpaperPath)
}
} catch {
console.log("No previous wallpaper found to restore.")
}
}
/**
* Set the wallpaper using hyprpaper, generate colors with pywal,
* and reload the AGS theme.
*/
export async function setTheme(wallpaperPath: string) {
console.log(`Setting theme for wallpaper: ${wallpaperPath}`)
// 1. Set wallpaper with hyprpaper
try {
// Preload the wallpaper first
await execAsync(["hyprctl", "hyprpaper", "preload", wallpaperPath]).catch(
() => {},
)
const out = await execAsync("hyprctl monitors -j")
const monitors = JSON.parse(out)
for (const mon of monitors) {
await execAsync([
"hyprctl",
"hyprpaper",
"wallpaper",
`${mon.name},${wallpaperPath}`,
])
}
} catch (error) {
console.error("Failed to set wallpaper via hyprpaper:", error)
}
// 2. Generate colors with pywal16
try {
// -q: quiet, -i: image, -n: skip setting wallpaper (hyprpaper does it)
await execAsync(`wal -q -n -i "${wallpaperPath}"`)
} catch (error) {
console.error("Failed to generate colors with pywal:", error)
}
// 3. Re-compile and apply AGS styles
try {
const agsDir = `${HOME}/.config/ags`
const scss = `${agsDir}/style.scss`
const css = `/tmp/ags-compiled-style.css`
// Compile SCSS to CSS using the sass CLI
await execAsync(`sass ${scss} ${css}`)
// Reset any previously applied CSS and apply the new one
app.reset_css()
app.apply_css(css)
console.log("AGS theme successfully updated!")
} catch (error) {
console.error("Failed to recompile and apply AGS styles:", error)
}
}
+6 -4
View File
@@ -4,6 +4,7 @@ import Workspaces from "./Workspaces"
import { Clock, SysTray } from "./System" import { Clock, SysTray } from "./System"
import Media from "./Media" import Media from "./Media"
import Controls from "./Controls" import Controls from "./Controls"
import ThemeSwitcher from "./ThemeSwitcher"
function Left() { function Left() {
return ( return (
@@ -27,7 +28,7 @@ function Center() {
) )
} }
function Right() { function Right({ gdkmonitor }: { gdkmonitor: Gdk.Monitor }) {
return ( return (
<box <box
$type="end" $type="end"
@@ -35,8 +36,9 @@ function Right() {
cssClasses={["right-box"]} cssClasses={["right-box"]}
spacing={8} spacing={8}
> >
<ThemeSwitcher />
<SysTray /> <SysTray />
<Controls /> <Controls gdkmonitor={gdkmonitor} />
</box> </box>
) )
} }
@@ -47,7 +49,7 @@ export default function Bar(gdkmonitor: Gdk.Monitor) {
return ( return (
<window <window
visible visible
name={`bar-${gdkmonitor.get_display()?.get_name()}`} name={`bar-${gdkmonitor.get_connector()}`}
class="Bar" class="Bar"
gdkmonitor={gdkmonitor} gdkmonitor={gdkmonitor}
exclusivity={Astal.Exclusivity.EXCLUSIVE} exclusivity={Astal.Exclusivity.EXCLUSIVE}
@@ -57,7 +59,7 @@ export default function Bar(gdkmonitor: Gdk.Monitor) {
<centerbox cssName="centerbox"> <centerbox cssName="centerbox">
<Left /> <Left />
<Center /> <Center />
<Right /> <Right gdkmonitor={gdkmonitor} />
</centerbox> </centerbox>
</window> </window>
) )
+14 -17
View File
@@ -1,32 +1,29 @@
import { Gtk } from "ags/gtk4" import { Gtk } from "ags/gtk4"
import app from "ags/gtk4/app"
import QuickSettings from "./QuickSettings"
export function SettingsButton() { export function PowerButton({ gdkmonitor }: { gdkmonitor: any }) {
return (
<button
cssClasses={["control-btn", "settings-btn"]}
onClicked={() => console.log("Open Settings Menu - Phase 8")}
>
<image iconName="emblem-system-symbolic" />
</button>
)
}
export function PowerButton() {
return ( return (
<button <button
cssClasses={["control-btn", "power-btn"]} cssClasses={["control-btn", "power-btn"]}
onClicked={() => console.log("Open Power Menu - Phase 7")} onClicked={() =>
app.toggle_window(`power-menu-${gdkmonitor.get_connector()}`)
}
> >
<image iconName="system-shutdown-symbolic" /> <image iconName="system-shutdown-symbolic" />
</button> </button>
) )
} }
export default function Controls() { export default function Controls({ gdkmonitor }: { gdkmonitor: any }) {
return ( return (
<box cssClasses={["controls-container"]} spacing={4} valign={Gtk.Align.CENTER}> <box
<SettingsButton /> cssClasses={["controls-container"]}
<PowerButton /> spacing={4}
valign={Gtk.Align.CENTER}
>
<QuickSettings />
<PowerButton gdkmonitor={gdkmonitor} />
</box> </box>
) )
} }
+86 -29
View File
@@ -4,6 +4,7 @@ import { createBinding, With, onCleanup } from "ags"
export default function Media() { export default function Media() {
const mpris = AstalMpris.Mpris.get_default() const mpris = AstalMpris.Mpris.get_default()
let lastPlaying: string | null = null
return ( return (
<box cssClasses={["media-container"]}> <box cssClasses={["media-container"]}>
@@ -18,31 +19,24 @@ export default function Media() {
<box <box
$={(box) => { $={(box) => {
const updateVisibility = () => { const updateVisibility = () => {
let hasPlaying = false const activePlayer = players.find(
for (const player of players) { (p) =>
if ( p.playback_status === AstalMpris.PlaybackStatus.PLAYING,
player.playback_status === )
AstalMpris.PlaybackStatus.PLAYING
) { if (activePlayer) {
hasPlaying = true lastPlaying = activePlayer.bus_name
break
}
} }
let first = true const targetPlayer =
activePlayer ||
players.find((p) => p.bus_name === lastPlaying) ||
players[0]
let child = box.get_first_child() let child = box.get_first_child()
for (const player of players) { for (const player of players) {
if (!child) break if (!child) break
child.set_visible(player === targetPlayer)
if (hasPlaying) {
child.set_visible(
player.playback_status ===
AstalMpris.PlaybackStatus.PLAYING,
)
} else {
child.set_visible(first)
first = false
}
child = child.get_next_sibling() child = child.get_next_sibling()
} }
} }
@@ -58,18 +52,23 @@ export default function Media() {
players.forEach((p, i) => { players.forEach((p, i) => {
try { try {
p.disconnect(connections[i]) p.disconnect(connections[i])
} catch (e) {} } catch {}
}) })
}) })
}} }}
> >
{players.map((player) => ( {players.map((player) => {
<button const playbackIcon = createBinding(
cssClasses={["media-btn"]} player,
onClicked={() => "playback-status",
console.log("Expand Media Controls - Phase 7") )((s: any) =>
} s === AstalMpris.PlaybackStatus.PLAYING
> ? "media-playback-pause-symbolic"
: "media-playback-start-symbolic",
)
return (
<menubutton cssClasses={["media-btn"]}>
<box spacing={8} valign={Gtk.Align.CENTER}> <box spacing={8} valign={Gtk.Align.CENTER}>
{/* Fallback to an icon if cover-art is empty */} {/* Fallback to an icon if cover-art is empty */}
<image <image
@@ -85,8 +84,66 @@ export default function Media() {
ellipsize={3} // Pango.EllipsizeMode.END ellipsize={3} // Pango.EllipsizeMode.END
/> />
</box> </box>
<popover>
<box
css="padding: 16px; min-width: 250px;"
orientation={Gtk.Orientation.VERTICAL}
spacing={16}
>
<box spacing={16}>
<image
file={createBinding(player, "cover-art")}
iconName="audio-x-generic-symbolic"
css="-gtk-icon-size: 64px; border-radius: 8px;"
/>
<box
orientation={Gtk.Orientation.VERTICAL}
valign={Gtk.Align.CENTER}
>
<label
label={createBinding(player, "title")}
css="font-weight: bold; font-size: 1.1em;"
halign={Gtk.Align.START}
wrap={true}
maxWidthChars={20}
/>
<label
label={createBinding(player, "artist")}
css="opacity: 0.8;"
halign={Gtk.Align.START}
wrap={true}
maxWidthChars={20}
/>
</box>
</box>
<centerbox>
<button
$type="start"
onClicked={() => player.previous()}
css="border-radius: 100%; padding: 8px;"
>
<image iconName="media-skip-backward-symbolic" />
</button> </button>
))} <button
$type="center"
onClicked={() => player.play_pause()}
css="border-radius: 100%; padding: 8px; min-width: 40px;"
>
<image iconName={playbackIcon} />
</button>
<button
$type="end"
onClicked={() => player.next()}
css="border-radius: 100%; padding: 8px;"
>
<image iconName="media-skip-forward-symbolic" />
</button>
</centerbox>
</box>
</popover>
</menubutton>
)
})}
</box> </box>
) )
}} }}
+2
View File
@@ -19,7 +19,9 @@ export function Clock() {
<menubutton cssClasses={["clock-btn"]} halign={Gtk.Align.CENTER}> <menubutton cssClasses={["clock-btn"]} halign={Gtk.Align.CENTER}>
<label label={time} /> <label label={time} />
<popover> <popover>
<box css="padding: 12px;">
<Gtk.Calendar /> <Gtk.Calendar />
</box>
</popover> </popover>
</menubutton> </menubutton>
) )
-1
View File
@@ -1,4 +1,3 @@
import { Gtk } from "ags/gtk4"
import { execAsync } from "ags/process" import { execAsync } from "ags/process"
import { createPoll } from "ags/time" import { createPoll } from "ags/time"