updated theme, changed and optimized other modules
This commit is contained in:
1 parent
6aa5a5182d
commit
a2a4cbecbc
7 files changed
+327
-59
No files matched your search
+114
-8
@@ -1,6 +1,7 @@
|
||||
// https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gtk/theme/Adwaita/_colors-public.scss
|
||||
$fg-color: #{"@theme_fg_color"};
|
||||
$bg-color: #{"@theme_bg_color"};
|
||||
@use "../../.cache/wal/colors.scss" as wal;
|
||||
|
||||
$fg-color: wal.$foreground;
|
||||
$bg-color: rgba(wal.$background, 0.8);
|
||||
|
||||
window.Bar {
|
||||
background: transparent;
|
||||
@@ -23,6 +24,7 @@ window.Bar {
|
||||
button {
|
||||
border-radius: 8px;
|
||||
margin: 2px;
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.workspaces {
|
||||
@@ -34,8 +36,12 @@ window.Bar {
|
||||
background: transparent;
|
||||
|
||||
&.active {
|
||||
background: #{"@theme_selected_bg_color"};
|
||||
color: #{"@theme_selected_fg_color"};
|
||||
background: wal.$color2;
|
||||
color: wal.$background;
|
||||
}
|
||||
|
||||
&:hover:not(.active) {
|
||||
background: rgba(wal.$color2, 0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,6 +55,10 @@ window.Bar {
|
||||
padding: 0 8px;
|
||||
min-height: 24px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(wal.$foreground, 0.1);
|
||||
}
|
||||
|
||||
.media-art {
|
||||
border-radius: 4px;
|
||||
-gtk-icon-size: 32px;
|
||||
@@ -56,7 +66,7 @@ window.Bar {
|
||||
}
|
||||
|
||||
.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;
|
||||
padding: 0 4px; // Reduced vertical padding
|
||||
margin: 2px;
|
||||
@@ -68,24 +78,120 @@ window.Bar {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
|
||||
&:hover {
|
||||
background: rgba(wal.$foreground, 0.1);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
image {
|
||||
-gtk-icon-size: 16px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.controls-container {
|
||||
.control-btn {
|
||||
padding: 2px 8px;
|
||||
min-height: 24px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(wal.$foreground, 0.1);
|
||||
}
|
||||
|
||||
image {
|
||||
-gtk-icon-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.controls-container {
|
||||
.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;
|
||||
}
|
||||
}
|
||||
@@ -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
@@ -4,6 +4,7 @@ import Workspaces from "./Workspaces"
|
||||
import { Clock, SysTray } from "./System"
|
||||
import Media from "./Media"
|
||||
import Controls from "./Controls"
|
||||
import ThemeSwitcher from "./ThemeSwitcher"
|
||||
|
||||
function Left() {
|
||||
return (
|
||||
@@ -27,7 +28,7 @@ function Center() {
|
||||
)
|
||||
}
|
||||
|
||||
function Right() {
|
||||
function Right({ gdkmonitor }: { gdkmonitor: Gdk.Monitor }) {
|
||||
return (
|
||||
<box
|
||||
$type="end"
|
||||
@@ -35,8 +36,9 @@ function Right() {
|
||||
cssClasses={["right-box"]}
|
||||
spacing={8}
|
||||
>
|
||||
<ThemeSwitcher />
|
||||
<SysTray />
|
||||
<Controls />
|
||||
<Controls gdkmonitor={gdkmonitor} />
|
||||
</box>
|
||||
)
|
||||
}
|
||||
@@ -47,7 +49,7 @@ export default function Bar(gdkmonitor: Gdk.Monitor) {
|
||||
return (
|
||||
<window
|
||||
visible
|
||||
name={`bar-${gdkmonitor.get_display()?.get_name()}`}
|
||||
name={`bar-${gdkmonitor.get_connector()}`}
|
||||
class="Bar"
|
||||
gdkmonitor={gdkmonitor}
|
||||
exclusivity={Astal.Exclusivity.EXCLUSIVE}
|
||||
@@ -57,7 +59,7 @@ export default function Bar(gdkmonitor: Gdk.Monitor) {
|
||||
<centerbox cssName="centerbox">
|
||||
<Left />
|
||||
<Center />
|
||||
<Right />
|
||||
<Right gdkmonitor={gdkmonitor} />
|
||||
</centerbox>
|
||||
</window>
|
||||
)
|
||||
|
||||
+14
-17
@@ -1,32 +1,29 @@
|
||||
import { Gtk } from "ags/gtk4"
|
||||
import app from "ags/gtk4/app"
|
||||
import QuickSettings from "./QuickSettings"
|
||||
|
||||
export function SettingsButton() {
|
||||
return (
|
||||
<button
|
||||
cssClasses={["control-btn", "settings-btn"]}
|
||||
onClicked={() => console.log("Open Settings Menu - Phase 8")}
|
||||
>
|
||||
<image iconName="emblem-system-symbolic" />
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export function PowerButton() {
|
||||
export function PowerButton({ gdkmonitor }: { gdkmonitor: any }) {
|
||||
return (
|
||||
<button
|
||||
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" />
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export default function Controls() {
|
||||
export default function Controls({ gdkmonitor }: { gdkmonitor: any }) {
|
||||
return (
|
||||
<box cssClasses={["controls-container"]} spacing={4} valign={Gtk.Align.CENTER}>
|
||||
<SettingsButton />
|
||||
<PowerButton />
|
||||
<box
|
||||
cssClasses={["controls-container"]}
|
||||
spacing={4}
|
||||
valign={Gtk.Align.CENTER}
|
||||
>
|
||||
<QuickSettings />
|
||||
<PowerButton gdkmonitor={gdkmonitor} />
|
||||
</box>
|
||||
)
|
||||
}
|
||||
+86
-29
@@ -4,6 +4,7 @@ import { createBinding, With, onCleanup } from "ags"
|
||||
|
||||
export default function Media() {
|
||||
const mpris = AstalMpris.Mpris.get_default()
|
||||
let lastPlaying: string | null = null
|
||||
|
||||
return (
|
||||
<box cssClasses={["media-container"]}>
|
||||
@@ -18,31 +19,24 @@ export default function Media() {
|
||||
<box
|
||||
$={(box) => {
|
||||
const updateVisibility = () => {
|
||||
let hasPlaying = false
|
||||
for (const player of players) {
|
||||
if (
|
||||
player.playback_status ===
|
||||
AstalMpris.PlaybackStatus.PLAYING
|
||||
) {
|
||||
hasPlaying = true
|
||||
break
|
||||
}
|
||||
const activePlayer = players.find(
|
||||
(p) =>
|
||||
p.playback_status === AstalMpris.PlaybackStatus.PLAYING,
|
||||
)
|
||||
|
||||
if (activePlayer) {
|
||||
lastPlaying = activePlayer.bus_name
|
||||
}
|
||||
|
||||
let first = true
|
||||
const targetPlayer =
|
||||
activePlayer ||
|
||||
players.find((p) => p.bus_name === lastPlaying) ||
|
||||
players[0]
|
||||
|
||||
let child = box.get_first_child()
|
||||
for (const player of players) {
|
||||
if (!child) break
|
||||
|
||||
if (hasPlaying) {
|
||||
child.set_visible(
|
||||
player.playback_status ===
|
||||
AstalMpris.PlaybackStatus.PLAYING,
|
||||
)
|
||||
} else {
|
||||
child.set_visible(first)
|
||||
first = false
|
||||
}
|
||||
child.set_visible(player === targetPlayer)
|
||||
child = child.get_next_sibling()
|
||||
}
|
||||
}
|
||||
@@ -58,18 +52,23 @@ export default function Media() {
|
||||
players.forEach((p, i) => {
|
||||
try {
|
||||
p.disconnect(connections[i])
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
})
|
||||
})
|
||||
}}
|
||||
>
|
||||
{players.map((player) => (
|
||||
<button
|
||||
cssClasses={["media-btn"]}
|
||||
onClicked={() =>
|
||||
console.log("Expand Media Controls - Phase 7")
|
||||
}
|
||||
>
|
||||
{players.map((player) => {
|
||||
const playbackIcon = createBinding(
|
||||
player,
|
||||
"playback-status",
|
||||
)((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}>
|
||||
{/* Fallback to an icon if cover-art is empty */}
|
||||
<image
|
||||
@@ -85,8 +84,66 @@ export default function Media() {
|
||||
ellipsize={3} // Pango.EllipsizeMode.END
|
||||
/>
|
||||
</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
|
||||
$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>
|
||||
)
|
||||
}}
|
||||
|
||||
@@ -19,7 +19,9 @@ export function Clock() {
|
||||
<menubutton cssClasses={["clock-btn"]} halign={Gtk.Align.CENTER}>
|
||||
<label label={time} />
|
||||
<popover>
|
||||
<box css="padding: 12px;">
|
||||
<Gtk.Calendar />
|
||||
</box>
|
||||
</popover>
|
||||
</menubutton>
|
||||
)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Gtk } from "ags/gtk4"
|
||||
import { execAsync } from "ags/process"
|
||||
import { createPoll } from "ags/time"
|
||||
|
||||
|
||||
Reference in new issue
Block a user