validate profile image and create fallback (#67)

* validate profile image and create fallback

* Update modules/menus/dashboard/profile/index.ts

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>

* Update modules/menus/dashboard/profile/index.ts

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>

* Update options.ts

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>

* Update modules/menus/dashboard/profile/index.ts

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>

* Update modules/menus/dashboard/profile/index.ts

---------

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
This commit is contained in:
matavach
2024-08-04 00:01:38 -05:00
committed by GitHub
parent 6166fdbe0f
commit a6d6a34ea7
2 changed files with 10 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
import icons from "../../../icons/index.js";
import powermenu from "../../power/helpers/actions.js";
import { PowerOptions } from "lib/types/options.js";
import GdkPixbuf from "types/@girs/gdkpixbuf-2.0/gdkpixbuf-2.0.js";
import options from "options";
const { image, name } = options.menus.dashboard.powermenu.avatar;
@@ -24,7 +25,14 @@ const Profile = () => {
Widget.Icon({
hpack: "center",
class_name: "profile-picture",
icon: image.bind("value"),
icon: image.bind("value").as(i => {
try {
GdkPixbuf.Pixbuf.new_from_file(i);
return i;
} catch {
return "avatar-default-symbolic";
}
}),
}),
Widget.Label({
hpack: "center",

View File

@@ -652,7 +652,7 @@ const options = mkOptions(OPTIONS, {
logout: opt("pkill Hyprland"),
shutdown: opt("shutdown now"),
avatar: {
image: opt("/home/jaskir/Pictures/Icons/900-900-max_catppuccin-mocha_hald8_GaussianRBF_lum1_shape96_near16.png"),
image: opt("avatar-default-symbolic"),
name: opt<"system" | string>("system"),
},
},