✨ ags: optimizations, add media and separator widgets
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import { readFile } from "astal";
|
import { readFile } from "astal";
|
||||||
import { getUserDirs } from "./user";
|
import { getUserDirs } from "./user";
|
||||||
|
|
||||||
export abstract class Wal {
|
export class Wal {
|
||||||
getColors(): JSON {
|
public static getColors(): JSON {
|
||||||
return JSON.parse(
|
return JSON.parse(
|
||||||
readFile(`${getUserDirs().cache}/wal/colors.json`)!
|
readFile(`${getUserDirs().cache}/wal/colors.json`)!
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -40,10 +40,23 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& > .bar-centerbox > * {
|
& > .bar-centerbox > * {
|
||||||
background: rgba($color: wal.$background, $alpha: .6);
|
background: rgba($color: wal.$background, $alpha: .6);
|
||||||
padding: 6px;
|
padding: 6px;
|
||||||
border-radius: 18px;
|
border-radius: 18px;
|
||||||
|
|
||||||
|
& > * {
|
||||||
|
margin: 0 2px;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,6 +117,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.media-eventbox {
|
||||||
|
& > .media > box {
|
||||||
|
border-radius: 12px;
|
||||||
|
background: wal.$color2;
|
||||||
|
padding: 0 6px;
|
||||||
|
|
||||||
|
& .icon {
|
||||||
|
margin-right: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.tray {
|
.tray {
|
||||||
padding: 0 6px;
|
padding: 0 6px;
|
||||||
|
|
||||||
|
|||||||
+20
-20
@@ -1,26 +1,26 @@
|
|||||||
// SCSS Variables
|
// SCSS Variables
|
||||||
// Generated by 'wal'
|
// Generated by 'wal'
|
||||||
$wallpaper: "/home/joaov/wallpapers/Bocchi The Rock!.png";
|
$wallpaper: "/home/joaov/wallpapers/Garden Kita.png";
|
||||||
|
|
||||||
// Special
|
// Special
|
||||||
$background: #0a0a0c;
|
$background: #101212;
|
||||||
$foreground: #c1c1c2;
|
$foreground: #c3c3c3;
|
||||||
$cursor: #c1c1c2;
|
$cursor: #c3c3c3;
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
$color0: #0a0a0c;
|
$color0: #101212;
|
||||||
$color1: #935d6d;
|
$color1: #59662a;
|
||||||
$color2: #967e84;
|
$color2: #517047;
|
||||||
$color3: #ac8486;
|
$color3: #87863c;
|
||||||
$color4: #bcae7a;
|
$color4: #707b48;
|
||||||
$color5: #a49c9c;
|
$color5: #4b6266;
|
||||||
$color6: #bcb79c;
|
$color6: #84876e;
|
||||||
$color7: #8a8a96;
|
$color7: #8e9898;
|
||||||
$color8: #565669;
|
$color8: #596d6d;
|
||||||
$color9: #C57C92;
|
$color9: #778839;
|
||||||
$color10: #C9A9B0;
|
$color10: #6C965F;
|
||||||
$color11: #E6B1B3;
|
$color11: #B4B350;
|
||||||
$color12: #FBE8A3;
|
$color12: #96A460;
|
||||||
$color13: #DBD1D0;
|
$color13: #658388;
|
||||||
$color14: #FBF5D1;
|
$color14: #B0B493;
|
||||||
$color15: #c1c1c2;
|
$color15: #c3c3c3;
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { Gtk, Widget } from "astal/gtk3";
|
||||||
|
|
||||||
|
export interface SeparatorProps {
|
||||||
|
class?: string;
|
||||||
|
alpha?: number;
|
||||||
|
cssColor?: string;
|
||||||
|
orientation?: Gtk.Orientation;
|
||||||
|
size?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Separator(props: SeparatorProps) {
|
||||||
|
return new Widget.Box({
|
||||||
|
className: `separator separator-${ props.orientation == Gtk.Orientation.VERTICAL ? "vertical" : "horizontal" } ${ props.class && props.class }`,
|
||||||
|
css: `.separator {
|
||||||
|
background: ${ props.cssColor ? props.cssColor : "lightgray" };
|
||||||
|
opacity: ${ props.alpha ? props.alpha : 1 };
|
||||||
|
}
|
||||||
|
.separator-horizontal {
|
||||||
|
padding-right: ${props.size ? props.size : 1 }px;
|
||||||
|
margin: 7px 4px;
|
||||||
|
}
|
||||||
|
.separator-vertical {
|
||||||
|
padding-bottom: ${props.size ? props.size : 1 }px;
|
||||||
|
margin: 4px 7px;
|
||||||
|
}`,
|
||||||
|
} as Widget.BoxProps);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { bind } from "astal";
|
import { bind } from "astal";
|
||||||
import { Widget } from "astal/gtk3";
|
import { Gtk, Widget } from "astal/gtk3";
|
||||||
import AstalWp from "gi://AstalWp?version=0.1";
|
import AstalWp from "gi://AstalWp?version=0.1";
|
||||||
|
|
||||||
const wp = AstalWp.get_default();
|
const wp = AstalWp.get_default();
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
import { Box, Button } from "astal/gtk3/widget";
|
import { Box, Button } from "astal/gtk3/widget";
|
||||||
import { GLib, Variable } from "astal";
|
import { GLib, Variable } from "astal";
|
||||||
|
import { Widget } from "astal/gtk3";
|
||||||
|
|
||||||
const dateTimeFormat = "%A %d, %H:%M"
|
const dateTimeFormat = "%A %d, %H:%M"
|
||||||
const time = new Variable<string>("").poll(600, () =>
|
const time = new Variable<string>("").poll(600, () =>
|
||||||
GLib.DateTime.new_now_local().format(dateTimeFormat)!);
|
GLib.DateTime.new_now_local().format(dateTimeFormat)!);
|
||||||
|
|
||||||
export function Clock(): JSX.Element {
|
export function Clock(): JSX.Element {
|
||||||
return (
|
return new Widget.Box({
|
||||||
<Box className={"clock"}>
|
className: "clock",
|
||||||
<Button label={time()} />
|
child: new Widget.Button({
|
||||||
</Box>
|
label: time()
|
||||||
)
|
} as Widget.ButtonProps)
|
||||||
|
} as Widget.BoxProps);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ const hyprland = AstalHyprland.get_default();
|
|||||||
export function FocusedWindow() {
|
export function FocusedWindow() {
|
||||||
return new Widget.Box({
|
return new Widget.Box({
|
||||||
className: "focused-window",
|
className: "focused-window",
|
||||||
|
visible: bind(hyprland, "focusedClient").as(Boolean),
|
||||||
children: [
|
children: [
|
||||||
new Widget.Icon({
|
new Widget.Icon({
|
||||||
className: "icon",
|
className: "icon",
|
||||||
icon: bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) => {
|
icon: bind(hyprland, "focusedClient").as(Boolean) && bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) => {
|
||||||
switch(client.initialClass) {
|
switch(client.initialClass) {
|
||||||
case "zen":
|
case "zen":
|
||||||
return "zen-browser";
|
return "zen-browser";
|
||||||
@@ -28,12 +29,12 @@ export function FocusedWindow() {
|
|||||||
new Widget.Label({
|
new Widget.Label({
|
||||||
className: "class",
|
className: "class",
|
||||||
xalign: 0,
|
xalign: 0,
|
||||||
label: bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) => client.get_class())
|
label: bind(hyprland, "focusedClient").as(Boolean) && bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) => client.get_class())
|
||||||
} as Widget.LabelProps),
|
} as Widget.LabelProps),
|
||||||
new Widget.Label({
|
new Widget.Label({
|
||||||
className: "title",
|
className: "title",
|
||||||
xalign: 0,
|
xalign: 0,
|
||||||
label: bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) => client.get_title())
|
label: bind(hyprland, "focusedClient").as(Boolean) && bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) => client.get_title())
|
||||||
} as Widget.LabelProps)
|
} as Widget.LabelProps)
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import { bind } from "astal";
|
||||||
|
import { Gtk, Widget } from "astal/gtk3";
|
||||||
|
import AstalMpris from "gi://AstalMpris";
|
||||||
|
import { Separator, SeparatorProps } from "../Separator";
|
||||||
|
import { Wal } from "../../scripts/pywal";
|
||||||
|
|
||||||
|
const mpris: AstalMpris.Mpris = AstalMpris.get_default();
|
||||||
|
let defaultPlayer: (AstalMpris.Player|undefined) = mpris.get_players()?.[0];
|
||||||
|
|
||||||
|
const playerIcons = {
|
||||||
|
spotify: '',
|
||||||
|
clapper: '',
|
||||||
|
spotube: '',
|
||||||
|
firefox: ''
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Media(): JSX.Element {
|
||||||
|
|
||||||
|
bind(mpris, "players")?.as((players: Array<AstalMpris.Player>) => {
|
||||||
|
defaultPlayer = players?.[0] as AstalMpris.Player;
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Widget.EventBox({
|
||||||
|
className: "media-eventbox",
|
||||||
|
visible: bind(mpris, "players").as((players: Array<AstalMpris.Player>) => players?.[0]).as(Boolean),
|
||||||
|
child: new Widget.Box({
|
||||||
|
className: "media",
|
||||||
|
children: [
|
||||||
|
new Widget.Box({
|
||||||
|
children: [
|
||||||
|
new Widget.Label({
|
||||||
|
className: "icon",
|
||||||
|
label: defaultPlayer && bind(defaultPlayer, "busName")?.as((name: string) => {
|
||||||
|
const banana: Array<string> = name.split('.');
|
||||||
|
const playerName: string = banana[banana.length-1];
|
||||||
|
return playerIcons[playerName as keyof typeof playerIcons] || '';
|
||||||
|
})
|
||||||
|
} as Widget.LabelProps),
|
||||||
|
new Widget.Label({
|
||||||
|
className: "title",
|
||||||
|
label: defaultPlayer && bind(defaultPlayer, "title")?.as((title: string) => title)
|
||||||
|
} as Widget.LabelProps),
|
||||||
|
Separator({
|
||||||
|
size: 2,
|
||||||
|
cssColor: `rgb(150, 150, 150)`,
|
||||||
|
alpha: 1
|
||||||
|
} as SeparatorProps),
|
||||||
|
new Widget.Label({
|
||||||
|
className: "artist",
|
||||||
|
label: defaultPlayer && bind(defaultPlayer, "artist")?.as((artist: string) => artist)
|
||||||
|
} as Widget.LabelProps)
|
||||||
|
]
|
||||||
|
} as Widget.BoxProps),
|
||||||
|
new Widget.Revealer({
|
||||||
|
transitionType: Gtk.RevealerTransitionType.SLIDE_RIGHT,
|
||||||
|
transitionDuration: 400,
|
||||||
|
revealChild: false //FIXME
|
||||||
|
} as Widget.RevealerProps)
|
||||||
|
]
|
||||||
|
} as Widget.BoxProps)
|
||||||
|
} as Widget.EventBoxProps);
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import { Tray } from "../widget/bar/Tray";
|
|||||||
import { Workspaces } from "../widget/bar/Workspaces";
|
import { Workspaces } from "../widget/bar/Workspaces";
|
||||||
import { Audio } from "../widget/bar/Audio";
|
import { Audio } from "../widget/bar/Audio";
|
||||||
import { FocusedWindow } from "../widget/bar/FocusedWindow";
|
import { FocusedWindow } from "../widget/bar/FocusedWindow";
|
||||||
|
import { Media } from "../widget/bar/Media";
|
||||||
|
|
||||||
export function Bar(monitor: number = 0, width: (number|undefined) = undefined, height: (number|undefined) = undefined) {
|
export function Bar(monitor: number = 0, width: (number|undefined) = undefined, height: (number|undefined) = undefined) {
|
||||||
return (
|
return (
|
||||||
@@ -32,6 +33,7 @@ export function Bar(monitor: number = 0, width: (number|undefined) = undefined,
|
|||||||
vertical={ false } homogeneous={ false }>
|
vertical={ false } homogeneous={ false }>
|
||||||
|
|
||||||
<Clock />
|
<Clock />
|
||||||
|
<Media />
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box className={ "widgets-right" } halign={ Gtk.Align.END }
|
<Box className={ "widgets-right" } halign={ Gtk.Align.END }
|
||||||
|
|||||||
Reference in New Issue
Block a user