Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify any value for "height" and/or "width" options in layout file are all acting as 1. #58

Open
shericWu opened this issue Jun 27, 2024 · 2 comments · May be fixed by #63
Open

Specify any value for "height" and/or "width" options in layout file are all acting as 1. #58

shericWu opened this issue Jun 27, 2024 · 2 comments · May be fixed by #63

Comments

@shericWu
Copy link

shericWu commented Jun 27, 2024

Hi, I really love this project since there are a lot of customization available, but I found one small problem.

According to man 5 wlogout:

height and width are values between 0.0 and 1.0 that control the location of where text is displayed the default width 0.5, height 0.9
avalible

But from my testing on wlogout 1.2.2-0, installed via pacman on Arch and hyprland, setting any value for "width" will place the text to the right side; any value for "height" will place the text to the bottom.
For example, the following layout file (which is default layout + "width" : 0.5) with default style.css will produce the following result.

{
    "label" : "lock",
    "action" : "loginctl lock-session",
    "text" : "Lock",
    "keybind" : "l",
    "width" : 0.5
}
{
    "label" : "hibernate",
    "action" : "systemctl hibernate",
    "text" : "Hibernate",
    "keybind" : "h"
}
{
    "label" : "logout",
    "action" : "loginctl terminate-user $USER",
    "text" : "Logout",
    "keybind" : "e"
}
{
    "label" : "shutdown",
    "action" : "systemctl poweroff",
    "text" : "Shutdown",
    "keybind" : "s"
}
{
    "label" : "suspend",
    "action" : "systemctl suspend",
    "text" : "Suspend",
    "keybind" : "u"
}
{
    "label" : "reboot",
    "action" : "systemctl reboot",
    "text" : "Reboot",
    "keybind" : "r"
}

20240627-224308
As the pictures shows, the text "Lock" is placed to the right side (which I assume is value 1). Not sure can anyone reproduce that.

@it2000-the-original
Copy link

I also discovered the same thing: when you specify a width in the layout file, you will see the text shifted in the right side

@Samferos Samferos linked a pull request Sep 19, 2024 that will close this issue
@Samferos
Copy link

static gboolean get_buttons(FILE *json)
[...]
else if (strcmp(tmp, "height") == 0)
            {
                if (tok[i].type != JSMN_PRIMITIVE ||
                    !isdigit(buffer[tok[i].start]))
                {
                    fprintf(stderr, "Invalid height\n");
                }
                else
                {
                    buttons[num_buttons - 1].yalign = buffer[tok[i].start];
                }
            }
            else if (strcmp(tmp, "width") == 0)
            {
                if (tok[i].type != JSMN_PRIMITIVE ||
                    !isdigit(buffer[tok[i].start]))
                {
                    fprintf(stderr, "Invalid width\n");
                }
                else
                {
                    buttons[num_buttons - 1].xalign = buffer[tok[i].start];
                }
            }
[...]

the values are being incorrectly assigned to the ascii code of the first character of the token

buttons[num_buttons - 1].yalign = buffer[tok[i].start];
buttons[num_buttons - 1].xalign = buffer[tok[i].start];

i made a fix in #63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants