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:
@@ -1,6 +1,7 @@
|
|||||||
import icons from "../../../icons/index.js";
|
import icons from "../../../icons/index.js";
|
||||||
import powermenu from "../../power/helpers/actions.js";
|
import powermenu from "../../power/helpers/actions.js";
|
||||||
import { PowerOptions } from "lib/types/options.js";
|
import { PowerOptions } from "lib/types/options.js";
|
||||||
|
import GdkPixbuf from "types/@girs/gdkpixbuf-2.0/gdkpixbuf-2.0.js";
|
||||||
|
|
||||||
import options from "options";
|
import options from "options";
|
||||||
const { image, name } = options.menus.dashboard.powermenu.avatar;
|
const { image, name } = options.menus.dashboard.powermenu.avatar;
|
||||||
@@ -24,7 +25,14 @@ const Profile = () => {
|
|||||||
Widget.Icon({
|
Widget.Icon({
|
||||||
hpack: "center",
|
hpack: "center",
|
||||||
class_name: "profile-picture",
|
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({
|
Widget.Label({
|
||||||
hpack: "center",
|
hpack: "center",
|
||||||
|
|||||||
@@ -652,7 +652,7 @@ const options = mkOptions(OPTIONS, {
|
|||||||
logout: opt("pkill Hyprland"),
|
logout: opt("pkill Hyprland"),
|
||||||
shutdown: opt("shutdown now"),
|
shutdown: opt("shutdown now"),
|
||||||
avatar: {
|
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"),
|
name: opt<"system" | string>("system"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user