1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat(wired): fix button bar inducing offset on other notifications; add test script

This commit is contained in:
oddlama 2023-10-14 21:34:03 +02:00
parent f9c4279de2
commit 88a547f6f5
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
2 changed files with 131 additions and 20 deletions

View file

@ -0,0 +1,117 @@
#!/usr/bin/env bash
short_summary=("Short summary")
long_summary=("Long summary, it will be truncated because it is really really long")
short_body=("Short body.")
long_body=("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.")
app_discord=(
"--app-name=Discord"
"--icon=/run/current-system/etc/profiles/per-user/$USER/share/pixmaps/discord.png"
)
image_1=("--hint=string:image-path:$HOME/Downloads/wallpaper.png")
urgency_low=("--urgency=low")
urgency_normal=("--urgency=normal")
urgency_critical=("--urgency=critical")
slider_0=("-h" "int:value:0")
slider_25=("-h" "int:value:25")
slider_100=("-h" "int:value:100")
actions_yes_no=("-A" "yes" "-A" "no")
actions_5=("-A" "yes" "-A" "no" "-A" "maybe" "-A" "cancel" "-A" "very long name is truncated")
function show() {
args=()
while [[ $# -gt 0 ]]; do
if [[ -v "$1" ]]; then
x="$1[@]"
args+=("${!x}")
else
args+=("$1")
fi
shift
done
notify-send "${args[@]}"
}
show short_summary
show long_summary
show long_summary long_body
show "Low urgency" short_body urgency_low
show "Normal urgency" short_body urgency_normal
show "Critical urgency" short_body urgency_critical
show "With app icon and name" app_discord
show "With app icon and name" long_body app_discord
show "With image" short_body image_1
show "With image and body" long_body image_1
show "With progress" slider_0
show "With progress" slider_25
show "With progress and body" short_body slider_100
show "With buttons" actions_yes_no
show "With buttons and body" long_body actions_5
show "With everything" long_body app_discord image_1 slider_25 actions_5
#for summary in \
# "Short summary" \
# "Long summary, it will be truncated because it is really really long" \
#; do
#
#for body in \
# "Short body." \
# "$lorem" \
#; do
#
#for app in \
# "empty[@]" \
# "app_discord[@]" \
#; do
#
#for image in \
# "empty[@]" \
# "image_1[@]" \
#; do
#
#for urgency in \
# "urgency_low[@]" \
# "urgency_normal[@]" \
# "urgency_critical[@]" \
#; do
#
#for progress in \
# "empty[@]" \
# "slider_0[@]" \
# "slider_25[@]" \
# "slider_100[@]" \
#; do
#
#for action in \
# "empty[@]" \
#; do
# #"actions_yes_no[@]" \
# #"actions_5[@]" \
#
#notify-send "$summary" "$body" \
# "${!app}" \
# "${!image}" \
# "${!progress}" \
# "${!action}" \
# "${!urgency}" \
# ;
#
#done
#done
#done
#done
#done
#done
#done

View file

@ -141,7 +141,7 @@
font = "${fonts.sansSerif.name} Bold ${toString (globalScale * 16)}";
ellipsize = mkLiteral "End";
color = colors.base06;
padding = mkPaddingLrBt 16 16 0 8;
padding = mkPaddingLrBt 16 16 12 8;
dimensions = mkDimensionsWH (maxWFull - summaryRightPadding) (maxWFull - summaryRightPadding) 0 30;
dimensions_image_hint = mkDimensionsWH (maxWImg - summaryRightPadding) (maxWImg - summaryRightPadding) 0 30;
dimensions_image_both = mkDimensionsWH (maxWImg - summaryRightPadding) (maxWImg - summaryRightPadding) 0 30;
@ -151,7 +151,7 @@
name = "${name}_${ident}_body";
parent = "${name}_${ident}_summary";
hook = mkHook "BL" "TL";
offset = mkVec2 0 12;
offset = mkVec2 0 0;
render_criteria = [
(And [
(Or extra.render_criteria)
@ -163,7 +163,7 @@
font = "${fonts.sansSerif.name} ${toString (globalScale * 16)}";
ellipsize = mkLiteral "End";
color = colors.base06;
padding = mkPaddingLrBt 16 16 12 0;
padding = mkPaddingLrBt 16 16 12 (-4);
dimensions = mkDimensionsWH maxWFull maxWFull 0 88;
dimensions_image_hint = mkDimensionsWH maxWImg maxWImg 0 88;
dimensions_image_both = mkDimensionsWH maxWImg maxWImg 0 88;
@ -174,7 +174,7 @@
# on the specific name for the parent, which cannot be changed dynamically.
# So each call to mkBody creates these progress bars which only differ in
# their parent :/
++ (mkProgress name "${ident}_hint" 0 {
++ (mkProgress name "${ident}_hint" (-4) {
render_criteria = [
(And (extra.render_criteria
++ [
@ -193,7 +193,7 @@
]))
];
})
++ (mkProgress name "${ident}_summary" 9 {
++ (mkProgress name "${ident}_summary" 0 {
render_criteria = [
(And (extra.render_criteria
++ [
@ -209,7 +209,7 @@
# Each mkProgress includes a button bar. But if no progress is included in a notification,
# those won't be rendered, so we have to define bars for non-progress notifications.
# (And yes, we need 3 because we cannot have duplicate names or dynamic parents)
++ (mkButtonBar name "${ident}_hint" 0 {
++ (mkButtonBar name "${ident}_hint" {
render_criteria = [
(And (extra.render_criteria
++ [
@ -218,7 +218,7 @@
]))
];
})
++ (mkButtonBar name "${ident}_body" (-8) {
++ (mkButtonBar name "${ident}_body" {
render_criteria = [
(And (extra.render_criteria
++ [
@ -228,7 +228,7 @@
]))
];
})
++ (mkButtonBar name "${ident}_summary" 0 {
++ (mkButtonBar name "${ident}_summary" {
render_criteria = [
(And (extra.render_criteria
++ [
@ -279,22 +279,16 @@
});
}
]
++ (mkButtonBar name "progress_${parent}_text" (
/*
ignore bottom end padding
*/
-8
)
extra)
++ (mkButtonBar name "progress_${parent}_text" extra)
);
mkButtonBar = name: parent: yOffset: extra:
mkButtonBar = name: parent: extra:
map (x: extra // x) (lib.flatten [
{
name = "${name}_button_bar_for_${parent}";
parent = "${name}_${parent}";
hook = mkHook "BL" "TL";
offset = mkVec2 0 yOffset;
offset = mkVec2 0 0;
render_criteria = [
(And (extra.render_criteria
++ [
@ -313,7 +307,7 @@
font = "${fonts.monospace.name} ${toString (globalScale * 14)}";
color = colors.base06;
padding = mkPaddingLrBt 0 0 0 0;
dimensions = mkDimensionsWH 568 568 56 48;
dimensions = mkDimensionsWH 568 568 44 44;
});
}
(lib.flip map [0 1 2 3 4 5] (
@ -321,7 +315,7 @@
lib.optionalAttrs (i == 0) {
parent = "${name}_button_bar_for_${parent}";
hook = mkHook "TL" "TL";
offset = mkVec2 16 12;
offset = mkVec2 16 0;
}
// lib.optionalAttrs (i != 0) {
parent = "${name}_action_${toString (i - 1)}_for_${parent}";
@ -374,7 +368,7 @@
replacing_enabled = true;
replacing_resets_timeout = true;
min_window_width = floor (globalScale * 600);
min_window_height = floor (globalScale * 60);
min_window_height = floor (globalScale * 20);
debug = false;
# https://github.com/Toqozz/wired-notify/wiki/Shortcuts