Skip to content

Commit 36d9b5a

Browse files
Finish OpenGL module
1 parent 1826e23 commit 36d9b5a

File tree

13 files changed

+150
-86
lines changed

13 files changed

+150
-86
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
uses: actions/checkout@v2
1414

1515
- name: install required packages
16-
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libgl-dev libegl-dev libglx-dev
16+
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev
1717

1818
- name: Initialize CodeQL
1919
uses: github/codeql-action/init@v1

.github/workflows/push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v2
1717

1818
- name: install required packages
19-
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libgl-dev libegl-dev libglx-dev
19+
run: sudo apt-get update && sudo apt-get install -y libpci-dev libvulkan-dev libwayland-dev libxrandr-dev libxcb-randr0-dev libdconf-dev libdbus-1-dev libmagickcore-dev libxfconf-0-dev libsqlite3-dev rpm librpm-dev libzstd-dev libegl-dev libglx-dev libosmesa6-dev
2020

2121
- name: Initialize CodeQL
2222
uses: github/codeql-action/init@v1

CMakeLists.txt

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ OPTION(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON)
3333
OPTION(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON)
3434
OPTION(ENABLE_ZLIB "Enable zlib" ON)
3535
OPTION(ENABLE_CHAFA "Enable chafa" ON)
36-
OPTION(ENABLE_GL "Enable gl" ON)
3736
OPTION(ENABLE_EGL "Enable egl" ON)
3837
OPTION(ENABLE_GLX "Enable glx" ON)
38+
OPTION(ENABLE_OSMESA "Enable osmesa" ON)
3939

4040
if(NOT CMAKE_BUILD_TYPE)
4141
set(CMAKE_BUILD_TYPE Release)
@@ -351,44 +351,30 @@ if(ENABLE_CHAFA)
351351
endif()
352352
endif()
353353

354-
if(ENABLE_GL)
355-
pkg_check_modules(GL gl)
356-
if(NOT GL_FOUND)
357-
message(WARNING "Package gl not found. Building without support.")
358-
endif()
359-
endif()
360-
361354
if(ENABLE_EGL)
362-
if(GL_FOUND)
363-
pkg_check_modules(EGL egl)
364-
if(EGL_FOUND)
365-
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_EGL=1)
366-
else()
367-
message(WARNING "Package egl not found. Building without support.")
368-
endif()
355+
pkg_check_modules(EGL egl)
356+
if(EGL_FOUND)
357+
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_EGL=1)
369358
else()
370-
message(WARNING "egl not enabled, because gl was not enabled or found. Building without support.")
359+
message(WARNING "Package egl not found. Building without support.")
371360
endif()
372361
endif()
373362

374363
if(ENABLE_GLX)
375-
if(GL_FOUND)
376-
pkg_check_modules(GLX glx)
377-
if(GLX_FOUND)
378-
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_GLX=1)
379-
else()
380-
message(WARNING "Package glx not found. Building without support.")
381-
endif()
364+
pkg_check_modules(GLX glx)
365+
if(GLX_FOUND)
366+
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_GLX=1)
382367
else()
383-
message(WARNING "glx not enabled, because gl was not enabled or found. Building without support")
368+
message(WARNING "Package glx not found. Building without support.")
384369
endif()
385370
endif()
386371

387-
if(GL_FOUND)
388-
if(EGL_FOUND OR GLX_FOUND)
389-
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_GL=1)
372+
if(ENABLE_OSMESA)
373+
pkg_check_modules(OSMESA osmesa)
374+
if(OSMESA_FOUND)
375+
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_OSMESA=1)
390376
else()
391-
message(WARNING "gl not enabled, because neither egl nor glx were found. Building without support.")
377+
message(WARNING "Package osmesa not found. Building without support.")
392378
endif()
393379
endif()
394380

@@ -414,9 +400,9 @@ target_include_directories(libfastfetch
414400
PRIVATE ${ZLIB_INCLUDE_DIRS}
415401
PRIVATE ${CHAFA_INCLUDE_DIRS}
416402
PRIVATE ${VULKAN_INCLUDE_DIRS}
417-
PRIVATE ${GL_INCLUDE_DIRS}
418403
PRIVATE ${EGL_INCLUDE_DIRS}
419404
PRIVATE ${GLX_INCLUDE_DIRS}
405+
PRIVATE ${OSMESA_INCLUDE_DIRS}
420406
)
421407

422408
target_link_libraries(libfastfetch

DEVELOPMENT.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Here i just add things that are easy to forget.
1414
- [ ] Better OS output for all possible combinations of /etc/os-release variables.
1515
- [ ] Expose temperatures to CPU format string
1616
- [ ] Expose temperatures to GPU format string
17-
- [ ] Fallback GPU detection using GL (multi GPU suport somehow possible?)
1817
- [ ] Find wayland compositor by looking at \${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}
1918
- [ ] Make LocalIP module more configurable
2019
- [ ] Automatic migrate old config files to newer versions

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ The following libraries are used if present at runtime:
2222
* [`libpci`](https://github.com/pciutils/pciutils): GPU output.
2323
* [`libvulkan`](https://www.vulkan.org/): Vulkan module & fallback for GPU output.
2424
* [`libxcb-randr`](https://xcb.freedesktop.org/),
25-
[`libXrandr`](https://gitlab.freedesktop.org/xorg/lib/libxrandr),
26-
[`libxcb`](https://xcb.freedesktop.org/),
27-
[`libX11`](https://gitlab.freedesktop.org/xorg/lib/libx11): At least one of them sould be present in X11 sessions for better resolution detection and faster WM detection. The `*randr` ones provide multi monitor support. The `libxcb*` ones usually have better performance.
25+
[`libXrandr`](https://gitlab.freedesktop.org/xorg/lib/libxrandr),
26+
[`libxcb`](https://xcb.freedesktop.org/),
27+
[`libX11`](https://gitlab.freedesktop.org/xorg/lib/libx11): At least one of them sould be present in X11 sessions for better resolution detection and faster WM detection. The `*randr` ones provide multi monitor support. The `libxcb*` ones usually have better performance.
2828
* [`libwayland-client`](https://wayland.freedesktop.org/): Better resolution performance and output in wayland sessions. Supports different refresh rates per monitor.
2929
* [`libGIO`](https://developer.gnome.org/gio/unstable/): Needed for values that are only stored GSettings.
3030
* [`libDConf`](https://developer.gnome.org/dconf/unstable/): Needed for values that are only stored in DConf + Fallback for GSettings.
3131
* [`libmagickcore` (ImageMagick)](https://www.imagemagick.org/): Images in terminal using sixel or kitty graphics protocol.
3232
* [`libchafa`](https://github.com/hpjansson/chafa): Image output as ascii art.
3333
* [`libZ`](https://www.zlib.net/): Faster image output when using kitty graphics protocol.
3434
* [`libDBus`](https://www.freedesktop.org/wiki/Software/dbus): Needed for detecting current media player and song.
35-
* [`libGL`](https://dri.freedesktop.org/wiki/libGL/):OpenGL module. At least one context creation library must be present too.
36-
* [`libEGL`](https://www.khronos.org/registry/EGL/): OpenGL module, using EGL context.
37-
* [`libGLX`](https://dri.freedesktop.org/wiki/GLX/): OpenGL module, using GLX context.
35+
* [`libEGL`](https://www.khronos.org/registry/EGL/),
36+
[`libGLX`](https://dri.freedesktop.org/wiki/GLX/),
37+
[`libOSMesa`](https://docs.mesa3d.org/osmesa.html): At least one of them is needed by the OpenGL module for gl context creation.
3838
* [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font.
3939
* [`libsqlite3`](https://www.sqlite.org/index.html): Needed for rpm package count.
4040
* [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE.
@@ -44,7 +44,7 @@ All categories not listed here should work without needing a specific implementa
4444

4545
##### Available Modules
4646
```
47-
Title, Separator, OS, Host, Kernel, Uptime, Processes, Packages, Shell, Resolution, DE, WM, WMTheme, Theme, Icons, Font, Cursor, Terminal, Terminal Font, CPU, CPUUsage, GPU, Memory, Disk, Battery, Player, Song, Vulkan, LocalIP, PublicIP, DateTime, Date, Time, Locale, Colors, Break, Custom
47+
Title, Separator, OS, Host, Kernel, Uptime, Processes, Packages, Shell, Resolution, DE, WM, WMTheme, Theme, Icons, Font, Cursor, Terminal, Terminal Font, CPU, CPUUsage, GPU, Memory, Disk, Battery, Player, Song, Vulkan, OpenGL, LocalIP, PublicIP, DateTime, Date, Time, Locale, Colors, Break, Custom
4848
```
4949

5050
##### Logos

completions/bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ __fastfetch_completion()
238238
"--lib-imagemagick"
239239
"--lib-z"
240240
"--lib-chafa"
241-
"--lib-gl"
242241
"--lib-egl"
243242
"--lib-glx"
243+
"--lib-osmesa"
244244
"--battery-dir"
245245
"--load-config"
246246
)

src/common/init.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ static void defaultConfig(FFinstance* instance)
210210
ffStrbufInitA(&instance->config.libImageMagick, 0);
211211
ffStrbufInitA(&instance->config.libZ, 0);
212212
ffStrbufInitA(&instance->config.libChafa, 0);
213-
ffStrbufInitA(&instance->config.libGL, 0);
214213
ffStrbufInitA(&instance->config.libEGL, 0);
215214
ffStrbufInitA(&instance->config.libGLX, 0);
215+
ffStrbufInitA(&instance->config.libOSMesa, 0);
216216

217217
ffStrbufInitA(&instance->config.diskFolders, 0);
218218

@@ -344,15 +344,15 @@ void ffListFeatures()
344344
#ifdef FF_HAVE_RPM
345345
"rpm\n"
346346
#endif
347-
#ifdef FF_HAVE_GL
348-
"gl\n"
349-
#endif
350347
#ifdef FF_HAVE_EGL
351348
"egl\n"
352349
#endif
353350
#ifdef FF_HAVE_GLX
354351
"glx\n"
355352
#endif
353+
#ifdef FF_HAVE_OSMESA
354+
"osmesa\n"
355+
#endif
356356
""
357357
, stdout);
358358
}

src/data/config.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,6 @@
254254
#--lib-imagemagick /usr/lib/libMagickCore-7.Q16HDRI.so
255255
#--lib-z /usr/lib/libz.so
256256
#--lib-chafa /usr/lib/libchafa.so
257-
#--lib-gl /usr/lib/libGL.so
258257
#--lib-egl /usr/lib/libEGL.so
259-
#--lib-GLX /usr/lib/libGLX.so
258+
#--lib-glx /usr/lib/libGLX.so
259+
#--lib-osmesa /usr/lib/libOSMesa.so

src/data/help.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ Library options: Set the path of a library to load
132132
--lib-imagemagick <path>
133133
--lib-z <path>
134134
--lib-chafa <path>
135-
--lib-gl <path>
136135
--lib-egl <path>
137136
--lib-glx <path>
137+
--lib-osmesa <path>
138138

139139
Module specific options:
140140
--separator-string <str>: Set the string printed by the separator module

src/fastfetch.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ static inline void printCommandHelp(const char* command)
358358
constructAndPrintCommandHelpFormat("opengl", "{}", 3,
359359
"version",
360360
"renderer",
361-
"vendor"
361+
"vendor",
362+
"shading language version"
362363
);
363364
}
364365
else
@@ -1029,12 +1030,12 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
10291030
optionParseString(key, value, &instance->config.libZ);
10301031
else if(strcasecmp(key, "--lib-chafa") == 0)
10311032
optionParseString(key, value, &instance->config.libChafa);
1032-
else if(strcasecmp(key, "--lib-gl") == 0)
1033-
optionParseString(key, value, &instance->config.libGL);
10341033
else if(strcasecmp(key, "--lib-egl") == 0)
10351034
optionParseString(key, value, &instance->config.libEGL);
10361035
else if(strcasecmp(key, "--lib-glx") == 0)
10371036
optionParseString(key, value, &instance->config.libGLX);
1037+
else if(strcasecmp(key, "--lib-osmesa") == 0)
1038+
optionParseString(key, value, &instance->config.libOSMesa);
10381039

10391040
//////////////////
10401041
//Module options//
@@ -1072,6 +1073,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
10721073
instance->config.glType = FF_GL_TYPE_EGL;
10731074
else if(strcasecmp(value, "glx") == 0)
10741075
instance->config.glType = FF_GL_TYPE_GLX;
1076+
else if(strcasecmp(value, "osmesa") == 0)
1077+
instance->config.glType = FF_GL_TYPE_OSMESA;
10751078
else
10761079
{
10771080
fprintf(stderr, "Error: unknown gl type: %s\n", value);

0 commit comments

Comments
 (0)