Skip to content

Commit 1826e23

Browse files
OpenGL module
1 parent 43b3998 commit 1826e23

File tree

14 files changed

+468
-4
lines changed

14 files changed

+468
-4
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
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
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
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
2020

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

CMakeLists.txt

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +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)
37+
OPTION(ENABLE_EGL "Enable egl" ON)
38+
OPTION(ENABLE_GLX "Enable glx" ON)
3639

3740
if(NOT CMAKE_BUILD_TYPE)
3841
set(CMAKE_BUILD_TYPE Release)
@@ -168,6 +171,7 @@ add_library(libfastfetch STATIC
168171
src/modules/date.c
169172
src/modules/time.c
170173
src/modules/colors.c
174+
src/modules/opengl.c
171175
)
172176

173177
if(ENABLE_LIBPCI)
@@ -343,7 +347,48 @@ if(ENABLE_CHAFA)
343347
message(WARNING "Package chafa>=1.10 not found. Building without support.")
344348
endif()
345349
else()
346-
message(WARNING "Chafa not enabled, because neither ImageMagick6 nor ImageMagick7 is found. Building without support.")
350+
message(WARNING "Chafa not enabled, because neither ImageMagick6 nor ImageMagick7 were found. Building without support.")
351+
endif()
352+
endif()
353+
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+
361+
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()
369+
else()
370+
message(WARNING "egl not enabled, because gl was not enabled or found. Building without support.")
371+
endif()
372+
endif()
373+
374+
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()
382+
else()
383+
message(WARNING "glx not enabled, because gl was not enabled or found. Building without support")
384+
endif()
385+
endif()
386+
387+
if(GL_FOUND)
388+
if(EGL_FOUND OR GLX_FOUND)
389+
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_GL=1)
390+
else()
391+
message(WARNING "gl not enabled, because neither egl nor glx were found. Building without support.")
347392
endif()
348393
endif()
349394

@@ -368,6 +413,10 @@ target_include_directories(libfastfetch
368413
PRIVATE ${IMAGEMAGICK6_INCLUDE_DIRS}
369414
PRIVATE ${ZLIB_INCLUDE_DIRS}
370415
PRIVATE ${CHAFA_INCLUDE_DIRS}
416+
PRIVATE ${VULKAN_INCLUDE_DIRS}
417+
PRIVATE ${GL_INCLUDE_DIRS}
418+
PRIVATE ${EGL_INCLUDE_DIRS}
419+
PRIVATE ${GLX_INCLUDE_DIRS}
371420
)
372421

