fastfetch-cli / fastfetch

An actively maintained, feature-rich and performance oriented, neofetch like system information tool.
MIT License
9.72k stars 390 forks source link

Fastfetch with Z shell (zsh) “Logo: getCharacterPixelDimensions() failed” error #452

Closed asrmarco13 closed 1 year ago

asrmarco13 commented 1 year ago

Hello everyone. Few months ago I switch to Garuda Linux. I use Konsole as a terminal and my default shell is ZSH (with oh-my-zsh framework and powerlevel10k for theme). How to happens with the Fish Shell when opening the terminal, I want to replicate the same thing with ZSH shell using Fastfetch. I added the following lines to my .zshrc config file like fish .config file:

# Run Fastfetch
if [[ -o interactive ]]; then
fastfetch --load-config dr460nized
fi

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

When i run the command:

source .zshrc

I get everything working fine (I see the correct Garuda Dr460nized logo and informations).

source-zshrc

But when I open a new terminal session I have the following error:

Logo: getCharacterPixelDimensions() failed

and the Garuda logo is not visible (informations displayed are correctly).

zsh-new-terminal-session

How can I fix it? Has anyone had the same problem as me and solved it?

Output of fastfetch --version:

fastfetch 1.11.0 (x86_64)

Output of fastfetch --load-config devinfo:

marcoorfei@IAD238
-----------------
OS: Garuda Linux x86_64
Host: 20QT006UIX (ThinkPad P1 Gen 2)
Kernel: 6.2.10-zen1-1-zen
Uptime: 15 mins
Packages: 1318 (pacman)[stable]
Shell: zsh 5.9
Display 1: 1920x1080 @ 60Hz
Display 2: 1920x1080 @ 60Hz
DE: KDE Plasma 5.27.4
WM: KWin (X11)
WM Theme: Sweet-Dark
Theme: kvantum-dark (Sweet) [QT], Breeze [GTK2], Sweet-Dark [GTK3/4]o                      .@@;.
Icons: BeautyLine [QT], BeautyLine [GTK2/3/4]
Font: Fira Sans (10pt) [QT], Fira Sans (10pt) [GTK2/3/4]
Cursor: Sweet (24px)
Terminal: konsole 22.12.3
Terminal Font: FiraCode Nerd Font Mono (10pt)
CPU: Intel(R) Core(TM) i9-9880H (16) @ 4.8 GHz
GPU: NVIDIA Quadro T2000 Mobile / Max-Q
Memory: 9.07 GiB / 31.03 GiB (29%)
Disk (/): 14.06 GiB / 100.00 GiB (14%)
Disk (/home): 90.98 GiB / 820 GiB (11%)
Battery: 82% [Discharging]
Power Adapter: Not supported on this platform
Locale: en_US.UTF-8

Output of fastfetch --load-config devinfo-verbose:

