Skip to content

Commit

Permalink
style: format with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed May 29, 2024
1 parent 6aaab9b commit 47e2a51
Show file tree
Hide file tree
Showing 70 changed files with 3,091 additions and 2,949 deletions.
2 changes: 2 additions & 0 deletions config/ags/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
types/
node-modules/
155 changes: 74 additions & 81 deletions config/ags/greeter/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,108 +2,101 @@ import AccountsService from "gi://AccountsService?version=1.0"
import GLib from "gi://GLib?version=2.0"
import icons from "lib/icons"

const { iconFile, realName, userName } = AccountsService.UserManager
.get_default().list_users()[0]
const { iconFile, realName, userName } = AccountsService.UserManager.get_default().list_users()[0]

const loggingin = Variable(false)

const CMD = GLib.getenv("ASZTAL_DM_CMD")
|| "Hyprland"
const CMD = GLib.getenv("ASZTAL_DM_CMD") || "Hyprland"

const ENV = GLib.getenv("ASZTAL_DM_ENV")
|| "WLR_NO_HARDWARE_CURSORS=1 _JAVA_AWT_WM_NONREPARENTING=1"
const ENV =
GLib.getenv("ASZTAL_DM_ENV") || "WLR_NO_HARDWARE_CURSORS=1 _JAVA_AWT_WM_NONREPARENTING=1"

async function login(pw: string) {
loggingin.value = true
const greetd = await Service.import("greetd")
return greetd.login(userName, pw, CMD, ENV.split(/\s+/))
.catch(res => {
loggingin.value = false
response.label = res?.description || JSON.stringify(res)
password.text = ""
revealer.reveal_child = true
})
loggingin.value = true
const greetd = await Service.import("greetd")
return greetd.login(userName, pw, CMD, ENV.split(/\s+/)).catch((res) => {
loggingin.value = false
response.label = res?.description || JSON.stringify(res)
password.text = ""
revealer.reveal_child = true
})
}

const avatar = Widget.Box({
class_name: "avatar",
hpack: "center",
css: `background-image: url('${iconFile}')`,
class_name: "avatar",
hpack: "center",
css: `background-image: url('${iconFile}')`,
})

const password = Widget.Entry({
placeholder_text: "Password",
hexpand: true,
visibility: false,
on_accept: ({ text }) => { login(text || "") },
placeholder_text: "Password",
hexpand: true,
visibility: false,
on_accept: ({ text }) => {
login(text || "")
},
})

const response = Widget.Label({
class_name: "response",
wrap: true,
max_width_chars: 35,
hpack: "center",
hexpand: true,
xalign: .5,
class_name: "response",
wrap: true,
max_width_chars: 35,
hpack: "center",
hexpand: true,
xalign: 0.5,
})

const revealer = Widget.Revealer({
transition: "slide_down",
child: response,
transition: "slide_down",
child: response,
})

export default Widget.Box({
class_name: "auth",
attribute: { password },
vertical: true,
children: [
Widget.Overlay({
child: Widget.Box(
{
css: "min-width: 200px; min-height: 200px;",
vertical: true,
},
Widget.Box({
class_name: "wallpaper",
css: `background-image: url('${WALLPAPER}')`,
}),
Widget.Box({
class_name: "wallpaper-contrast",
vexpand: true,
}),
),
overlay: Widget.Box(
{
vpack: "end",
vertical: true,
},
avatar,
Widget.Box({
hpack: "center",
children: [
Widget.Icon(icons.ui.avatar),
Widget.Label(realName || userName),
],
}),
Widget.Box(
{
class_name: "password",
},
Widget.Spinner({
visible: loggingin.bind(),
active: true,
}),
Widget.Icon({
visible: loggingin.bind().as(b => !b),
icon: icons.ui.lock,
}),
password,
),
),
class_name: "auth",
attribute: { password },
vertical: true,
children: [
Widget.Overlay({
child: Widget.Box(
{
css: "min-width: 200px; min-height: 200px;",
vertical: true,
},
Widget.Box({
class_name: "wallpaper",
css: `background-image: url('${WALLPAPER}')`,
}),
Widget.Box({
class_name: "wallpaper-contrast",
vexpand: true,
})
),
overlay: Widget.Box(
{
vpack: "end",
vertical: true,
},
avatar,
Widget.Box({
hpack: "center",
children: [Widget.Icon(icons.ui.avatar), Widget.Label(realName || userName)],
}),
Widget.Box(
{ class_name: "response-box" },
revealer,
),
],
{
class_name: "password",
},
Widget.Spinner({
visible: loggingin.bind(),
active: true,
}),
Widget.Icon({
visible: loggingin.bind().as((b) => !b),
icon: icons.ui.lock,
}),
password
)
),
}),
Widget.Box({ class_name: "response-box" }, revealer),
],
})
50 changes: 25 additions & 25 deletions config/ags/greeter/greeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ import statusbar from "./statusbar"
import auth from "./auth"

const win = RegularWindow({
name: "greeter",
setup: self => {
self.set_default_size(500, 500)
self.show_all()
auth.attribute.password.grab_focus()
},
child: Widget.Overlay({
child: Widget.Box({ expand: true }),
overlays: [
Widget.Box({
vpack: "start",
hpack: "fill",
hexpand: true,
child: statusbar,
}),
Widget.Box({
vpack: "center",
hpack: "center",
child: auth,
}),
],
}),
name: "greeter",
setup: (self) => {
self.set_default_size(500, 500)
self.show_all()
auth.attribute.password.grab_focus()
},
child: Widget.Overlay({
child: Widget.Box({ expand: true }),
overlays: [
Widget.Box({
vpack: "start",
hpack: "fill",
hexpand: true,
child: statusbar,
}),
Widget.Box({
vpack: "center",
hpack: "center",
child: auth,
}),
],
}),
})

App.config({
icons: "./assets",
windows: [win],
cursorTheme: GLib.getenv("XCURSOR_THEME")!,
icons: "./assets",
windows: [win],
cursorTheme: GLib.getenv("XCURSOR_THEME")!,
})
16 changes: 8 additions & 8 deletions config/ags/greeter/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import AccountsService from "gi://AccountsService?version=1.0"
const { userName } = AccountsService.UserManager.get_default().list_users()[0]

declare global {
const WALLPAPER: string
const WALLPAPER: string
}

Object.assign(globalThis, {
TMP: `${GLib.get_tmp_dir()}/greeter`,
OPTIONS: "/var/cache/greeter/options.json",
WALLPAPER: "/var/cache/greeter/background",
// TMP: "/tmp/ags",
// OPTIONS: Utils.CACHE_DIR + "/options.json",
// WALLPAPER: Utils.HOME + "/.config/background",
USER: userName,
TMP: `${GLib.get_tmp_dir()}/greeter`,
OPTIONS: "/var/cache/greeter/options.json",
WALLPAPER: "/var/cache/greeter/background",
// TMP: "/tmp/ags",
// OPTIONS: Utils.CACHE_DIR + "/options.json",
// WALLPAPER: Utils.HOME + "/.config/background",
USER: userName,
})

Utils.ensureDirectory(TMP)
45 changes: 21 additions & 24 deletions config/ags/greeter/statusbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,35 @@ const { monochrome } = options.bar.powermenu
const { format } = options.bar.date

const poweroff = PanelButton({
class_name: "powermenu",
child: Widget.Icon(icons.powermenu.shutdown),
on_clicked: () => Utils.exec("shutdown now"),
setup: self => self.hook(monochrome, () => {
self.toggleClassName("colored", !monochrome.value)
self.toggleClassName("box")
class_name: "powermenu",
child: Widget.Icon(icons.powermenu.shutdown),
on_clicked: () => Utils.exec("shutdown now"),
setup: (self) =>
self.hook(monochrome, () => {
self.toggleClassName("colored", !monochrome.value)
self.toggleClassName("box")
}),
})

const date = PanelButton({
class_name: "date",
child: Widget.Label({
label: clock.bind().as(c => c.format(`${format}`)!),
}),
class_name: "date",
child: Widget.Label({
label: clock.bind().as((c) => c.format(`${format}`)!),
}),
})

const darkmode = PanelButton({
class_name: "darkmode",
child: Widget.Icon({ icon: scheme.bind().as(s => icons.color[s]) }),
on_clicked: () => scheme.value = scheme.value === "dark" ? "light" : "dark",
class_name: "darkmode",
child: Widget.Icon({ icon: scheme.bind().as((s) => icons.color[s]) }),
on_clicked: () => (scheme.value = scheme.value === "dark" ? "light" : "dark"),
})

export default Widget.CenterBox({
class_name: "bar",
hexpand: true,
center_widget: date,
end_widget: Widget.Box({
hpack: "end",
children: [
darkmode,
BatteryBar(),
poweroff,
],
}),
class_name: "bar",
hexpand: true,
center_widget: date,
end_widget: Widget.Box({
hpack: "end",
children: [darkmode, BatteryBar(), poweroff],
}),
})
19 changes: 9 additions & 10 deletions config/ags/lib/battery.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import icons from "./icons"

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
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",
})
Utils.notify({
summary: `${percent}% Battery Percentage`,
iconName: icons.battery.warning,
urgency: "critical",
})
})
}
10 changes: 5 additions & 5 deletions config/ags/lib/gtk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import Gio from "gi://Gio"
import options from "options"

const settings = new Gio.Settings({
schema: "org.gnome.desktop.interface",
schema: "org.gnome.desktop.interface",
})

function gtk() {
const scheme = options.theme.scheme.value
settings.set_string("color-scheme", `prefer-${scheme}`)
const scheme = options.theme.scheme.value
settings.set_string("color-scheme", `prefer-${scheme}`)
}

export default function init() {
options.theme.scheme.connect("changed", gtk)
gtk()
options.theme.scheme.connect("changed", gtk)
gtk()
}
Loading

0 comments on commit 47e2a51

Please sign in to comment.