scorpion-26 / gBar

Blazingly fast status bar written with GTK
MIT License
478 stars 17 forks source link

Crash with error No such file or directory [/usr/share/icons] #25

Closed SkyLeite closed 1 year ago

SkyLeite commented 1 year ago

Describe the bug Sometimes (but not always!) running gBar bar 0 results in the following error:

terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
  what():  filesystem error: recursive directory iterator cannot open directory: No such file or directory [/usr/share/icons]

Since I'm using NixOS the /usr/share/icons directory doesn't exist, but I'm not sure the application should crash when failing to (presumably) load icons. I would expect it to open with a placeholder for such icons.

Steps to Reproduce

  1. Rename your /usr/share/icons directory to something else
  2. Run gBar bar 0

I've no idea why this crash only happens sometimes though :sweat:

Expected behavior gBar should open with placeholders for icons it could not load (presuming that's what it's doing)

Screenshots/Error logs

sky@home ~$ gBar bar 0                                                                                                                                                                                                                    134 ↵
Set value for AudioInput: false
Set value for AudioMaxVolume: 100
Set value for AudioMinVolume: 0
Set value for AudioRevealer: false
Set value for AudioScrollSpeed: 5
Set value for BatteryFolder: /sys/class/power_supply/BAT1
Set value for CPUThermalZone: /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon2/temp1_input
Set value for CenterTime: true
Set value for DateTimeStyle: %a %D - %H:%M:%S %Z
Set value for DefaultWorkspaceSymbol: 
Set value for EnableSNI: true
Set value for ExitCommand: killall Hyprland
Set value for Location: T
Set value for LockCommand: ~/.config/scripts/sys.sh lock
Set value for MaxDownloadBytes: 10485760
Set value for MaxUploadBytes: 5242880
Set value for MinDownloadBytes: 0
Set value for MinUploadBytes: 0
Set value for NetworkAdapter: eno1
Set value for NetworkWidget: true
Set value for SuspendCommand: systemctl suspend
Set value for TimeSpace: 300
Set value for UseHyprlandIPC: false
Set value for WorkspaceScrollInvert: false
Set value for WorkspaceScrollOnMonitor: true
Set value for CPUThermalZone: /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon2/temp1_input
Set value for SuspendCommand: ~/.config/scripts/sys.sh suspend
Set value for LockCommand: ~/.config/scripts/sys.sh lock
Set value for ExitCommand: killall Hyprland
Set value for BatteryFolder: /sys/class/power_supply/BAT1
Set value for DefaultWorkspaceSymbol: 
Set value for WorkspaceScrollOnMonitor: true
Set value for WorkspaceScrollInvert: false
Set value for UseHyprlandIPC: true
Set value for CenterTime: true
Set value for TimeSpace: 300
Set value for AudioInput: false
Set value for AudioRevealer: false
Set value for AudioScrollSpeed: 5
Set value for CheckPackagesCommand: p="$(checkupdates)"; e=$?; if [ $e -eq 127 ] ; then exit 127; fi; if [ $e -eq 2 ] ; then echo "0" && exit 0; fi; echo "$p" | wc -l
Set value for CheckUpdateInterval: 300
Set value for NetworkAdapter: eno1
Set value for NetworkWidget: true
Set value for EnableSNI: true
Set value for SNIIconSize: *, 25
Set value for SNIIconSize: OBS, 23
Set value for MinDownloadBytes: 0
Set value for MaxDownloadBytes: 10485760
Set value for MinUploadBytes: 0
Set value for MaxUploadBytes: 5242880
Wayland: Added workspace!
Workspace ID: 6
Wayland: Deactivate Workspace 6
Wayland: Added workspace!
Workspace ID: 3
Wayland: Activate Workspace 3
Wayland: Added workspace!
Workspace ID: 1
Wayland: Deactivate Workspace 1
Wayland: Added workspace!
Workspace ID: 7
Wayland: Deactivate Workspace 7
Wayland: Registering monitor DP-1 at ID 0
Wayland: Added group to monitor
Wayland: Registering monitor DP-3 at ID 1
Wayland: Added group to monitor
Wayland: Registering monitor DP-2 at ID 2
Wayland: Added group to monitor
Forcefully activate workspace 3
Forcefully activate workspace 1
NVML not found, disabling Nvidia GPU
PulseAudio: Context is ready!
PulseAudio: Update info
CSS found and loaded successfully!
SNI: Clearing old children
Invalid child!

(gBar:227740): Gtk-CRITICAL **: 19:06:47.257: gtk_widget_set_visible: assertion 'GTK_IS_WIDGET (widget)' failed

(gBar:227740): Gtk-CRITICAL **: 19:06:47.257: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed
sh: line 1: checkupdates: command not found
GetOutdatedPackages: Invalid command. Disabling package widget!
SNI: Registered Item :1.5 /org/ayatana/NotificationItem/nm_applet
SNI: Registered Item :1.346 /org/blueman/sni
SNI: Registered Item :1.37 /org/ayatana/NotificationItem/steam
SNI: Creating Item :1.37 /org/ayatana/NotificationItem/steam
SNI: Menu object path: /org/ayatana/NotificationItem/steam/Menu
SNI: Creating Item :1.346 /org/blueman/sni
SNI: Cannot open blueman-active
SNI: Creating Item :1.5 /org/ayatana/NotificationItem/nm_applet
terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
  what():  filesystem error: recursive directory iterator cannot open directory: No such file or directory [/usr/share/icons]
[1]    227740 IOT instruction (core dumped)  gBar bar 0

Information about your system and gBar

scorpion-26 commented 1 year ago

Thanks for the report! I already know the issue (caused by me being a bit naive in 18f3e12 and only considering Arch) and have an idea for a fix ready, though I'd appreciate if you can confirm something, since my docker nix image doesn't want to cooperate. Does your XDG_DATA_DIRS environment variable contain something from networkmanager/nm-applet? If so, does the mentioned nm-applet folder contain an icon directory?

scorpion-26 commented 1 year ago

I've pushed the fix anyways, since it can't hurt and fixes at least the crash. As long as XDG_DATA_DIRS is set correctly(I hope Nix does that automatically, though I could be wrong), this should also find the icons.

SkyLeite commented 1 year ago

Thanks for the report! I already know the issue (caused by me being a bit naive in 18f3e12 and only considering Arch) and have an idea for a fix ready, though I'd appreciate if you can confirm something, since my docker nix image doesn't want to cooperate. Does your XDG_DATA_DIRS environment variable contain something from networkmanager/nm-applet? If so, does the mentioned nm-applet folder contain an icon directory?

Not as far as I can tell, though to be honest I don't really use nm-applet so in my case it shouldn't matter at least. XDG_DATA_DIRS is set up correctly though :)

I'll give the fix a try tomorrow and report back. Thank you very much :)

SkyLeite commented 1 year ago

Yep, this seems to be fixed. And I even see the nm-applet icon, which I honestly didn't even know I had running :joy:

Thank you so much!