373422
target_link_libraries(libfastfetch

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ The following libraries are used if present at runtime:
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.
3538
* [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font.
3639
* [`libsqlite3`](https://www.sqlite.org/index.html): Needed for rpm package count.
3740
* [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE.

completions/bash

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ __fastfetch_completion()
217217
"--date-key"
218218
"--time-format"
219219
"--time-key"
220+
"--gl"
220221
)
221222

222223
local FF_OPTIONS_PATH=(
@@ -237,6 +238,9 @@ __fastfetch_completion()
237238
"--lib-imagemagick"
238239
"--lib-z"
239240
"--lib-chafa"
241+
"--lib-gl"
242+
"--lib-egl"
243+
"--lib-glx"
240244
"--battery-dir"
241245
"--load-config"
242246
)

presets/all

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--structure Title:Separator:OS:Host:Kernel:Uptime:Processes:Packages:Shell:Resolution:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Disk:Battery:Player:Song:PublicIP:LocalIP:DateTime:Locale:Vulkan:Break:Colors
1+
--structure Title:Separator:OS:Host:Kernel:Uptime:Processes:Packages:Shell:Resolution:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:GPU:Memory:Disk:Battery:Player:Song:PublicIP:LocalIP:DateTime:Locale:Vulkan:OpenGL:Break:Colors

src/common/init.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ static void defaultConfig(FFinstance* instance)
125125
instance->config.disableLinewrap = true;
126126
instance->config.hideCursor = true;
127127
instance->config.escapeBedrock = true;
128+
instance->config.glType = FF_GL_TYPE_AUTO;
128129

129130
ffStrbufInitA(&instance->config.osFormat, 0);
130131
ffStrbufInitA(&instance->config.osKey, 0);
@@ -190,6 +191,8 @@ static void defaultConfig(FFinstance* instance)
190191
ffStrbufInitA(&instance->config.timeFormat, 0);
191192
ffStrbufInitA(&instance->config.vulkanKey, 0);
192193
ffStrbufInitA(&instance->config.vulkanFormat, 0);
194+
ffStrbufInitA(&instance->config.openGLKey, 0);
195+
ffStrbufInitA(&instance->config.openGLFormat, 0);
193196

194197
ffStrbufInitA(&instance->config.libPCI, 0);
195198
ffStrbufInitA(&instance->config.libVulkan, 0);
@@ -207,6 +210,9 @@ static void defaultConfig(FFinstance* instance)
207210
ffStrbufInitA(&instance->config.libImageMagick, 0);
208211
ffStrbufInitA(&instance->config.libZ, 0);
209212
ffStrbufInitA(&instance->config.libChafa, 0);
213+
ffStrbufInitA(&instance->config.libGL, 0);
214+
ffStrbufInitA(&instance->config.libEGL, 0);
215+
ffStrbufInitA(&instance->config.libGLX, 0);
210216

211217
ffStrbufInitA(&instance->config.diskFolders, 0);
212218

@@ -338,6 +344,15 @@ void ffListFeatures()
338344
#ifdef FF_HAVE_RPM
339345
"rpm\n"
340346
#endif
347+
#ifdef FF_HAVE_GL
348+
"gl\n"
349+
#endif
350+
#ifdef FF_HAVE_EGL
351+
"egl\n"
352+
#endif
353+
#ifdef FF_HAVE_GLX
354+
"glx\n"
355+
#endif
341356
""
342357
, stdout);
343358
}

src/data/config.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@
157157
# Default is true.
158158
#--escape-bedrock true
159159

160+
# GL option
161+
# Sets with opengl context creation library to use
162+
# Must be either auto, egl or glx
163+
# Default is auto.
164+
#--gl auto
165+
160166
# Key options:
161167
# Sets the displayed key of a module
162168
# Can be any string. Some of theme take an argument like a format string. See "fastfetch --help format" for help.
@@ -190,6 +196,7 @@
190196
#--song-key Song
191197
#--datetime-key Date Time
192198
#--vulkan-key Vulkan
199+
#--opengl-key OpenGL
193200

194201
# Format options:
195202
# Sets the format string for module values.
@@ -226,6 +233,7 @@
226233
#--song-format
227234
#--datetime-format
228235
#--vulkan-format
236+
#--opengl-format
229237

230238
# Library options:
231239
# Sets an user specific path to a library to load.
@@ -246,3 +254,6 @@
246254
#--lib-imagemagick /usr/lib/libMagickCore-7.Q16HDRI.so
247255
#--lib-z /usr/lib/libz.so
248256
#--lib-chafa /usr/lib/libchafa.so
257+
#--lib-gl /usr/lib/libGL.so
258+
#--lib-egl /usr/lib/libEGL.so
259+
#--lib-GLX /usr/lib/libGLX.so

src/data/help.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Format options: Provide the format string for custom output. Use fastfetch --hel
7878
--time-format <format>
7979
--date-format <format>
8080
--vulkan-format <format>
81+
--opengl-format <format>
8182

8283
Key options: Provide a custom key for an output
8384
--os-key <key>
@@ -112,6 +113,7 @@ Key options: Provide a custom key for an output
112113
--time-key <key>
113114
--date-key <key>
114115
--vulkan-key <key>
116+
--opengl-key <key>
115117

116118
Library options: Set the path of a library to load
117119
--lib-PCI <path>
@@ -130,6 +132,9 @@ Library options: Set the path of a library to load
130132
--lib-imagemagick <path>
131133
--lib-z <path>
132134
--lib-chafa <path>
135+
--lib-gl <path>
136+
--lib-egl <path>
137+
--lib-glx <path>
133138

134139
Module specific options:
135140
--separator-string <str>: Set the string printed by the separator module
@@ -141,6 +146,7 @@ Module specific options:
141146
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
142147
--public-ip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
143148
--player-name: The name of the player to use
149+
--gl <value>: Sets the opengl context creation library to use. Must be auto, egl, or glx. Default is auto
144150

145151
Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci"
146152
If a value starts with a ?, it is optional. "true" will be used if not set.

src/data/modules.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Locale
1717
LocalIP
1818
Memory
1919
OS
20+
OpenGL
2021
Packages
2122
Player
2223
Processes

0 commit comments

Comments
 (0)