marcoorfei@IAD238
-----------------
OS: System: Linux; Name: Garuda Linux; Pretty name: Garuda Linux; ID: garuda; ID like: arch; Variant: ; Variant ID: ; Version: ; Version ID: ; Version codename: ; Build ID: rolling; Architecture: x86_64
Host: Family: product_family: ThinkPad P1 Gen 2; product_name: 20QT006UIX; product_version: ThinkPad P1 Gen 2; product_sku: LENOVO_MT_20QT_BU_Think_FM_ThinkPad P1 Gen 2; sys_vendor: LENOVO
Bios: 1.45
Chassis: 10
Kernel: Sysname: Linux; Release: 6.2.10-zen1-1-zen; Version: #1 ZEN SMP PREEMPT_DYNAMIC Fri, 07 Apr 2023 02:10:16 +0000
Uptime: Days: 0; Hours: 0; Minutes: 18; Seconds: 30
Processes: Count: 1198
Packages: All: 1318; pacman: 1318; pacman branch: stable; dpkg: 0; rpm: 0; emerge: 0; eopkg: 0; xbps: 0; apk: 0; flatpak-system: 0; flatpak-user: 0; snap: 0; brew: 0; brew-cask: 0; port: 0; scoop: 0; choco: 0
Shell: Process name: zsh; Process path: /usr/bin/zsh; Process exe: zsh; Process version: 5.9; User path: /bin/zsh; User exe: zsh; User version: 5.9
Display 1: Width: 1920; Height: 1080; Refresh rate: 60.0028; ScaledWith: 1920; ScaledHeight: 1080
Display 2: Width: 1920; Height: 1080; Refresh rate: 60; ScaledWith: 1920; ScaledHeight: 1080
Brightness (nvidia_0): 9%
DE: Process name: plasmashell; Pretty name: KDE Plasma; Version: 5.27.4
WM: Process name: KWin; Pretty name: KWin; Protocol: X11
WM Theme: Name: Sweet-Dark
Theme: Plasma: kvantum-dark; Plasma colors: Sweet; Plasma colors pretty: Sweet; GTK2: Breeze; GTK3: Sweet-Dark; GTK4: Sweet-Dark; GTK: Breeze [GTK2], Sweet-Dark [GTK3/4]
Icons: Plasma: BeautyLine; GTK2: BeautyLine; GTK3: BeautyLine; GTK4: BeautyLine; GTK: BeautyLine [GTK2/3/4]
Font: Font1: Fira Sans (10pt); Font2: Fira Sans (10pt); Font3: Fira Sans (10pt); Font4: Fira Sans (10pt)
Cursor: Theme: Sweet; Size: 24
Terminal: Process: konsole; Path: /usr/bin/konsole; Exe: konsole
Terminal Font: Pretty: FiraCode Nerd Font Mono (10pt); Name: FiraCode Nerd Font Mono; Size: 10; Styles:
CPU: Name: Intel(R) Core(TM) i9-9880H, Vendor: GenuineIntel, CoresPhysical: 8, CoresLogical: 16, CoresOnline: 16, FrequencyMin: 0.8, FrequencyMax: 4.8, Temperature: -nan
CPU Usage: Percentage: 7.54717
GPU: Vendor: NVIDIA; Name: Quadro T2000 Mobile / Max-Q; Driver: nvidia; Temperature: -nan; CoreCount: -1; Type: Discrete
Memory: Used: 9.10 GiB; Total: 31.03 GiB; Percentage: 29
Swap: 0 B / 65.03 GiB (0%)
Disk (/): SizeUsed: 14.06 GiB; SizeTotal: 100.00 GiB; SizePercentage: 14; FilesUsed: 0; FilesTotal: 0; FilesPercentage: 0; Removable: false; Hidden: false; Filesystem: btrfs; Name: /
Disk (/home): SizeUsed: 90.98 GiB; SizeTotal: 820 GiB; SizePercentage: 11; FilesUsed: 0; FilesTotal: 0; FilesPercentage: 0; Removable: false; Hidden: false; Filesystem: btrfs; Name: /home
Battery: Manufactor: SMP; Model: 01YU911; Technology: Li-poly; Capacity: 80; Status: Discharging
Power Adapter: Not supported on this platform
Media Player: No media found
Media: No media found
Date & Time: year: 2023; yearShort: 23; month: 4; monthPretty: 04; monthName: April; monthNameShort: Apr; weekNumber: 16; weekday: Wednesday; weekdayShort: Wed; dayInYear: 109; dayInMonth: 19; dayInWeek: 3; hour: 9; hourPretty: 09; hour12: 9; hour12Pretty: 09; minute: 34; minutePretty: 34; second: 10; secondPretty: 10
Locale: en_US.UTF-8
Vulkan: driver: NVIDIA [530.41.03]; Api Version: 1.3.236; Conformance Version: 1.3.1
OpenGL: version: 4.6.0 NVIDIA 530.41.03; renderer: Quadro T2000/PCIe/SSE2; vendor: NVIDIA Corporation
OpenCL: version: 3.0 CUDA; device: Quadro T2000; vendor: NVIDIA Corporation
Bluetooth: Name: MX Ergo; Address: FB:7C:D2:0B:7B:1D; Type: input-mouse; Battery: 100
Sound: Built-in Audio Analog Stereo (100%)
Gamepad: No devices detected
Weather: +12°C - Sunny (Como, Italy)

Output of fastfetch --list-features:

threads
libpci
vulkan
wayland
xcb-randr
xcb
xrandr
x11
gio
dconf
dbus
imagemagick7
chafa
zlib
xfconf
egl
glx
osmesa
opencl
libpulse
libnm

Another information: Fastfetch is installed by default on Garuda Linux and function correctly with Fish

CarterLi commented 1 year ago

Does sleep 0.5 work?

In addition, you can always set --logo-width and --logo-height to bypass the getCharacterPixelDimensions() function

asrmarco13 commented 1 year ago

Does sleep 0.5 work?

In addition, you can always set --logo-width and --logo-height to bypass the getCharacterPixelDimensions() function

Hi @CarterLi , I followed your instructions. If I use sleep 0.5 or --logo-width or --logo-height sometimes the logo appears and sometimes not. What's wrong?

no-garuda-logo

CarterLi commented 1 year ago

@LinusDierheimer Do you have some ideas?

LinusDierheimer commented 1 year ago

I have wrote a small c program, to debug this. Can you compile and run it?

#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include <termios.h>
#include <poll.h>
#include <sys/ioctl.h>

