Skip to content

Commit 008cf3b

Browse files
OpenCL module
1 parent 3daede5 commit 008cf3b

File tree

14 files changed

+166
-20
lines changed

14 files changed

+166
-20
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 libegl-dev libglx-dev libosmesa6-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 ocl-icd-opencl-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 libegl-dev libglx-dev libosmesa6-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 ocl-icd-opencl-dev
2020

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

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ OPTION(ENABLE_CHAFA "Enable chafa" ON)
3636
OPTION(ENABLE_EGL "Enable egl" ON)
3737
OPTION(ENABLE_GLX "Enable glx" ON)
3838
OPTION(ENABLE_OSMESA "Enable osmesa" ON)
39+
OPTION(ENABLE_OPENCL "Enable opencl" ON)
3940

4041
if(NOT CMAKE_BUILD_TYPE)
4142
set(CMAKE_BUILD_TYPE Release)
@@ -172,6 +173,7 @@ add_library(libfastfetch STATIC
172173
src/modules/time.c
173174
src/modules/colors.c
174175
src/modules/opengl.c
176+
src/modules/opencl.c
175177
)
176178

177179
if(ENABLE_LIBPCI)
@@ -378,6 +380,15 @@ if(ENABLE_OSMESA)
378380
endif()
379381
endif()
380382

