hyprwm / hyprlock

Hyprland's GPU-accelerated screen locking utility
BSD 3-Clause "New" or "Revised" License
773 stars 59 forks source link

Command output texts markup not parsed #503

Closed abkein closed 2 weeks ago

abkein commented 2 weeks ago

Regression?

No

Hyprlock Info and Version

<0.4.1-1>

Hyprlock config ```sh background { color = rgba(13131377) path = ~/Pictures/Wallpapers/memorize.jpg blur_size = 1#5 blur_passes = 1#4 brightness = 0.7 noise = 0.01 } input-field { monitor = eDP-1 size = 250, 50 outline_thickness = 2 dots_size = 0.1 dots_spacing = 0.3 outer_color = rgba(91919155) inner_color = rgba(13131311) font_color = rgba(C6C6C6FF) fade_on_empty = true position = 0, 20 halign = center valign = center } label { monitor = text = cmd[update:1000] ~/.config/hypr/hyprlock/label.sh shadow_passes = 1 shadow_boost = 0.5 color = rgba(E2E2E2FF) font_size = 14 font_family = Gabarito position = 0, -40 halign = center valign = center } ``` `~/.config/hypr/hyprlock/label.sh`: ```sh #!/usr/bin/env bash user=$(whoami) echo "Hi there,
$user" ```

Compositor Info and Version

System/Version info ```sh Hyprland, built from branch at commit 0f594732b063a90d44df8c5d402d658f27471dfe (props: bump version to 0.43.0). Date: Sun Sep 8 16:48:21 2024 Tag: v0.43.0, commits: 5196 flags: (if any) System Information: System name: Linux Node name: aleaf Release: 6.10.10-arch1-1 Version: #1 SMP PREEMPT_DYNAMIC Thu, 12 Sep 2024 17:21:02 +0000 GPU information: 04:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Phoenix1 [1002:15bf] (rev c7) (prog-if 00 [VGA controller]) os-release: NAME="Arch Linux" PRETTY_NAME="Arch Linux" ID=arch BUILD_ID=rolling ANSI_COLOR="38;2;23;147;209" HOME_URL="https://archlinux.org/" DOCUMENTATION_URL="https://wiki.archlinux.org/" SUPPORT_URL="https://bbs.archlinux.org/" BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues" PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/" LOGO=archlinux-logo plugins: ```

Description

When I use plain echo

label {
    ...
    text = cmd[update:1000] echo "Hi there, <br/> $USER"
    ...
}

Line break is parsed

But if I write script

#!/usr/bin/env bash
user=$(whoami)
echo "Hi there, <br/> $user"
label {
    ...
    text = cmd[update:1000] ~/.config/hypr/hyprlock/label.sh
    ...
}

Line break is not parsed and appears in the text

Wrapping it with echo text=cmd[update:1000] echo $(~/.config/hypr/hyprlock/label.sh) not helps

How to reproduce

Copy-paste my config

Crash reports, logs, images, videos

No response

PaideiaDilemma commented 2 weeks ago

In your script you can just use "\n" or whatever. <br/> was just chosen for the config, so that you have a way to represent a line break. bash obviously has no idea about <br/>

abkein commented 2 weeks ago

But what about other elements, like span? It is also leaved untouched

PaideiaDilemma commented 2 weeks ago

span is different. It is used by pango markup. You can also pass that via a script.

So <br/> does not work, when it is within your command output. You should use an actual new line instead. Pango markup can be within your command output as well :)

abkein commented 2 weeks ago

So

label { # Greeting
    monitor = 
    text = cmd[update:1000] ~/.config/hypr/hyprlock/label.sh
    shadow_passes = 1
    shadow_boost = 0.5
    color = $text_color
    font_size = 14
    font_family = $font_family

    position = 0, -40
    halign = center
    valign = center
}
label { # Some text
    monitor = 
    text = cmd[update:1000] cat ~/.config/hypr/hyprlock/text.markup
    shadow_passes = 1
    shadow_boost = 0.5
    color = $text_color

    position = 0, 20
    halign = left
    valign = bottom
}

label.sh:

#!/usr/bin/env bash

echo "Hi, there"
user=$(whoami)
echo "$user"

text.markup:

<span color="##E2E2E2" bgcolor="##2980B9" bgalpha="50%" face="Gabarito" size="20pt">
    Alles muss sich veraendern
</span>

All this produces:

IMG warning

sc

Look at the text below input field and in the left-bottom corner. No line breaks and span not parsed

abkein commented 2 weeks ago

My bad Double ## required in conf file are unnecessary in file. And line-breaks can be inserted like this:

echo "<span>$text"
echo -n "</span>"