void ffGetTerminalResponse(const char* request, const char* format, ...)
{
    struct termios oldTerm, newTerm;
    if(tcgetattr(STDIN_FILENO, &oldTerm) == -1)
        return;

    newTerm = oldTerm;
    newTerm.c_lflag &= (tcflag_t) ~(ICANON | ECHO);
    if(tcsetattr(STDIN_FILENO, TCSANOW, &newTerm) == -1)
        return;

    fputs(request, stdout);
    fflush(stdout);

    struct pollfd pfd;
    pfd.fd = STDIN_FILENO;
    pfd.events = POLLIN;
    pfd.revents = 0;

    //Give the terminal 35ms to respond
    if(poll(&pfd, 1, 500) <= 0)
    {
        tcsetattr(STDIN_FILENO, TCSANOW, &oldTerm);
        return;
    }

    char buffer[512];
    ssize_t readed = read(STDIN_FILENO, buffer, sizeof(buffer) - 1);

    tcsetattr(STDIN_FILENO, TCSANOW, &oldTerm);

    if(readed <= 0)
        return;

    buffer[readed] = '\0';

    va_list args;
    va_start(args, format);
    vsscanf(buffer, format, args);
    va_end(args);
}

static void printWinsize(struct winsize* win)
{
    printf("winsize.ws_row: %hu\n", win->ws_row);
    printf("winsize.ws_col: %hu\n", win->ws_col);
    printf("winsize.ws_ypixel: %hu\n", win->ws_ypixel);
    printf("winsize.ws_xpixel: %hu\n", win->ws_xpixel);
}

int main()
{
    struct winsize winsize;

    memset(&winsize, 0, sizeof(struct winsize));
    ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize);
    printWinsize(&winsize);

    putchar('\n');

    memset(&winsize, 0, sizeof(struct winsize));
    ffGetTerminalResponse("\033[18t", "\033[8;%hu;%hut", &winsize.ws_row, &winsize.ws_col);
    ffGetTerminalResponse("\033[14t", "\033[4;%hu;%hut", &winsize.ws_ypixel, &winsize.ws_xpixel);
    printWinsize(&winsize);
}
LinusDierheimer commented 1 year ago

@CarterLi BTW, this is the output within konsole on my machine:

winsize.ws_row: 84
winsize.ws_col: 319
winsize.ws_ypixel: 1438
winsize.ws_xpixel: 2558

winsize.ws_row: 84
winsize.ws_col: 319
winsize.ws_ypixel: 1428
winsize.ws_xpixel: 2552

Slightly different values between ioctl and the escape sequences... Maybe this is causing the bugs with wrong calculated height. The difference gets even bigger when i enable tabbing:

winsize.ws_row: 82
winsize.ws_col: 319
winsize.ws_ypixel: 1405
winsize.ws_xpixel: 2558

winsize.ws_row: 82
winsize.ws_col: 319
winsize.ws_ypixel: 1394
winsize.ws_xpixel: 2552
asrmarco13 commented 1 year ago

Hi @LinusDierheimer , I run your program on my KDE Terminal Emulator (my default terminal):

> gcc fastefecth.c -o fastefecth && "/home/marcoorfei/"fastefecth

winsize.ws_row: 28
winsize.ws_col: 110
winsize.ws_ypixel: 728
winsize.ws_xpixel: 1326

winsize.ws_row: 28
winsize.ws_col: 110
winsize.ws_ypixel: 728
winsize.ws_xpixel: 1320
TheNextRS commented 1 year ago

Bildschirmfoto vom 2023-06-13 11-35-04

Tested on a VM, but I get the same results on physical machines...

I can still explain that there are compatibility problems with the kde konsole. but the output of the gnome terminal makes no sense to me.

CarterLi commented 1 year ago

It makes sense. Gnome terminal doesnt support the image protocol, thats all.

And AFAIK, Gnome terminal doesnt support any image protocols

CarterLi commented 1 year ago

The terminal support of image protocols varies greatly, since its a non-standard thing.

As for the preferred image protocol to use, kitty (with png) > iterm > others, and always use them with --logo-width and --logo-height specified

LinusDierheimer commented 1 year ago

Hi LinusDierheimer, I run your program on my KDE Terminal Emulator (my default terminal)

This is really weird, it gets enough data to not fail. Fastfetch uses pretty much the same code, i don't have an idea why it doesn't work there

Tested on a VM, but I get the same results on physical machines...

Gnome terminal doesn't support any image protocol, thats why it looks the way it does.

Konsole is weird here. It does support both ways of getting the sizes. Is everything up to date in your installation? My outputs are from konsole too.

CarterLi commented 1 year ago

I can't reproduce this issue in the latest version of konsole (23.04.3) and I assume it was a terminal bug in old konsole versions. If you can reproduce it in konsole version 23.04.3 or later, please open a new issue.

Closing as stale.