383+
if(ENABLE_OPENCL)
384+
pkg_check_modules(OPENCL OpenCL)
385+
if(OPENCL_FOUND)
386+
target_compile_definitions(libfastfetch PRIVATE FF_HAVE_OPENCL=1)
387+
else()
388+
message(WARNING "Package opencl not found. Building without support.")
389+
endif()
390+
endif()
391+
381392
target_include_directories(libfastfetch
382393
PUBLIC ${PROJECT_BINARY_DIR}
383394
PUBLIC ${PROJECT_SOURCE_DIR}/src
@@ -403,6 +414,7 @@ target_include_directories(libfastfetch
403414
PRIVATE ${EGL_INCLUDE_DIRS}
404415
PRIVATE ${GLX_INCLUDE_DIRS}
405416
PRIVATE ${OSMESA_INCLUDE_DIRS}
417+
PRIVATE ${OPENCL_INCLUDE_DIRS}
406418
)
407419

408420
target_link_libraries(libfastfetch

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,33 @@ There are some presets defined for fastfech in [`presets`](presets), you can can
1919
Fastfetch dynamically loads needed libraries if they are available. Therefore its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and `libpthread`. They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most linux distributions, so you probably don't have to worry about it.
2020

2121
The following libraries are used if present at runtime:
22-
* [`libpci`](https://github.com/pciutils/pciutils): GPU output.
23-
* [`libvulkan`](https://www.vulkan.org/): Vulkan module & fallback for GPU output.
24-
* [`libxcb-randr`](https://xcb.freedesktop.org/),
22+
* [`libpci`](https://github.com/pciutils/pciutils): GPU output.
23+
* [`libvulkan`](https://www.vulkan.org/): Vulkan module & fallback for GPU output.
24+
* [`libxcb-randr`](https://xcb.freedesktop.org/),
2525
[`libXrandr`](https://gitlab.freedesktop.org/xorg/lib/libxrandr),
2626
[`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.
28-
* [`libwayland-client`](https://wayland.freedesktop.org/): Better resolution performance and output in wayland sessions. Supports different refresh rates per monitor.
29-
* [`libGIO`](https://developer.gnome.org/gio/unstable/): Needed for values that are only stored GSettings.
30-
* [`libDConf`](https://developer.gnome.org/dconf/unstable/): Needed for values that are only stored in DConf + Fallback for GSettings.
31-
* [`libmagickcore` (ImageMagick)](https://www.imagemagick.org/): Images in terminal using sixel or kitty graphics protocol.
32-
* [`libchafa`](https://github.com/hpjansson/chafa): Image output as ascii art.
33-
* [`libZ`](https://www.zlib.net/): Faster image output when using kitty graphics protocol.
34-
* [`libDBus`](https://www.freedesktop.org/wiki/Software/dbus): Needed for detecting current media player and song.
35-
* [`libEGL`](https://www.khronos.org/registry/EGL/),
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.
28+
* [`libwayland-client`](https://wayland.freedesktop.org/): Better resolution performance and output in wayland sessions. Supports different refresh rates per monitor.
29+
* [`libGIO`](https://developer.gnome.org/gio/unstable/): Needed for values that are only stored GSettings.
30+
* [`libDConf`](https://developer.gnome.org/dconf/unstable/): Needed for values that are only stored in DConf + Fallback for GSettings.
31+
* [`libmagickcore` (ImageMagick)](https://www.imagemagick.org/): Images in terminal using sixel or kitty graphics protocol.
32+
* [`libchafa`](https://github.com/hpjansson/chafa): Image output as ascii art.
33+
* [`libZ`](https://www.zlib.net/): Faster image output when using kitty graphics protocol.
34+
* [`libDBus`](https://www.freedesktop.org/wiki/Software/dbus): Needed for detecting current media player and song.
35+
* [`libEGL`](https://www.khronos.org/registry/EGL/),
3636
[`libGLX`](https://dri.freedesktop.org/wiki/GLX/),
3737
[`libOSMesa`](https://docs.mesa3d.org/osmesa.html): At least one of them is needed by the OpenGL module for gl context creation.
38-
* [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font.
39-
* [`libsqlite3`](https://www.sqlite.org/index.html): Needed for rpm package count.
40-
* [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE.
38+
* [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module
39+
* [`libXFConf`](https://gitlab.xfce.org/xfce/xfconf): Needed for XFWM theme and XFCE Terminal font.
40+
* [`libsqlite3`](https://www.sqlite.org/index.html): Needed for rpm package count.
41+
* [`librpm`](http://rpm.org/): Slower fallback for rpm package count. Needed on openSUSE.
4142

4243
## Support status
4344
All categories not listed here should work without needing a specific implementation.
4445

4546
##### Available Modules
4647
```
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
48+
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, OpenCL, LocalIP, PublicIP, DateTime, Date, Time, Locale, Colors, Break, Custom
4849
```
4950

5051
##### Logos

completions/bash

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ __fastfetch_completion()
153153
"-s"
154154
"--structure"
155155
"--set"
156+
"--gl"
156157
"--os-format"
157158
"--os-key"
158159
"--host-format"
@@ -217,7 +218,12 @@ __fastfetch_completion()
217218
"--date-key"
218219
"--time-format"
219220
"--time-key"
220-
"--gl"
221+
"--vulkan-key"
222+
"--vulkan-format"
223+
"--opengl-key"
224+
"--opengl-format"
225+
"--opencl-key"
226+
"--opencl-format"
221227
)
222228

223229
local FF_OPTIONS_PATH=(
@@ -241,6 +247,7 @@ __fastfetch_completion()
241247
"--lib-egl"
242248
"--lib-glx"
243249
"--lib-osmesa"
250+
"--lib-opencl"
244251
"--battery-dir"
245252
"--load-config"
246253
)

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:OpenGL: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:OpenCL:Break:Colors

presets/verbose

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@
2727
--song-format "Song: {}; Artist: {}; Album: {}"
2828
--datetime-format "year: {}; yearShort: {}; month: {}; monthPretty: {}; monthName: {}; monthNameShort: {}; weekNumber: {}; weekday: {}; weekdayShort: {}; dayInYear: {}; dayInMonth: {}; dayInWeek: {}; hour: {}; hourPretty: {}; hour12: {}; hour12Pretty: {}; minute: {}; minutePretty: {}; second: {}; secondPretty: {}"
2929
--vulkan-format "driver: {}; Api Version: {}; Conformance Version: {}"
30+
--opengl-format "version: {}; renderer: {}; vendor: {}"
31+
--opencl-format "version: {}; device: {}; vendor: {}"

src/common/init.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ static void defaultConfig(FFinstance* instance)
193193
ffStrbufInitA(&instance->config.vulkanFormat, 0);
194194
ffStrbufInitA(&instance->config.openGLKey, 0);
195195
ffStrbufInitA(&instance->config.openGLFormat, 0);
196+
ffStrbufInitA(&instance->config.openCLKey, 0);
197+
ffStrbufInitA(&instance->config.openCLFormat, 0);
196198

197199
ffStrbufInitA(&instance->config.libPCI, 0);
198200
ffStrbufInitA(&instance->config.libVulkan, 0);
@@ -213,6 +215,7 @@ static void defaultConfig(FFinstance* instance)
213215
ffStrbufInitA(&instance->config.libEGL, 0);
214216
ffStrbufInitA(&instance->config.libGLX, 0);
215217
ffStrbufInitA(&instance->config.libOSMesa, 0);
218+
ffStrbufInitA(&instance->config.libOpenCL, 0);
216219

217220
ffStrbufInitA(&instance->config.diskFolders, 0);
218221

@@ -353,6 +356,9 @@ void ffListFeatures()
353356
#ifdef FF_HAVE_OSMESA
354357
"osmesa\n"
355358
#endif
359+
#ifdef FF_HAVE_OPENCL
360+
"opencl\n"
361+
#endif
356362
""
357363
, stdout);
358364
}

src/data/config.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
#--datetime-key Date Time
198198
#--vulkan-key Vulkan
199199
#--opengl-key OpenGL
200+
#--opencl-key OpenCL
200201

201202
# Format options:
202203
# Sets the format string for module values.
@@ -234,6 +235,7 @@
234235
#--datetime-format
235236
#--vulkan-format
236237
#--opengl-format
238+
#--opencl-format
237239

238240
# Library options:
239241
# Sets an user specific path to a library to load.
@@ -257,3 +259,4 @@
257259
#--lib-egl /usr/lib/libEGL.so
258260
#--lib-glx /usr/lib/libGLX.so
259261
#--lib-osmesa /usr/lib/libOSMesa.so
262+
#--lib-opencl /usr/lib/libOpenCL.so

src/data/help.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Format options: Provide the format string for custom output. Use fastfetch --hel
7979
--date-format <format>
8080
--vulkan-format <format>
8181
--opengl-format <format>
82+
--opencl-format <format>
8283

8384
Key options: Provide a custom key for an output
8485
--os-key <key>
@@ -114,6 +115,7 @@ Key options: Provide a custom key for an output
114115
--date-key <key>
115116
--vulkan-key <key>
116117
--opengl-key <key>
118+
--opencl-key <key>
117119

118120
Library options: Set the path of a library to load
119121
--lib-PCI <path>
@@ -135,6 +137,7 @@ Library options: Set the path of a library to load
135137
--lib-egl <path>
136138
--lib-glx <path>
137139
--lib-osmesa <path>
140+
--lib-opencl <path>
138141

139142
Module specific options:
140143
--separator-string <str>: Set the string printed by the separator module

0 commit comments

Comments
 (0)