Compare commits

..

83 Commits

Author SHA1 Message Date
李通洲 b9742642fc Release 1.11.2 before merging #432 2023-06-09 11:31:36 +08:00
李通洲 356c905703 DisplayServer (macOS): add a missing variable initialization 2023-06-09 11:07:06 +08:00
李通洲 47a5473a35 Init: fix possible memleaks 2023-06-09 10:10:03 +08:00
李通洲 96bca6888a LocalIP: remove useless code 2023-06-09 09:47:45 +08:00
李通洲 bbf31c1a95 Doc: update changelog 2023-06-08 22:28:32 +08:00
李通洲 42b8c1b429 Wallpaper: add missing docs 2023-06-08 22:27:15 +08:00
李通洲 77fde11039 Disk (Linux): fix fastfetch doesn't show Windows drives (/mnt/c) 2023-06-08 22:24:57 +08:00
李通洲 e13f04e80f Disk: backport changes from config branch 2023-06-08 22:24:57 +08:00
李通洲 ad026f6105 LocalIP: backport mac address support
Also change `--*-ip-*` to `--*ip-*` to be consistant to my config branch
2023-06-08 22:22:05 +08:00
李通洲 9107d0e107 Player: try avoiding too Linux-specific names 2023-06-08 16:08:56 +08:00
李通洲 ee876c54bf Theme: split detection code 2023-06-08 16:08:56 +08:00
李通洲 4af44a40bf OS (macOS): add fast path for code name detection 2023-06-07 14:30:45 +08:00
李通洲 399cfe2fbc CI (Wallpaper): run this module 2023-06-06 21:17:03 +08:00
李通洲 71d0cdbfce Wallpaper (Linux): add support for xfce4 2023-06-06 21:02:21 +08:00
李通洲 aae740472f Wallpaper (Linux): add support for gnome 2023-06-06 21:02:21 +08:00
李通洲 8f9beb2789 Wallpaper (macOS): add support 2023-06-06 21:02:21 +08:00
李通洲 77b93a904f Wallpaper (Windows): add new module 2023-06-06 15:48:24 +08:00
李通洲 7934c16bca Doc: update changelog for Icons module 2023-06-06 15:46:57 +08:00
李通洲 941ddee2fc Icons (Windows): add support
Instead of icon theme, this module on Windows detects enabled system icons
2023-06-06 15:35:41 +08:00
李通洲 16113bf330 Icons: split detection code 2023-06-06 15:35:41 +08:00
李通洲 505182428b Global: silence some clang warnings 2023-06-04 01:30:48 +08:00
李通洲 3c2a84ff78 TerminalFont: detect /dev/pts/* 2023-06-01 11:00:40 +08:00
李通洲 8a3346b650 DisplayServer (Wayland): remove a useless line 2023-05-30 22:38:35 +08:00
李通洲 5b63fb1362 Doc: update changelog 2023-05-30 21:04:11 +08:00
李通洲 393857b067 Brightness (Linux): print more useful display name instead of intel_backlight 2023-05-30 20:57:05 +08:00
李通洲 cb8a9c0796 DisplayServer (Wayland): detect display type 2023-05-30 20:54:08 +08:00
李通洲 036752763f DisplayServer (Wayland): silence compiler warnings 2023-05-30 20:53:35 +08:00
李通洲 3a90af1f44 DisplayServer (Wayland): detect screen rotation 2023-05-30 20:16:18 +08:00
李通洲 772de0ff97 DisplayServer: better wayland feature detection 2023-05-29 13:35:45 +08:00
李通洲 53a61a8e58 Display (Linux): support name detection for wayland protocol 2023-05-29 13:30:50 +08:00
Linus Dierheimer a37328c1aa Font: Show QT before GTK
keeps consistency with other modules
2023-05-28 12:34:23 +02:00
李通洲 782325395c DE: Fix Gnome version detection on Fedora 2023-05-28 01:10:00 +08:00
李通洲 e13d554433 Merge remote-tracking branch 'upstream/master' into dev 2023-05-28 00:20:31 +08:00
李通洲 5b65e182e9 Release: 1.11.1
Update changelog too
2023-05-27 23:53:41 +08:00
李通洲 a7896c39f0 DisplayServer (Apple): use FF_AUTO_FREE 2023-05-27 23:34:04 +08:00
李通洲 4f19bf9a18 Windows: use ffStrbufInitWS 2023-05-27 23:34:03 +08:00
李通洲 c379c65960 Disk (Windows): improve performance 2023-05-27 23:34:03 +08:00
李通洲 1ae0a83880 Windows: fix potential memory curruption bug in unicode.c
Also add ffStrbufInitWS
2023-05-27 23:34:03 +08:00
李通洲 77f7c813f4 TerminalShell (Windows): print clink version 2023-05-27 21:47:36 +08:00
李通洲 bfec8b5634 TerminalShell: code refactoring 2023-05-27 21:47:18 +08:00
李通洲 15a43a6b11 TerminalShel (Windows): detect Tabby version with exe file version 2023-05-27 21:26:00 +08:00
李通洲 c9e3c34ce1 Settings (Linux): fix memleaks reported by LeakSanitizer 2023-05-27 18:25:54 +08:00
李通洲 b99b3ad982 TerminalFont: support Tabby 2023-05-26 15:47:19 +08:00
李通洲 f4ce5c4143 TerminalShell: support Tabby terminal version detection 2023-05-26 15:44:54 +08:00
李通洲 bb4bf63621 Sound (macOS): detecting volume more aggressively 2023-05-26 15:18:59 +08:00
李通洲 60c1a552bb Logo: add macOS small version 2023-05-26 09:16:29 +08:00
李通洲 0a979ddd1e TerminalShell: fix iTerm being detected as iTermServer-* sometimes 2023-05-24 14:50:39 +08:00
李通洲 e45c4b49fd TerminalShell: support xonsh 2023-05-24 14:50:37 +08:00
李通洲 b89ace7aae Swap (Windows): fix compiler warnings 2023-05-16 20:54:45 +08:00
李通洲 424ca923fc Vulkan: try fixing #456 2023-05-16 20:53:45 +08:00
李通洲 e837e1e1d1 Swap: split module code from memory.c 2023-05-11 22:03:18 +08:00
李通洲 aea0986928 CMake(Windows): remove USE_WIN_NTAPI option 2023-05-11 19:55:31 +08:00
李通洲 dc2a3492f0 Network: drop module 2023-05-03 21:50:05 +08:00
Edward Piper 8cf033002c Fix EndeavourOS logo again 2023-05-03 21:49:50 +08:00
李通洲 4d7cb25aa6 DisplayServer (Windows): code simplification 2023-04-26 00:14:39 +08:00
李通洲 60cf3ec861 OpenCL: split detection code 2023-04-25 19:08:27 +08:00
李通洲 4fd82b16e8 Doc: document Network module 2023-04-18 20:59:26 +08:00
李通洲 26feccc0e4 LocalIP: simplify loop interface detection 2023-04-18 20:38:02 +08:00
李通洲 9a1bc66dfc Network (FreeBSD): add dirty support 2023-04-18 20:37:22 +08:00
李通洲 24a3783d7c Network: code refactor & bug fixes 2023-04-18 20:36:41 +08:00
李通洲 7e072c395f Network (Linux): add support 2023-04-18 18:27:25 +08:00
李通洲 94e1ed1d7e Network (Windows): add support 2023-04-18 18:02:31 +08:00
李通洲 94e6f4040d Network (macOS): init 2023-04-18 17:29:48 +08:00
Linus Dierheimer d570e59818 --pipe: don't print white color blocks
Fixes #450
2023-04-17 17:04:28 +02:00
李通洲 0e9d48fff0 FFstrbuf: remove FF_STRBUF_CREATE macro 2023-04-15 12:27:51 +08:00
李通洲 e690d73434 CpuUsage: code refactor 2023-04-15 12:27:51 +08:00
李通洲 8f2b3c6b69 Processes: code refactor 2023-04-15 12:27:51 +08:00
Linus Dierheimer 3c0b2fc910 Merge pull request #448 from LinusDierheimer/master
Merge pull request #437 from LinusDierheimer/dev
2023-04-13 09:17:37 +02:00
Linus Dierheimer 7d0a1c8987 Merge pull request #446 from tdtooke/dev
Adds another font color index to arch icon
2023-04-12 08:09:54 +02:00
tdtooke 757d947446 Update builtin.c 2023-04-11 13:44:07 -07:00
tdtooke 4ced4f9631 Update builtin.c 2023-04-11 13:35:24 -07:00
Linus Dierheimer c6859d7edd Merge pull request #445 from KingKrouch/winlogo-patch
Update Windows 11 ASCII logo to look more visually consistent.
2023-04-10 18:04:17 +02:00
KingKrouch 94cf9a89cc Update Windows 11 ASCII
Reason being that the original ASCII art as shown in Windows Terminal has random portions using "*" and "(" as opposed to "/".
2023-04-10 15:28:42 +00:00
Linus Dierheimer bd8d78427b Fix flatpak package count
Fix user package count
Show runtime packages too
Fixes #441
2023-04-06 11:11:31 +02:00
Linus Dierheimer e40d4b9b68 Fix a new compile warning 2023-04-05 13:41:10 +02:00
Linus Dierheimer 4a07485a19 Remove leftover comment 2023-04-05 13:21:46 +02:00
李通洲 71614e0b0c Font: code refactor 2023-04-04 12:06:21 +08:00
李通洲 d5b6c14bdf Doc: update changelog 2023-04-04 11:05:27 +08:00
李通洲 9509718b0e Gamepad: fix copy-and-paste errors 2023-04-04 11:02:59 +08:00
李通洲 c0ca022ac2 Doc: update changelog 2023-04-02 20:56:12 +08:00
李通洲 708b4a8981 Logo: add SteamOS (#439) 2023-04-02 20:54:16 +08:00
李通洲 8006b0ca4f Gamepad (Windows): change the name of Pro Controller 2023-04-02 20:41:18 +08:00
李通洲 cc2286f056 Windows: fix compiling with imagemagick enabled 2023-04-02 20:41:16 +08:00
54 changed files with 877 additions and 425 deletions
+22
View File
@@ -1,3 +1,25 @@
# 1.11.2
This release should be the last version of fastfetch 1.x (if no serious bugs found, hopefully)
Features:
* Support display name, type, rotation detection on Wayland (Linux, Display)
* Print more useful display name instead of intel_backlight (Linux, Brightness)
* Icons module supports Windows (Windows, Icons)
* Add Wallpaper module which shows the current wallpaper image path
* Add mac address detection `--localip-show-mac` (LocalIP, #451)
Bugfixes:
* Fix Gnome version detection on Fedora (DE)
* Fix Windows drives detection in WSL (Disk)
Changes:
* In order to make Icons module consistant between different platforms, `--icons-format` no longer supports individual GTK / QT icon params.
* `--theme-format` no longer supports individual GTK / plasma theme params.
* `--local-ip-*` and `--public-ip-*` have been changed to `--localip-*` and `--publicip-*`
* `--localip-compact-type` is no longer supported. Fastfetch now display IPs as `--localip-compat-type multiline` by default, with `--local-compact true` can be set as an alias of `--localip-compact-type oneline`
* `--localip-v6first` is no longer supported.
# 1.11.1
Features:
+18 -2
View File
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
project(fastfetch
VERSION 1.11.1
VERSION 1.11.2
LANGUAGES C
DESCRIPTION "Fast system information tool"
HOMEPAGE_URL "https://github.com/LinusDierheimer/fastfetch"
@@ -57,7 +57,7 @@ cmake_dependent_option(ENABLE_GIO "Enable gio-2.0" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_DCONF "Enable dconf" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_DBUS "Enable dbus-1" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_XFCONF "Enable libxfconf-0" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR BSD" OFF)
cmake_dependent_option(ENABLE_SQLITE3 "Enable sqlite3" ON "LINUX OR BSD OR APPLE" OFF)
cmake_dependent_option(ENABLE_RPM "Enable rpm" ON "LINUX" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK7 "Enable imagemagick 7" ON "LINUX OR BSD OR APPLE OR WIN32" OFF)
cmake_dependent_option(ENABLE_IMAGEMAGICK6 "Enable imagemagick 6" ON "LINUX OR BSD OR APPLE" OFF)
@@ -306,6 +306,7 @@ set(LIBFASTFETCH_SRC
src/modules/uptime.c
src/modules/users.c
src/modules/vulkan.c
src/modules/wallpaper.c
src/modules/weather.c
src/modules/wifi.c
src/modules/wm.c
@@ -342,6 +343,7 @@ if(LINUX)
src/detection/gpu/gpu_linux.c
src/detection/gtk_qt/gtk.c
src/detection/host/host_linux.c
src/detection/icons/icons_linux.c
src/detection/localip/localip_linux.c
src/detection/gamepad/gamepad_linux.c
src/detection/media/media_linux.c
@@ -357,8 +359,10 @@ if(LINUX)
src/detection/temps/temps_linux.c
src/detection/terminalfont/terminalfont_linux.c
src/detection/terminalshell/terminalshell_linux.c
src/detection/theme/theme_linux.c
src/detection/uptime/uptime_linux.c
src/detection/users/users_linux.c
src/detection/wallpaper/wallpaper_linux.c
src/detection/wifi/wifi_linux.c
src/detection/wmtheme/wmtheme_linux.c
src/util/platform/FFPlatform_unix.c
@@ -382,6 +386,7 @@ elseif(ANDROID)
src/detection/font/font_nosupport.c
src/detection/gpu/gpu_nosupport.c
src/detection/host/host_android.c
src/detection/icons/icons_nosupport.c
src/detection/localip/localip_linux.c
src/detection/gamepad/gamepad_nosupport.c
src/detection/media/media_nosupport.c
@@ -396,8 +401,10 @@ elseif(ANDROID)
src/detection/temps/temps_linux.c
src/detection/terminalfont/terminalfont_android.c
src/detection/terminalshell/terminalshell_linux.c
src/detection/theme/theme_nosupport.c
src/detection/uptime/uptime_linux.c
src/detection/users/users_linux.c
src/detection/wallpaper/wallpaper_nosupport.c
src/detection/wifi/wifi_android.c
src/detection/wmtheme/wmtheme_nosupport.c
src/util/platform/FFPlatform_unix.c
@@ -428,6 +435,7 @@ elseif(BSD)
src/detection/gpu/gpu_linux.c
src/detection/gtk_qt/gtk.c
src/detection/host/host_bsd.c
src/detection/icons/icons_linux.c
src/detection/localip/localip_linux.c
src/detection/gamepad/gamepad_nosupport.c
src/detection/media/media_linux.c
@@ -443,8 +451,10 @@ elseif(BSD)
src/detection/temps/temps_linux.c
src/detection/terminalfont/terminalfont_linux.c
src/detection/terminalshell/terminalshell_linux.c
src/detection/theme/theme_linux.c
src/detection/uptime/uptime_bsd.c
src/detection/users/users_linux.c
src/detection/wallpaper/wallpaper_linux.c
src/detection/wifi/wifi_nosupport.c
src/detection/wmtheme/wmtheme_linux.c
src/util/platform/FFPlatform_unix.c
@@ -470,6 +480,7 @@ elseif(APPLE)
src/detection/font/font_apple.m
src/detection/gpu/gpu_apple.c
src/detection/host/host_apple.c
src/detection/icons/icons_nosupport.c
src/detection/localip/localip_linux.c
src/detection/gamepad/gamepad_apple.c
src/detection/media/media_apple.m
@@ -484,8 +495,10 @@ elseif(APPLE)
src/detection/temps/temps_apple.c
src/detection/terminalfont/terminalfont_apple.m
src/detection/terminalshell/terminalshell_linux.c
src/detection/theme/theme_nosupport.c
src/detection/uptime/uptime_bsd.c
src/detection/users/users_linux.c
src/detection/wallpaper/wallpaper_apple.c
src/detection/wifi/wifi_apple.m
src/detection/wmtheme/wmtheme_apple.m
src/util/apple/cf_helpers.c
@@ -511,6 +524,7 @@ elseif(WIN32)
src/detection/font/font_windows.c
src/detection/gpu/gpu_windows.c
src/detection/host/host_windows.c
src/detection/icons/icons_windows.c
src/detection/localip/localip_windows.c
src/detection/gamepad/gamepad_windows.c
src/detection/media/media_nosupport.c
@@ -525,8 +539,10 @@ elseif(WIN32)
src/detection/terminalfont/terminalfont_windows.c
src/detection/terminalshell/terminalshell_windows.c
src/detection/temps/temps_windows.cpp
src/detection/theme/theme_nosupport.c
src/detection/uptime/uptime_windows.c
src/detection/users/users_windows.c
src/detection/wallpaper/wallpaper_windows.c
src/detection/wifi/wifi_windows.c
src/detection/wmtheme/wmtheme_windows.c
src/util/windows/getline.c
+2 -1
View File
@@ -64,6 +64,7 @@ The following libraries are used if present at runtime:
* [`MoltenVK`](https://github.com/KhronosGroup/MoltenVK): Vulkan driver for macOS. [`molten-vk`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/molten-vk.rb)
* [`libmagickcore` (ImageMagick)](https://www.imagemagick.org/): Images in terminal using sixel graphics protocol. [`imagemagick`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/imagemagick.rb)
* [`libchafa`](https://github.com/hpjansson/chafa): Image output as ascii art. [`chafa`](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/chafa.rb)
* [`libsqlite3`](https://www.sqlite.org/index.html): Used for fast wallpaper detection ( fallback to AppleScript )
For the image logo, iTerm with iterm image protocol should work. Apple Terminal is not supported.
@@ -89,7 +90,7 @@ All categories not listed here should work without needing a specific implementa
##### Available Modules
```
Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Theme, Time, Title, Uptime, Vulkan, Wifi, WM, WMTheme
Battery, Bios, Bluetooth, Board, Break, Brightness, Colors, Command, CPU, CPUUsage, Cursor, Custom, Date, DateTime, DE, Disk, Display, Font, Gamepad, GPU, Host, Icons, Kernel, Locale, LocalIP, Media, Memory, OpenCL, OpenGL, Packages, Player, Power Adapter, Processes, PublicIP, Separator, OS, Shell, Sound, Swap, Terminal, Terminal Font, Theme, Time, Title, Uptime, Vulkan, Wallpaper, Wifi, WM, WMTheme
```
##### Builtin logos
+10 -10
View File
@@ -32,8 +32,8 @@ __fastfetch_complete_help()
"battery-format"
"poweradapter-format"
"locale-format"
"local-ip-format"
"public-ip-format"
"localip-format"
"publicip-format"
"player-format"
"media-format"
"datetime-format"
@@ -235,8 +235,8 @@ __fastfetch_completion()
"--set-keyless"
"--player-name"
"--percent-type"
"--public-ip-url"
"--public-ip-timeout"
"--publicip-url"
"--publicip-timeout"
"--weather-output-format"
"--weather-timeout"
"--os-key"
@@ -317,12 +317,12 @@ __fastfetch_completion()
"--locale-key"
"--locale-format"
"--locale-error"
"--local-ip-key"
"--local-ip-format"
"--local-ip-error"
"--public-ip-key"
"--public-ip-format"
"--public-ip-error"
"--localip-key"
"--localip-format"
"--localip-error"
"--publicip-key"
"--publicip-format"
"--publicip-error"
"--wifi-key"
"--wifi-format"
"--wifi-error"
+1 -1
View File
@@ -1 +1 @@
--structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Terminal:TerminalFont:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Break:Colors
--structure Title:Separator:OS:Host:Bios:Board:Chassis:Kernel:Uptime:Processes:Packages:Shell:Display:Brightness:DE:WM:WMTheme:Theme:Icons:Font:Cursor:Wallpaper:Terminal:TerminalFont:CPU:CPUUsage:GPU:Memory:Swap:Disk:Battery:PowerAdapter:Player:Media:PublicIP:LocalIP:Wifi:DateTime:Locale:Vulkan:OpenGL:OpenCL:Users:Bluetooth:Sound:Gamepad:Weather:Break:Colors
+5 -9
View File
@@ -109,6 +109,7 @@ static void defaultConfig(FFinstance* instance)
initModuleArg(&instance->config.date);
initModuleArg(&instance->config.time);
initModuleArg(&instance->config.vulkan);
initModuleArg(&instance->config.wallpaper);
initModuleArg(&instance->config.openGL);
initModuleArg(&instance->config.openCL);
initModuleArg(&instance->config.users);
@@ -156,10 +157,7 @@ static void defaultConfig(FFinstance* instance)
instance->config.titleFQDN = false;
ffStrbufInitA(&instance->config.diskFolders, 0);
instance->config.diskShowRemovable = true;
instance->config.diskShowHidden = false;
instance->config.diskShowUnknown = false;
instance->config.diskShowSubvolumes = false;
instance->config.diskShowTypes = FF_DISK_TYPE_REGULAR_BIT | FF_DISK_TYPE_EXTERNAL_BIT;
instance->config.displayCompactType = FF_DISPLAY_COMPACT_TYPE_NONE;
instance->config.displayDetectName = false;
@@ -173,12 +171,8 @@ static void defaultConfig(FFinstance* instance)
ffStrbufInitA(&instance->config.separatorString, 0);
instance->config.localIpShowIpV4 = true;
instance->config.localIpShowIpV6 = false;
instance->config.localIpShowLoop = false;
instance->config.localIpV6First = false;
instance->config.localIpShowType = FF_LOCALIP_TYPE_IPV4_BIT;
ffStrbufInit(&instance->config.localIpNamePrefix);
instance->config.localIpCompactType = FF_LOCALIP_COMPACT_TYPE_NONE;
instance->config.publicIpTimeout = 0;
ffStrbufInit(&instance->config.publicIpUrl);
@@ -343,6 +337,7 @@ static void destroyConfig(FFinstance* instance)
destroyModuleArg(&instance->config.host);
destroyModuleArg(&instance->config.bios);
destroyModuleArg(&instance->config.board);
destroyModuleArg(&instance->config.chassis);
destroyModuleArg(&instance->config.kernel);
destroyModuleArg(&instance->config.uptime);
destroyModuleArg(&instance->config.processes);
@@ -369,6 +364,7 @@ static void destroyConfig(FFinstance* instance)
destroyModuleArg(&instance->config.locale);
destroyModuleArg(&instance->config.localIP);
destroyModuleArg(&instance->config.publicIP);
destroyModuleArg(&instance->config.wallpaper);
destroyModuleArg(&instance->config.weather);
destroyModuleArg(&instance->config.wifi);
destroyModuleArg(&instance->config.player);
+42
View File
@@ -297,6 +297,7 @@ typedef struct SQLiteData
FF_LIBRARY_SYMBOL(sqlite3_step)
FF_LIBRARY_SYMBOL(sqlite3_data_count)
FF_LIBRARY_SYMBOL(sqlite3_column_int)
FF_LIBRARY_SYMBOL(sqlite3_column_text)
FF_LIBRARY_SYMBOL(sqlite3_finalize)
FF_LIBRARY_SYMBOL(sqlite3_close)
} SQLiteData;
@@ -310,6 +311,7 @@ static const SQLiteData* getSQLiteData(const FFinstance* instance)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_step)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_data_count)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_column_int)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_column_text)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_finalize)
FF_LIBRARY_DATA_LOAD_SYMBOL(sqlite3_close)
@@ -350,12 +352,52 @@ int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, cons
return result;
}
bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath, const char* query, FFstrbuf* result)
{
if(!ffPathExists(dbPath, FF_PATHTYPE_FILE))
return false;
const SQLiteData* data = getSQLiteData(instance);
if(data == NULL)
return false;
sqlite3* db;
if(data->ffsqlite3_open_v2(dbPath, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK)
return false;
sqlite3_stmt* stmt;
if(data->ffsqlite3_prepare_v2(db, query, (int) strlen(query), &stmt, NULL) != SQLITE_OK)
{
data->ffsqlite3_close(db);
return false;
}
if(data->ffsqlite3_step(stmt) != SQLITE_ROW || data->ffsqlite3_data_count(stmt) < 1)
{
data->ffsqlite3_finalize(stmt);
data->ffsqlite3_close(db);
return false;
}
ffStrbufSetS(result, (const char *) data->ffsqlite3_column_text(stmt, 0));
data->ffsqlite3_finalize(stmt);
data->ffsqlite3_close(db);
return true;
}
#else //FF_HAVE_SQLITE3
int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query)
{
FF_UNUSED(instance, dbPath, query)
return 0;
}
bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath, const char* query, FFstrbuf* result)
{
FF_UNUSED(instance, dbPath, query, result)
return false;
}
#endif //FF_HAVE_SQLITE3
#ifdef __ANDROID__
+1
View File
@@ -31,6 +31,7 @@ FFvariant ffSettingsGet(const FFinstance* instance, const char* dconfKey, const
FFvariant ffSettingsGetXFConf(const FFinstance* instance, const char* channelName, const char* propertyName, FFvarianttype type);
int ffSettingsGetSQLite3Int(const FFinstance* instance, const char* dbPath, const char* query);
bool ffSettingsGetSQLite3String(const FFinstance* instance, const char* dbPath, const char* query, FFstrbuf* result);
#ifdef __ANDROID__
void ffSettingsGetAndroidProperty(const char* propName, FFstrbuf* result);
+11 -8
View File
@@ -168,13 +168,13 @@
# Sets the URL of public IP detection server to be used.
# Only HTTP protocol is supported, and the value should not contain "http://" prefix.
# Default is "ipinfo.io/ip".
#--public-ip-url "ipinfo.io/ip"
#--publicip-url "ipinfo.io/ip"
# Public IP timeout option:
# Sets the time to wait for the public ip server to respond.
# Must be a positive integer.
# Default is 0 (disabled).
#--public-ip-timeout 0
#--publicip-timeout 0
# Weather output format option:
# Sets the weather format to be used. It must be URI encoded.
@@ -321,8 +321,8 @@
#--battery-key Battery {1}
#--poweradapter-key Power Adapter {1}
#--locale-key Locale
#--local-ip-key Local IP ({1})
#--public-ip-key Public IP
#--localip-key Local IP ({1})
#--publicip-key Public IP
#--wifi-key Wifi
#--weather-key Weather
#--player-key Media Player
@@ -335,6 +335,7 @@
#--bluetooth-key Bluetooth
#--sound-key Sound
#--gamepad-key Gamepad
#--wallpaper-key Wallpaper
# Format options:
# Sets the format string for module values.
@@ -369,8 +370,8 @@
#--battery-format
#--poweradapter-format
#--locale-format
#--local-ip-format
#--public-ip-format
#--localip-format
#--publicip-format
#--weather-format
#--player-format
#--media-format
@@ -382,6 +383,7 @@
#--bluetooth-format
#--sound-format
#--gamepad-format
#--wallpaper-format
# Error options:
# Sets the format string to use if an error occured
@@ -416,8 +418,8 @@
#--battery-error
#--poweradapter-error
#--locale-error
#--local-ip-error
#--public-ip-error
#--localip-error
#--publicip-error
#--weather-error
#--player-error
#--media-error
@@ -429,6 +431,7 @@
#--bluetooth-error
#--sound-error
#--gamepad-error
#--wallpaper-error
# Library options:
# Sets an user specific path to a library to load.
+5 -4
View File
@@ -108,6 +108,7 @@ Module specific options:
--shell-version <?value>: Set if shell version should be detected and printed
--terminal-version <?value>: Set if terminal version should be detected and printed
--disk-folders <folders>: A colon (semicolon on Windows) separated list of folder paths for the disk output. Default is "/:/home" ("C:\\;D:\\ ..." on Windows)
--disk-show-regular <?value>: Set if regular volume should be printed. Default is true
--disk-show-removable <?value>: Set if removable volume should be printed. Default is true
--disk-show-hidden <?value>: Set if hidden volumes should be printed. Default is false
--disk-show-subvolumes <?value>: Set if subvolumes should be printed. Default is false
@@ -126,12 +127,12 @@ Module specific options:
--battery-temp <?value>: Detect and display Battery temperature if supported. Default is false
--localip-show-ipv4 <?value>: Show IPv4 addresses in local ip module. Default is true
--localip-show-ipv6 <?value>: Show IPv6 addresses in local ip module. Default is false
--localip-show-mac <?value>: Show mac addresses in local ip module. Default is false
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
--localip-name-prefix <str>: Show IPs with given name prefix only. Default is empty
--localip-compact-type <str>: Show IPs in one line. Should be either none, oneline, multiline. Default is none
--localip-v6first <?value>: Set if ipv6 should be printed first. Default is false
--public-ip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
--public-ip-url: The URL of public IP detection server to be used.
--localip-compact <?value>: Show all IPs in one line. Default is false
--publicip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
--publicip-url: The URL of public IP detection server to be used.
--weather-timeout: Time in milliseconds to wait for the weather server to respond. Default is disabled (0)
--weather-output-format: The output weather format to be used. It must be URI encoded.
--player-name: The name of the player to use
+16 -7
View File
@@ -2,6 +2,7 @@
#include "common/io/io.h"
#include <dirent.h>
#include <ctype.h>
const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result)
{
@@ -12,13 +13,13 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result)
if(dirp == NULL)
return "Failed to open `/sys/class/backlight/`";
FFstrbuf backlightDir;
FF_STRBUF_AUTO_DESTROY backlightDir;
ffStrbufInitA(&backlightDir, 64);
ffStrbufAppendS(&backlightDir, backlightDirPath);
uint32_t backlightDirLength = backlightDir.length;
FFstrbuf buffer;
FF_STRBUF_AUTO_DESTROY buffer;
ffStrbufInit(&buffer);
struct dirent* entry;
@@ -38,18 +39,26 @@ const char* ffDetectBrightness(FF_MAYBE_UNUSED FFlist* result)
if(ffReadFileBuffer(backlightDir.chars, &buffer))
{
FFBrightnessResult* display = (FFBrightnessResult*) ffListAdd(result);
ffStrbufInitS(&display->name, entry->d_name);
ffStrbufSubstrBeforeLastC(&backlightDir, '/');
ffStrbufAppendS(&backlightDir, "/device");
ffStrbufInitA(&display->name, PATH_MAX + 1);
if(realpath(backlightDir.chars, display->name.chars))
{
ffStrbufRecalculateLength(&display->name);
ffStrbufSubstrAfterLastC(&display->name, '/');
if(ffStrbufStartsWithS(&display->name, "card") && isdigit(display->name.chars[4]))
ffStrbufSubstrAfterFirstC(&display->name, '-');
}
else
ffStrbufInitS(&display->name, entry->d_name);
double maxBrightness = ffStrbufToDouble(&buffer);
display->value = (float) (actualBrightness * 100 / maxBrightness);
}
break;
}
ffStrbufSubstrBefore(&backlightDir, backlightDirLength);
}
closedir(dirp);
ffStrbufDestroy(&backlightDir);
ffStrbufDestroy(&buffer);
return NULL;
}
+13 -6
View File
@@ -18,11 +18,18 @@ const FFDiskResult* ffDetectDisks()
if(result.disks.length == 0 && result.error.length == 0)
ffStrbufAppendS(&result.error, "No disks found");
//We need to sort the disks, so that we can detect, which disk a path resides on
// For example for /boot/efi/bootmgr we need to check /boot/efi before /boot
//Note that we sort alphabetically here for a better ordering when printing the list,
// so the check must be done in reverse order
ffListSort(&result.disks, compareDisks);
else
{
//We need to sort the disks, so that we can detect, which disk a path resides on
// For example for /boot/efi/bootmgr we need to check /boot/efi before /boot
//Note that we sort alphabetically here for a better ordering when printing the list,
// so the check must be done in reverse order
ffListSort(&result.disks, compareDisks);
FF_LIST_FOR_EACH(FFDisk, disk, result.disks)
{
if(disk->bytesTotal == 0)
disk->type |= FF_DISK_TYPE_UNKNOWN_BIT;
}
}
);
}
-8
View File
@@ -5,14 +5,6 @@
#include "fastfetch.h"
typedef enum FFDiskType
{
FF_DISK_TYPE_REGULAR,
FF_DISK_TYPE_HIDDEN,
FF_DISK_TYPE_EXTERNAL,
FF_DISK_TYPE_SUBVOLUME
} FFDiskType;
typedef struct FFDisk
{
FFstrbuf mountpoint;
+3 -3
View File
@@ -7,11 +7,11 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk)
{
// FreeBSD doesn't support these flags
if(fs->f_flags & MNT_DONTBROWSE)
disk->type = FF_DISK_TYPE_HIDDEN;
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
else if(fs->f_flags & MNT_REMOVABLE)
disk->type = FF_DISK_TYPE_EXTERNAL;
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
else
disk->type = FF_DISK_TYPE_REGULAR;
disk->type = FF_DISK_TYPE_REGULAR_BIT;
ffStrbufInitS(&disk->name, [NSFileManager.defaultManager displayNameAtPath:@(fs->f_mntonname)].UTF8String);
}
+3 -3
View File
@@ -13,11 +13,11 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk)
ffStrbufStartsWithS(&disk->mountpoint, "/proc") ||
ffStrbufStartsWithS(&disk->mountpoint, "/zroot")
)
disk->type = FF_DISK_TYPE_HIDDEN;
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
else if((fs->f_flags & MNT_NOSUID) || !(fs->f_flags & MNT_LOCAL))
disk->type = FF_DISK_TYPE_EXTERNAL;
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
else
disk->type = FF_DISK_TYPE_REGULAR;
disk->type = FF_DISK_TYPE_REGULAR_BIT;
ffStrbufInit(&disk->name);
}
+17 -20
View File
@@ -17,14 +17,6 @@
static bool isPhysicalDevice(FFstrbuf* device)
{
struct stat deviceStat;
if(stat(device->chars, &deviceStat) != 0)
return false;
//Ignore all devices that are not block devices
if(!S_ISBLK(deviceStat.st_mode))
return false;
//DrvFs is a filesystem plugin to WSL that was designed to support interop between WSL and the Windows filesystem.
if(ffStrbufEqualS(device, "drvfs"))
return true;
@@ -33,6 +25,14 @@ static bool isPhysicalDevice(FFstrbuf* device)
if(ffStrbufStartsWithS(device, "rpool/"))
return true;
struct stat deviceStat;
if(stat(device->chars, &deviceStat) != 0)
return false;
//Ignore all devices that are not block devices
if(!S_ISBLK(deviceStat.st_mode))
return false;
//Pseudo filesystems don't have a device in /dev
if(!ffStrbufStartsWithS(device, "/dev/"))
return false;
@@ -112,7 +112,7 @@ static void detectName(FFDisk* disk, const FFstrbuf* device)
if(stat(device->chars, &deviceStat) != 0)
return;
FFstrbuf basePath;
FF_STRBUF_AUTO_DESTROY basePath;
ffStrbufInit(&basePath);
//Try partlabel first
@@ -129,8 +129,6 @@ static void detectName(FFDisk* disk, const FFstrbuf* device)
//Use the mountpoint as a last resort
if(disk->name.length == 0)
ffStrbufAppend(&disk->name, &disk->mountpoint);
ffStrbufDestroy(&basePath);
}
#ifdef __ANDROID__
@@ -138,11 +136,11 @@ static void detectName(FFDisk* disk, const FFstrbuf* device)
static void detectType(FF_MAYBE_UNUSED const FFlist* devices, FFDisk* currentDisk, FF_MAYBE_UNUSED const char* options)
{
if(ffStrbufEqualS(&currentDisk->mountpoint, "/") || ffStrbufEqualS(&currentDisk->mountpoint, "/storage/emulated"))
currentDisk->type = FF_DISK_TYPE_REGULAR;
currentDisk->type = FF_DISK_TYPE_REGULAR_BIT;
else if(ffStrbufStartsWithS(&currentDisk->mountpoint, "/mnt/media_rw/"))
currentDisk->type = FF_DISK_TYPE_EXTERNAL;
currentDisk->type = FF_DISK_TYPE_EXTERNAL_BIT;
else
currentDisk->type = FF_DISK_TYPE_HIDDEN;
currentDisk->type = FF_DISK_TYPE_HIDDEN_BIT;
}
#else
@@ -171,13 +169,13 @@ static bool isSubvolume(const FFlist* devices)
static void detectType(const FFlist* devices, FFDisk* currentDisk, const char* options)
{
if(isSubvolume(devices))
currentDisk->type = FF_DISK_TYPE_SUBVOLUME;
currentDisk->type = FF_DISK_TYPE_SUBVOLUME_BIT;
else if(strstr(options, "nosuid") != NULL || strstr(options, "nodev") != NULL)
currentDisk->type = FF_DISK_TYPE_EXTERNAL;
currentDisk->type = FF_DISK_TYPE_EXTERNAL_BIT;
else if(ffStrbufStartsWithS(&currentDisk->mountpoint, "/boot") || ffStrbufStartsWithS(&currentDisk->mountpoint, "/efi"))
currentDisk->type = FF_DISK_TYPE_HIDDEN;
currentDisk->type = FF_DISK_TYPE_HIDDEN_BIT;
else
currentDisk->type = FF_DISK_TYPE_REGULAR;
currentDisk->type = FF_DISK_TYPE_REGULAR_BIT;
}
#endif
@@ -204,7 +202,7 @@ void ffDetectDisksImpl(FFDiskResult* disks)
return;
}
FFlist devices;
FF_LIST_AUTO_DESTROY devices;
ffListInit(&devices, sizeof(FFstrbuf));
char* line = NULL;
@@ -254,7 +252,6 @@ void ffDetectDisksImpl(FFDiskResult* disks)
FF_LIST_FOR_EACH(FFstrbuf, device, devices)
ffStrbufDestroy(device);
ffListDestroy(&devices);
fclose(mountsFile);
}
+3 -3
View File
@@ -33,11 +33,11 @@ void ffDetectDisksImpl(FFDiskResult* disks)
disk->bytesUsed = disk->bytesTotal - bytesFree;
if(driveType == DRIVE_REMOVABLE || driveType == DRIVE_REMOTE || driveType == DRIVE_CDROM)
disk->type = FF_DISK_TYPE_EXTERNAL;
disk->type = FF_DISK_TYPE_EXTERNAL_BIT;
else if(driveType == DRIVE_FIXED)
disk->type = FF_DISK_TYPE_REGULAR;
disk->type = FF_DISK_TYPE_REGULAR_BIT;
else
disk->type = FF_DISK_TYPE_HIDDEN;
disk->type = FF_DISK_TYPE_HIDDEN_BIT;
ffStrbufInit(&disk->filesystem);
ffStrbufInit(&disk->name);
@@ -108,6 +108,7 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds, const FFinstance* ins
if(instance->config.allowSlowOperations)
{
FF_STRBUF_AUTO_DESTROY name;
ffStrbufInit(&name);
detectWMPlugin(&name);
if(name.length)
ffStrbufAppendF(&ds->wmPrettyName, " (with %s)", name.chars);
+78 -15
View File
@@ -19,6 +19,7 @@ typedef struct WaylandData
FF_LIBRARY_SYMBOL(wl_display_roundtrip)
struct wl_display* display;
const struct wl_interface* ffwl_output_interface;
bool detectName;
} WaylandData;
typedef struct WaylandDisplay
@@ -27,6 +28,10 @@ typedef struct WaylandDisplay
int32_t height;
int32_t refreshRate;
int32_t scale;
enum wl_output_transform transform;
FFDisplayType type;
FFstrbuf name;
bool detectName;
} WaylandDisplay;
#ifndef __FreeBSD__
@@ -57,10 +62,8 @@ static void stubListener(void* data, ...)
(void) data;
}
static void waylandOutputModeListener(void* data, struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate)
static void waylandOutputModeListener(void* data, FF_MAYBE_UNUSED struct wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refreshRate)
{
FF_UNUSED(output);
if(!(flags & WL_OUTPUT_MODE_CURRENT))
return;
@@ -70,16 +73,51 @@ static void waylandOutputModeListener(void* data, struct wl_output* output, uint
display->refreshRate = refreshRate;
}
#if WAYLAND_VERSION_MINOR >= 2
static void waylandOutputScaleListener(void* data, struct wl_output* output, int32_t scale)
#ifdef WL_OUTPUT_SCALE_SINCE_VERSION
static void waylandOutputScaleListener(void* data, FF_MAYBE_UNUSED struct wl_output* output, int32_t scale)
{
FF_UNUSED(output);
WaylandDisplay* display = data;
display->scale = scale;
}
#endif
static void waylandOutputGeometryListener(void *data,
FF_MAYBE_UNUSED struct wl_output *output,
FF_MAYBE_UNUSED int32_t x,
FF_MAYBE_UNUSED int32_t y,
FF_MAYBE_UNUSED int32_t physical_width,
FF_MAYBE_UNUSED int32_t physical_height,
FF_MAYBE_UNUSED int32_t subpixel,
const char *make,
const char *model,
int32_t transform)
{
WaylandDisplay* display = data;
display->transform = (enum wl_output_transform) transform;
if(display->detectName)
{
if(make && strcmp(make, "unknown") != 0)
ffStrbufAppendS(&display->name, make);
if(model && strcmp(model, "unknown") != 0)
{
if(display->name.length > 0)
ffStrbufAppendC(&display->name, '-');
ffStrbufAppendS(&display->name, model);
}
}
}
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_output *output, const char *name)
{
WaylandDisplay* display = data;
if(strncmp(name, "eDP-", strlen("eDP-")) == 0)
display->type = FF_DISPLAY_TYPE_BUILTIN;
else if(strncmp(name, "HDMI-", strlen("HDMI-")) == 0 || strncmp(name, "DP-", strlen("DP-")) == 0)
display->type = FF_DISPLAY_TYPE_EXTERNAL;
}
#endif
static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version)
{
struct wl_proxy* output = wldata->ffwl_proxy_marshal_constructor_versioned((struct wl_proxy*) registry, WL_REGISTRY_BIND, wldata->ffwl_output_interface, version, name, wldata->ffwl_output_interface->name, version, NULL);
@@ -87,25 +125,33 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
return;
WaylandDisplay display = {
.detectName = wldata->detectName,
.width = 0,
.height = 0,
.refreshRate = 0,
.scale = 1,
.transform = WL_OUTPUT_TRANSFORM_NORMAL,
.type = FF_DISPLAY_TYPE_UNKNOWN,
};
ffStrbufInit(&display.name);
struct wl_output_listener outputListener = {
.mode = waylandOutputModeListener,
.geometry = (void*) stubListener,
.geometry = waylandOutputGeometryListener,
//https://lists.freedesktop.org/archives/wayland-devel/2013-July/010278.html
#if WAYLAND_VERSION_MINOR >= 2
#ifdef WL_OUTPUT_DONE_SINCE_VERSION
.done = (void*) stubListener,
#endif
#ifdef WL_OUTPUT_SCALE_SINCE_VERSION
.scale = waylandOutputScaleListener,
#endif
//https://lists.freedesktop.org/archives/wayland-devel/2021-December/042064.html
#if WAYLAND_VERSION_MINOR >= 20
.name = (void*) stubListener,
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
.name = waylandOutputNameListener,
#endif
#ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION
.description = (void*) stubListener,
#endif
};
@@ -120,14 +166,29 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER;
ffThreadMutexLock(&mutex);
switch(display.transform)
{
case WL_OUTPUT_TRANSFORM_90:
case WL_OUTPUT_TRANSFORM_270:
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
case WL_OUTPUT_TRANSFORM_FLIPPED_270: {
int32_t temp = display.width;
display.width = display.height;
display.height = temp;
break;
}
default:
break;
}
ffdsAppendDisplay(wldata->result,
(uint32_t) display.width,
(uint32_t) display.height,
display.refreshRate / 1000.0,
(uint32_t) (display.width / display.scale),
(uint32_t) (display.height / display.scale),
NULL,
FF_DISPLAY_TYPE_UNKNOWN
&display.name,
display.type
);
ffThreadMutexUnlock(&mutex);
@@ -164,6 +225,8 @@ bool detectWayland(const FFinstance* instance, FFDisplayServerResult* result)
if(data.display == NULL)
return false;
data.detectName = instance->config.displayDetectName;
waylandDetectWM(ffwl_display_get_fd(data.display), result);
struct wl_proxy* registry = ffwl_proxy_marshal_constructor((struct wl_proxy*) data.display, WL_DISPLAY_GET_REGISTRY, ffwl_registry_interface, NULL);
+10
View File
@@ -141,6 +141,16 @@ static void getGnome(const FFinstance* instance, FFDisplayServerResult* result)
ffStrbufSetS(&result->deProcessName, "gnome-shell");
ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_GNOME);
ffParsePropFileData(instance, "gnome-shell/org.gnome.Extensions", "version :", &result->deVersion);
if (result->deVersion.length == 0)
{
if (ffProcessAppendStdOut(&result->deVersion, (char* const[]){
"gnome-shell",
"--version",
NULL
}) == NULL) // GNOME Shell 44.1
ffStrbufSubstrAfterLastC(&result->deVersion, ' ');
}
}
static void getCinnamon(const FFinstance* instance, FFDisplayServerResult* result)
+11 -5
View File
@@ -6,16 +6,22 @@
static void generateString(FFFontResult* font)
{
ffParseGTK(&font->display, &font->fonts[1], &font->fonts[2], &font->fonts[3]);
if(font->fonts[0].length > 0)
{
if(font->display.length > 0)
ffStrbufAppendS(&font->display, ", ");
ffStrbufAppend(&font->display, &font->fonts[0]);
ffStrbufAppendS(&font->display, " [QT]");
for(uint8_t i = 1; i < sizeof(font->fonts) / sizeof(font->fonts[0]); i++)
{
if(font->fonts[i].length > 0)
{
ffStrbufAppendS(&font->display, ", ");
break;
}
}
}
ffParseGTK(&font->display, &font->fonts[1], &font->fonts[2], &font->fonts[3]);
}
void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
+11 -3
View File
@@ -13,7 +13,7 @@ static inline bool allPropertiesSet(FFGTKResult* result)
result->font.length > 0;
}
static inline void applyGTKSettings(FFGTKResult* result, const char* themeName, const char* iconsName, const char* fontName, const char* cursorTheme, int cursorSize)
static inline void applyGTKSettings(FFGTKResult* result, const char* themeName, const char* iconsName, const char* fontName, const char* cursorTheme, int cursorSize, const char* wallpaper)
{
if(result->theme.length == 0)
ffStrbufAppendS(&result->theme, themeName);
@@ -29,6 +29,9 @@ static inline void applyGTKSettings(FFGTKResult* result, const char* themeName,
if(result->cursorSize.length == 0 && cursorSize > 0)
ffStrbufAppendF(&result->cursorSize, "%i", cursorSize);
if(result->wallpaper.length == 0)
ffStrbufAppendS(&result->wallpaper, wallpaper);
}
static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* result)
@@ -40,6 +43,7 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul
static const char* fontName = NULL;
static const char* cursorTheme = NULL;
static int cursorSize = 0;
static const char* wallpaper = NULL;
static bool init = false;
@@ -48,7 +52,7 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul
if(init)
{
ffThreadMutexUnlock(&mutex);
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize, wallpaper);
return;
}
@@ -63,6 +67,7 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul
fontName = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/FontName", FF_VARIANT_TYPE_STRING).strValue;
cursorTheme = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeName", FF_VARIANT_TYPE_STRING).strValue;
cursorSize = ffSettingsGetXFConf(instance, "xsettings", "/Gtk/CursorThemeSize", FF_VARIANT_TYPE_INT).intValue;
wallpaper = ffSettingsGetXFConf(instance, "xfce4-desktop", "/backdrop/screen0/monitor0/workspace0/last-image", FF_VARIANT_TYPE_STRING).strValue;
}
else if(ffStrbufIgnCaseCompS(&wmde->dePrettyName, FF_DE_PRETTY_CINNAMON) == 0)
{
@@ -90,10 +95,12 @@ static void detectGTKFromSettings(const FFinstance* instance, FFGTKResult* resul
fontName = ffSettingsGet(instance, "/org/gnome/desktop/interface/font-name", "org.gnome.desktop.interface", NULL, "font-name", FF_VARIANT_TYPE_STRING).strValue;
cursorTheme = ffSettingsGet(instance, "/org/gnome/desktop/interface/cursor-theme", "org.gnome.desktop.interface", NULL, "cursor-theme", FF_VARIANT_TYPE_STRING).strValue;
cursorSize = ffSettingsGet(instance, "/org/gnome/desktop/interface/cursor-size", "org.gnome.desktop.interface", NULL, "cursor-size", FF_VARIANT_TYPE_INT).intValue;
wallpaper = ffSettingsGet(instance, "/org/gnome/desktop/background/picture-uri", "org.gnome.desktop.background", NULL, "picture-uri", FF_VARIANT_TYPE_STRING).strValue;
// TODO: support other DEs for wallpaper
}
ffThreadMutexUnlock(&mutex);
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize);
applyGTKSettings(result, themeName, iconsName, fontName, cursorTheme, cursorSize, wallpaper);
}
static void detectGTKFromConfigFile(const char* filename, FFGTKResult* result)
@@ -184,6 +191,7 @@ static void detectGTK(const FFinstance* instance, const char* version, FFGTKResu
ffStrbufInit(&result.font); \
ffStrbufInit(&result.cursor); \
ffStrbufInit(&result.cursorSize); \
ffStrbufInit(&result.wallpaper); \
detectGTK(instance, #version, &result); \
ffThreadMutexUnlock(&mutex); \
return &result;
+1
View File
@@ -12,6 +12,7 @@ typedef struct FFGTKResult
FFstrbuf font;
FFstrbuf cursor;
FFstrbuf cursorSize;
FFstrbuf wallpaper;
} FFGTKResult;
typedef struct FFQtResult
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#ifndef FF_INCLUDED_detection_icons
#define FF_INCLUDED_detection_icons
#include "fastfetch.h"
const char* ffDetectIcons(const FFinstance* instance, FFstrbuf* result);
#endif
+36
View File
@@ -0,0 +1,36 @@
#include "icons.h"
#include "common/parsing.h"
#include "detection/gtk_qt/gtk_qt.h"
#include "detection/displayserver/displayserver.h"
const char* ffDetectIcons(const FFinstance* instance, FFstrbuf* result)
{
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0)
return "Icons aren't supported in TTY";
const FFstrbuf* plasma = &ffDetectQt(instance)->icons;
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->icons;
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->icons;
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->icons;
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
return "No icons could be found";
FF_STRBUF_AUTO_DESTROY gtkPretty;
ffStrbufInit(&gtkPretty);
ffParseGTK(&gtkPretty, gtk2, gtk3, gtk4);
if(plasma->length > 0)
{
ffStrbufAppend(result, plasma);
ffStrbufAppendS(result, " [QT]");
if(gtkPretty.length > 0)
ffStrbufAppendS(result, ", ");
}
ffStrbufAppend(result, &gtkPretty);
return NULL;
}
+6
View File
@@ -0,0 +1,6 @@
#include "icons.h"
const char* ffDetectIcons(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFstrbuf* result)
{
return "Not supported on this platform";
}
+33
View File
@@ -0,0 +1,33 @@
#include "icons.h"
#include "util/windows/registry.h"
const char* ffDetectIcons(FF_MAYBE_UNUSED const FFinstance* instance, FFstrbuf* result)
{
FF_HKEY_AUTO_DESTROY hKey = NULL;
if(!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\ClassicStartMenu", &hKey, NULL))
return "ffRegOpenKeyForRead(Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\ClassicStartMenu) failed";
// Whether these icons are hidden
uint32_t ThisPC = 0, UsersFiles = 0, RemoteNetwork = 0, RecycleBin = 0, ControlPanel = 0;
ffRegReadUint(hKey, L"{20D04FE0-3AEA-1069-A2D8-08002B30309D}", &ThisPC, NULL);
ffRegReadUint(hKey, L"{59031a47-3f72-44a7-89c5-5595fe6b30ee}", &UsersFiles, NULL);
ffRegReadUint(hKey, L"{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}", &RemoteNetwork, NULL);
ffRegReadUint(hKey, L"{645FF040-5081-101B-9F08-00AA002F954E}", &RecycleBin, NULL);
ffRegReadUint(hKey, L"{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}", &ControlPanel, NULL);
if (!ThisPC)
ffStrbufAppendS(result, "This PC, ");
if (!UsersFiles)
ffStrbufAppendS(result, "User's Files, ");
if (!RemoteNetwork)
ffStrbufAppendS(result, "Remote Network, ");
if (!RecycleBin)
ffStrbufAppendS(result, "Recycle Bin, ");
if (!ControlPanel)
ffStrbufAppendS(result, "Control Panel");
ffStrbufTrimRight(result, ' ');
ffStrbufTrimRight(result, ',');
return NULL;
}
+3 -2
View File
@@ -8,8 +8,9 @@
typedef struct FFLocalIpResult
{
FFstrbuf name;
FFstrbuf addr;
bool ipv6;
FFstrbuf ipv4;
FFstrbuf ipv6;
FFstrbuf mac;
} FFLocalIpResult;
const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results);
+66 -13
View File
@@ -7,12 +7,43 @@
#include <netinet/in.h>
#include <arpa/inet.h>
static void addNewIp(FFlist* list, const char* name, const char* addr, bool ipv6)
#if defined(__FreeBSD__) || defined(__APPLE__)
#include <net/if_dl.h>
#else
#include <linux/if_packet.h>
#endif
static void addNewIp(FFlist* list, const char* name, const char* addr, int type)
{
FFLocalIpResult* ip = (FFLocalIpResult*) ffListAdd(list);
ffStrbufInitS(&ip->name, name);
ffStrbufInitS(&ip->addr, addr);
ip->ipv6 = ipv6;
FFLocalIpResult* ip = NULL;
FF_LIST_FOR_EACH(FFLocalIpResult, temp, *list)
{
if (!ffStrbufEqualS(&temp->name, name)) continue;
ip = temp;
break;
}
if (!ip)
{
ip = (FFLocalIpResult*) ffListAdd(list);
ffStrbufInitS(&ip->name, name);
ffStrbufInit(&ip->ipv4);
ffStrbufInit(&ip->ipv6);
ffStrbufInit(&ip->mac);
}
switch (type)
{
case AF_INET:
ffStrbufSetS(&ip->ipv4, addr);
break;
case AF_INET6:
ffStrbufSetS(&ip->ipv6, addr);
break;
case -1:
ffStrbufSetS(&ip->mac, addr);
break;
}
}
const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results)
@@ -26,8 +57,7 @@ const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results)
if (!ifa->ifa_addr || !(ifa->ifa_flags & IFF_RUNNING))
continue;
// loop back
if ((ifa->ifa_flags & IFF_LOOPBACK) && !instance->config.localIpShowLoop)
if ((ifa->ifa_flags & IFF_LOOPBACK) && !(instance->config.localIpShowType & FF_LOCALIP_TYPE_LOOP_BIT))
continue;
if (instance->config.localIpNamePrefix.length && strncmp(ifa->ifa_name, instance->config.localIpNamePrefix.chars, instance->config.localIpNamePrefix.length) != 0)
@@ -35,26 +65,49 @@ const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results)
if (ifa->ifa_addr->sa_family == AF_INET)
{
// IPv4
if (!instance->config.localIpShowIpV4)
if (!(instance->config.localIpShowType & FF_LOCALIP_TYPE_IPV4_BIT))
continue;
struct sockaddr_in* ipv4 = (struct sockaddr_in*) ifa->ifa_addr;
char addressBuffer[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN);
addNewIp(results, ifa->ifa_name, addressBuffer, false);
addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET);
}
else if (ifa->ifa_addr->sa_family == AF_INET6)
{
// IPv6
if (!instance->config.localIpShowIpV6)
if (!(instance->config.localIpShowType & FF_LOCALIP_TYPE_IPV6_BIT))
continue;
struct sockaddr_in6* ipv6 = (struct sockaddr_in6 *)ifa->ifa_addr;
char addressBuffer[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, &ipv6->sin6_addr, addressBuffer, INET6_ADDRSTRLEN);
addNewIp(results, ifa->ifa_name, addressBuffer, true);
addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET6);
}
#if defined(__FreeBSD__) || defined(__APPLE__)
else if (ifa->ifa_addr->sa_family == AF_LINK)
{
if (!(instance->config.localIpShowType & FF_LOCALIP_TYPE_MAC_BIT))
continue;
char addressBuffer[32];
uint8_t* ptr = (uint8_t*) LLADDR((struct sockaddr_dl *)ifa->ifa_addr);
snprintf(addressBuffer, sizeof(addressBuffer), "%02x:%02x:%02x:%02x:%02x:%02x",
ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]);
addNewIp(results, ifa->ifa_name, addressBuffer, -1);
}
#else
else if (ifa->ifa_addr->sa_family == AF_PACKET)
{
if (!(instance->config.localIpShowType & FF_LOCALIP_TYPE_MAC_BIT))
continue;
char addressBuffer[32];
uint8_t* ptr = ((struct sockaddr_ll *)ifa->ifa_addr)->sll_addr;
snprintf(addressBuffer, sizeof(addressBuffer), "%02x:%02x:%02x:%02x:%02x:%02x",
ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]);
addNewIp(results, ifa->ifa_name, addressBuffer, -1);
}
#endif
}
if (ifAddrStruct) freeifaddrs(ifAddrStruct);
+53 -24
View File
@@ -1,21 +1,45 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <wchar.h>
#include "util/mallocHelper.h"
#include "util/windows/unicode.h"
#include "localip.h"
static void addNewIp(FFlist* list, const char* name, const char* addr, bool ipv6)
static void addNewIp(FFlist* list, const char* name, const char* value, int type, bool newIp)
{
FFLocalIpResult* ip = (FFLocalIpResult*) ffListAdd(list);
ffStrbufInitS(&ip->name, name);
ffStrbufInitS(&ip->addr, addr);
ip->ipv6 = ipv6;
FFLocalIpResult* ip = NULL;
if (newIp)
{
ip = (FFLocalIpResult*) ffListAdd(list);
ffStrbufInitS(&ip->name, name);
ffStrbufInit(&ip->ipv4);
ffStrbufInit(&ip->ipv6);
ffStrbufInit(&ip->mac);
}
else
{
ip = ffListGet(list, list->length - 1);
}
switch (type)
{
case AF_INET:
ffStrbufSetS(&ip->ipv4, value);
break;
case AF_INET6:
ffStrbufSetS(&ip->ipv6, value);
break;
case -1:
ffStrbufSetS(&ip->mac, value);
break;
}
}
const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results)
{
IP_ADAPTER_ADDRESSES* adapter_addresses = NULL;
IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = NULL;
// Start with a 16 KB buffer and resize if needed -
// multiple attempts in case interfaces change while
@@ -27,11 +51,10 @@ const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results)
assert(adapter_addresses);
DWORD error = GetAdaptersAddresses(
AF_UNSPEC,
GAA_FLAG_SKIP_ANYCAST |
GAA_FLAG_SKIP_MULTICAST |
GAA_FLAG_SKIP_DNS_SERVER |
GAA_FLAG_SKIP_FRIENDLY_NAME,
instance->config.localIpShowType & FF_LOCALIP_TYPE_IPV4_BIT
? instance->config.localIpShowType & FF_LOCALIP_TYPE_IPV6_BIT ? AF_UNSPEC : AF_INET
: AF_INET6,
GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER,
NULL,
adapter_addresses,
&adapter_addresses_buffer_size);
@@ -47,41 +70,47 @@ const char* ffDetectLocalIps(const FFinstance* instance, FFlist* results)
// Iterate through all of the adapters
for (IP_ADAPTER_ADDRESSES* adapter = adapter_addresses; adapter; adapter = adapter->Next)
{
if (adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK && !instance->config.localIpShowLoop)
bool isLoop = adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK;
if (isLoop && !(instance->config.localIpShowType & FF_LOCALIP_TYPE_LOOP_BIT))
continue;
bool newIp = true;
char name[128];
WideCharToMultiByte(CP_UTF8, 0, adapter->FriendlyName, -1, name, sizeof(name), NULL, NULL);
if (instance->config.localIpNamePrefix.length && strncmp(name, instance->config.localIpNamePrefix.chars, instance->config.localIpNamePrefix.length) != 0)
continue;
if (instance->config.localIpShowType & FF_LOCALIP_TYPE_MAC_BIT && adapter->PhysicalAddressLength == 6)
{
char addressBuffer[32];
uint8_t* ptr = adapter->PhysicalAddress;
snprintf(addressBuffer, sizeof(addressBuffer), "%02x:%02x:%02x:%02x:%02x:%02x",
ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]);
addNewIp(results, name, addressBuffer, -1, newIp);
newIp = false;
}
for (IP_ADAPTER_UNICAST_ADDRESS* ifa = adapter->FirstUnicastAddress; ifa; ifa = ifa->Next)
{
if (ifa->Address.lpSockaddr->sa_family == AF_INET)
{
// IPv4
if (!instance->config.localIpShowIpV4)
continue;
SOCKADDR_IN* ipv4 = (SOCKADDR_IN*) ifa->Address.lpSockaddr;
char addressBuffer[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN);
addNewIp(results, name, addressBuffer, false);
addNewIp(results, name, addressBuffer, AF_INET, newIp);
newIp = false;
}
else if (ifa->Address.lpSockaddr->sa_family == AF_INET6)
{
// IPv6
if (!instance->config.localIpShowIpV6)
continue;
SOCKADDR_IN6* ipv6 = (SOCKADDR_IN6*) ifa->Address.lpSockaddr;
char addressBuffer[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, &ipv6->sin6_addr, addressBuffer, INET6_ADDRSTRLEN);
addNewIp(results, name, addressBuffer, true);
addNewIp(results, name, addressBuffer, AF_INET6, newIp);
newIp = false;
}
}
}
free(adapter_addresses);
return NULL;
}
+1 -1
View File
@@ -7,7 +7,7 @@ const FFMediaResult* ffDetectMedia(const FFinstance* instance)
{
FF_DETECTION_INTERNAL_GUARD(FFMediaResult,
ffStrbufInitA(&result.error, 0);
ffStrbufInit(&result.busNameShort);
ffStrbufInit(&result.playerId);
ffStrbufInit(&result.player);
ffStrbufInit(&result.song);
ffStrbufInit(&result.artist);
+1 -1
View File
@@ -8,7 +8,7 @@
typedef struct FFMediaResult
{
FFstrbuf error;
FFstrbuf busNameShort; //e.g. plasma-browser-integration
FFstrbuf playerId; // Bus name on Linux, app bundle name on macOS. e.g. plasma-browser-integration
FFstrbuf player; // e.g. Google Chrome
FFstrbuf song;
FFstrbuf artist;
+3 -3
View File
@@ -57,17 +57,17 @@ static const char* getMedia(FFMediaResult* result)
if (identifier == nil)
identifier = MRNowPlayingClientGetParentAppBundleIdentifier(clientObj);
if (identifier != nil)
ffCfStrGetString(identifier, &result->busNameShort);
ffCfStrGetString(identifier, &result->playerId);
}
dispatch_group_leave(group);
});
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
if(result->busNameShort.length > 0)
if(result->playerId.length > 0)
{
char buf[128];
snprintf(buf, sizeof(buf), "name of app id \"%s\"", result->busNameShort.chars);
snprintf(buf, sizeof(buf), "name of app id \"%s\"", result->playerId.chars);
ffOsascript(buf, &result->player);
}
+2 -2
View File
@@ -87,14 +87,14 @@ static bool getBusProperties(FFDBusData* data, const char* busName, FFMediaResul
}
//Set short bus name
ffStrbufAppendS(&result->busNameShort, busName + sizeof(FF_DBUS_MPRIS_PREFIX) - 1);
ffStrbufAppendS(&result->playerId, busName + sizeof(FF_DBUS_MPRIS_PREFIX) - 1);
//We found a song, get the player name
ffDBusGetPropertyString(data, busName, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2", "Identity", &result->player);
if(result->player.length == 0)
ffDBusGetPropertyString(data, busName, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2", "DesktopEntry", &result->player);
if(result->player.length == 0)
ffStrbufAppend(&result->player, &result->busNameShort);
ffStrbufAppend(&result->player, &result->playerId);
return true;
}
+48 -2
View File
@@ -24,7 +24,52 @@ static void parseSystemVersion(FFOSResult* os)
ffStrbufInitS(&os->buildID, value.UTF8String);
}
void parseOSXSoftwareLicense(FFOSResult* os)
static bool detectOSCodeName(FFOSResult* os)
{
// https://en.wikipedia.org/wiki/MacOS_version_history
char* str_end;
const char* version = os->version.chars;
unsigned long num = strtoul(version, &str_end, 10);
if (str_end == version) return false;
switch (num)
{
case 14: ffStrbufAppendS(&os->codename, "Sonoma"); return true;
case 13: ffStrbufAppendS(&os->codename, "Ventura"); return true;
case 12: ffStrbufAppendS(&os->codename, "Monterey"); return true;
case 11: ffStrbufAppendS(&os->codename, "Big Sur"); return true;
case 10: {
version = str_end + 1;
num = strtoul(version, &str_end, 10);
if (str_end == version) return false;
switch (num)
{
case 16: ffStrbufAppendS(&os->codename, "Big Sur"); return true;
case 15: ffStrbufAppendS(&os->codename, "Catalina"); return true;
case 14: ffStrbufAppendS(&os->codename, "Mojave"); return true;
case 13: ffStrbufAppendS(&os->codename, "High Sierra"); return true;
case 12: ffStrbufAppendS(&os->codename, "Sierra"); return true;
case 11: ffStrbufAppendS(&os->codename, "El Capitan"); return true;
case 10: ffStrbufAppendS(&os->codename, "Yosemite"); return true;
case 9: ffStrbufAppendS(&os->codename, "Mavericks"); return true;
case 8: ffStrbufAppendS(&os->codename, "Mountain Lion"); return true;
case 7: ffStrbufAppendS(&os->codename, "Lion"); return true;
case 6: ffStrbufAppendS(&os->codename, "Snow Leopard"); return true;
case 5: ffStrbufAppendS(&os->codename, "Leopard"); return true;
case 4: ffStrbufAppendS(&os->codename, "Tiger"); return true;
case 3: ffStrbufAppendS(&os->codename, "Panther"); return true;
case 2: ffStrbufAppendS(&os->codename, "Jaguar"); return true;
case 1: ffStrbufAppendS(&os->codename, "Puma"); return true;
case 0: ffStrbufAppendS(&os->codename, "Cheetah"); return true;
}
}
}
return false;
}
static void parseOSXSoftwareLicense(FFOSResult* os)
{
FILE* rtf = fopen("/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf", "r");
if(rtf == NULL)
@@ -81,5 +126,6 @@ void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance)
ffStrbufAppend(&os->prettyName, &os->name);
ffStrbufAppend(&os->versionID, &os->version);
parseOSXSoftwareLicense(os);
if(!detectOSCodeName(os))
parseOSXSoftwareLicense(os);
}
+1 -1
View File
@@ -77,7 +77,7 @@ static const char* detectSound(const FFinstance* instance, FFlist* devices)
return "Failed to connect to pulseaudio context";
}
int state;
pa_context_state_t state;
while((state = ffpa_context_get_state(context)) != PA_CONTEXT_READY)
{
if(!PA_CONTEXT_IS_GOOD(state))
@@ -410,6 +410,8 @@ static bool detectTerminalFontCommon(const FFinstance* instance, const FFTermina
detectTabby(instance, terminalFont);
#ifndef _WIN32
else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/pts/"))
ffStrbufAppendS(&terminalFont->error, "Terminal font detection is not supported on PTS");
else if(ffStrbufIgnCaseEqualS(&terminalShell->terminalProcessName, "kitty"))
detectKitty(instance, terminalFont);
else if(ffStrbufStartsWithIgnCaseS(&terminalShell->terminalExe, "/dev/tty"))
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#ifndef FF_INCLUDED_detection_theme
#define FF_INCLUDED_detection_theme
#include "fastfetch.h"
const char* ffDetectTheme(const FFinstance* instance, FFstrbuf* result);
#endif
+69
View File
@@ -0,0 +1,69 @@
#include "theme.h"
#include "common/parsing.h"
#include "detection/gtk_qt/gtk_qt.h"
#include "detection/displayserver/displayserver.h"
const char* ffDetectTheme(const FFinstance* instance, FFstrbuf* result)
{
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0)
return "Theme isn't supported in TTY";
const FFQtResult* plasma = ffDetectQt(instance);
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->theme;
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->theme;
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->theme;
if(plasma->widgetStyle.length == 0 && plasma->colorScheme.length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
return "No themes found";
FF_STRBUF_AUTO_DESTROY plasmaColorPretty;
ffStrbufInit(&plasmaColorPretty);
if(ffStrbufStartsWithIgnCase(&plasma->colorScheme, &plasma->widgetStyle))
ffStrbufAppendNS(&plasmaColorPretty, plasma->colorScheme.length - plasma->widgetStyle.length, &plasma->colorScheme.chars[plasma->widgetStyle.length]);
else
ffStrbufAppend(&plasmaColorPretty, &plasma->colorScheme);
ffStrbufTrim(&plasmaColorPretty, ' ');
FF_STRBUF_AUTO_DESTROY gtkPretty;
ffStrbufInit(&gtkPretty);
ffParseGTK(&gtkPretty, gtk2, gtk3, gtk4);
if(plasma->widgetStyle.length > 0)
{
ffStrbufAppend(result, &plasma->widgetStyle);
if(plasma->colorScheme.length > 0)
{
ffStrbufAppendS(result, " (");
if(plasmaColorPretty.length > 0)
ffStrbufAppend(result, &plasmaColorPretty);
else
ffStrbufAppend(result, &plasma->colorScheme);
ffStrbufAppendC(result, ')');
}
}
else if(plasma->colorScheme.length > 0)
{
if(plasmaColorPretty.length > 0)
ffStrbufAppend(result, &plasmaColorPretty);
else
ffStrbufAppend(result, &plasma->colorScheme);
}
if(plasma->widgetStyle.length > 0 || plasma->colorScheme.length > 0)
{
ffStrbufAppendS(result, " [QT]");
if(gtkPretty.length > 0)
ffStrbufAppendS(result, ", ");
}
ffStrbufAppend(result, &gtkPretty);
return NULL;
}
+6
View File
@@ -0,0 +1,6 @@
#include "theme.h"
const char* ffDetectTheme(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFstrbuf* result)
{
return "Not supported on this platform";
}
+10
View File
@@ -0,0 +1,10 @@
#pragma once
#ifndef FF_INCLUDED_detection_wallpaper
#define FF_INCLUDED_detection_wallpaper
#include "fastfetch.h"
const char* ffDetectWallpaper(const FFinstance* instance, FFstrbuf* result);
#endif
+31
View File
@@ -0,0 +1,31 @@
#include "wallpaper.h"
#include "common/settings.h"
#include "util/apple/osascript.h"
const char* ffDetectWallpaper(FF_MAYBE_UNUSED const FFinstance* instance, FFstrbuf* result)
{
// https://stackoverflow.com/questions/301215/getting-desktop-background-on-mac
#ifdef FF_HAVE_SQLITE3
FF_STRBUF_AUTO_DESTROY path;
ffStrbufInitCopy(&path, &instance->state.platform.homeDir);
ffStrbufAppendS(&path, "Library/Application Support/Dock/desktoppicture.db");
if (ffSettingsGetSQLite3String(instance, path.chars,
"SELECT value\n"
"FROM preferences\n"
"JOIN data ON preferences.data_id=data.ROWID\n"
"JOIN pictures ON preferences.picture_id=pictures.ROWID\n"
"JOIN displays ON pictures.display_id=displays.ROWID\n"
"JOIN spaces ON pictures.space_id=spaces.ROWID\n"
"WHERE display_id=1 AND space_id=1 AND key=1", result)
)
return NULL;
#endif
if (!ffOsascript("tell application \"Finder\" to get POSIX path of (get desktop picture as alias)", result))
return "ffOsascript() failed";
return NULL;
}
+17
View File
@@ -0,0 +1,17 @@
#include "wallpaper.h"
#include "common/settings.h"
#include "detection/gtk_qt/gtk_qt.h"
const char* ffDetectWallpaper(const FFinstance* instance, FFstrbuf* result)
{
const FFGTKResult* gtk = ffDetectGTK4(instance);
if (!gtk->wallpaper.length)
return "Failed to detect the current wallpaper path";
if (ffStrbufStartsWithS(&gtk->wallpaper, "file:///"))
ffStrbufAppendS(result, gtk->wallpaper.chars + strlen("file://"));
else
ffStrbufAppend(result, &gtk->wallpaper);
return NULL;
}
@@ -0,0 +1,6 @@
#include "wallpaper.h"
const char* ffDetectWallpaper(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_UNUSED FFstrbuf* result)
{
return "Not supported on this platform";
}
@@ -0,0 +1,14 @@
#include "wallpaper.h"
#include "util/windows/registry.h"
const char* ffDetectWallpaper(FF_MAYBE_UNUSED const FFinstance* instance, FFstrbuf* result)
{
FF_HKEY_AUTO_DESTROY hKey = NULL;
if(!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Desktop", &hKey, NULL))
return "ffRegOpenKeyForRead(Control Panel\\Desktop) failed";
if(!ffRegReadStrbuf(hKey, L"WallPaper", result, NULL))
return "ffRegReadStrbuf(WallPaper) failed";
return NULL;
}
+33 -37
View File
@@ -15,6 +15,8 @@
#include "util/windows/getline.h"
#endif
#pragma GCC diagnostic ignored "-Wsign-conversion"
typedef struct CustomValue
{
bool printKey;
@@ -207,24 +209,20 @@ static inline void printCommandHelp(const char* command)
}
else if(strcasecmp(command, "theme-format") == 0)
{
constructAndPrintCommandHelpFormat("theme", "{} ({3}) [Plasma], {7}", 7,
"Plasma theme",
"Plasma color scheme",
"Plasma color scheme pretty",
"GTK2 theme",
"GTK3 theme",
"GTK4 theme",
"Combined GTK themes"
constructAndPrintCommandHelpFormat("theme", "{}", 1,
"Combined themes"
);
}
else if(strcasecmp(command, "icons-format") == 0)
{
constructAndPrintCommandHelpFormat("icons", "{} [Plasma], {5}", 5,
"Plasma icons",
"GTK2 icons",
"GTK3 icons",
"GTK4 icons",
"Combined GTK icons"
constructAndPrintCommandHelpFormat("icons", "{}", 1,
"Combined icons"
);
}
else if(strcasecmp(command, "wallpaper-format") == 0)
{
constructAndPrintCommandHelpFormat("wallpaper", "{}", 1,
"Wallpaper image file"
);
}
else if(strcasecmp(command, "font-format") == 0)
@@ -385,7 +383,7 @@ static inline void printCommandHelp(const char* command)
constructAndPrintCommandHelpFormat("player", "{}", 4,
"Pretty player name",
"Player name",
"DBus bus name",
"Player Identifier",
"URL name"
);
}
@@ -1149,6 +1147,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
else if(optionParseModuleArgs(key, value, "wm-theme", &instance->config.wmTheme)) {}
else if(optionParseModuleArgs(key, value, "theme", &instance->config.theme)) {}
else if(optionParseModuleArgs(key, value, "icons", &instance->config.icons)) {}
else if(optionParseModuleArgs(key, value, "wallpaper", &instance->config.wallpaper)) {}
else if(optionParseModuleArgs(key, value, "font", &instance->config.font)) {}
else if(optionParseModuleArgs(key, value, "cursor", &instance->config.cursor)) {}
else if(optionParseModuleArgs(key, value, "terminal", &instance->config.terminal)) {}
@@ -1162,8 +1161,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
else if(optionParseModuleArgs(key, value, "battery", &instance->config.battery)) {}
else if(optionParseModuleArgs(key, value, "poweradapter", &instance->config.powerAdapter)) {}
else if(optionParseModuleArgs(key, value, "locale", &instance->config.locale)) {}
else if(optionParseModuleArgs(key, value, "local-ip", &instance->config.localIP)) {}
else if(optionParseModuleArgs(key, value, "public-ip", &instance->config.publicIP)) {}
else if(optionParseModuleArgs(key, value, "localip", &instance->config.localIP)) {}
else if(optionParseModuleArgs(key, value, "publicip", &instance->config.publicIP)) {}
else if(optionParseModuleArgs(key, value, "weather", &instance->config.weather)) {}
else if(optionParseModuleArgs(key, value, "player", &instance->config.player)) {}
else if(optionParseModuleArgs(key, value, "media", &instance->config.media)) {}
@@ -1263,14 +1262,16 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
instance->config.terminalVersion = optionParseBoolean(value);
else if(strcasecmp(key, "--disk-folders") == 0)
optionParseString(key, value, &instance->config.diskFolders);
else if(strcasecmp(key, "--disk-show-regular") == 0)
optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_REGULAR_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_REGULAR_BIT);
else if(strcasecmp(key, "--disk-show-removable") == 0)
instance->config.diskShowRemovable = optionParseBoolean(value);
optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_EXTERNAL_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_EXTERNAL_BIT);
else if(strcasecmp(key, "--disk-show-hidden") == 0)
instance->config.diskShowHidden = optionParseBoolean(value);
optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_HIDDEN_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_HIDDEN_BIT);
else if(strcasecmp(key, "--disk-show-subvolumes") == 0)
instance->config.diskShowSubvolumes = optionParseBoolean(value);
optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_SUBVOLUME_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_SUBVOLUME_BIT);
else if(strcasecmp(key, "--disk-show-unknown") == 0)
instance->config.diskShowUnknown = optionParseBoolean(value);
optionParseBoolean(value) ? (instance->config.diskShowTypes |= FF_DISK_TYPE_UNKNOWN_BIT) : (instance->config.diskShowTypes &= ~FF_DISK_TYPE_UNKNOWN_BIT);
else if(strcasecmp(key, "--display-compact-type") == 0)
{
optionParseEnum(key, value, &instance->config.displayCompactType,
@@ -1298,32 +1299,25 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
optionParseString(key, value, &instance->config.batteryDir);
else if(strcasecmp(key, "--separator-string") == 0)
optionParseString(key, value, &instance->config.separatorString);
else if(strcasecmp(key, "--localip-v6first") == 0)
instance->config.localIpV6First = optionParseBoolean(value);
else if(strcasecmp(key, "--localip-show-ipv4") == 0)
instance->config.localIpShowIpV4 = optionParseBoolean(value);
optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_IPV4_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_IPV4_BIT);
else if(strcasecmp(key, "--localip-show-ipv6") == 0)
instance->config.localIpShowIpV6 = optionParseBoolean(value);
optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_IPV6_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_IPV6_BIT);
else if(strcasecmp(key, "--localip-show-mac") == 0)
optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_MAC_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_MAC_BIT);
else if(strcasecmp(key, "--localip-show-loop") == 0)
instance->config.localIpShowLoop = optionParseBoolean(value);
optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_LOOP_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_LOOP_BIT);
else if(strcasecmp(key, "--localip-compact") == 0)
optionParseBoolean(value) ? (instance->config.localIpShowType |= FF_LOCALIP_TYPE_COMPACT_BIT) : (instance->config.localIpShowType &= ~FF_LOCALIP_TYPE_COMPACT_BIT);
else if(strcasecmp(key, "--localip-name-prefix") == 0)
optionParseString(key, value, &instance->config.localIpNamePrefix);
else if(strcasecmp(key, "--localip-compact-type") == 0)
{
optionParseEnum(key, value, &instance->config.localIpCompactType,
"none", FF_LOCALIP_COMPACT_TYPE_NONE,
"oneline", FF_LOCALIP_COMPACT_TYPE_ONELINE,
"multiline", FF_LOCALIP_COMPACT_TYPE_MULTILINE,
NULL
);
}
else if(strcasecmp(key, "--os-file") == 0)
optionParseString(key, value, &instance->config.osFile);
else if(strcasecmp(key, "--player-name") == 0)
optionParseString(key, value, &instance->config.playerName);
else if(strcasecmp(key, "--public-ip-url") == 0)
else if(strcasecmp(key, "--publicip-url") == 0)
optionParseString(key, value, &instance->config.publicIpUrl);
else if(strcasecmp(key, "--public-ip-timeout") == 0)
else if(strcasecmp(key, "--publicip-timeout") == 0)
instance->config.publicIpTimeout = optionParseUInt32(key, value);
else if(strcasecmp(key, "--weather-output-format") == 0)
optionParseString(key, value, &instance->config.weatherOutputFormat);
@@ -1454,6 +1448,8 @@ static void parseStructureCommand(FFinstance* instance, FFdata* data, const char
ffPrintWMTheme(instance);
else if(strcasecmp(line, "icons") == 0)
ffPrintIcons(instance);
else if(strcasecmp(line, "wallpaper") == 0)
ffPrintWallpaper(instance);
else if(strcasecmp(line, "font") == 0)
ffPrintFont(instance);
else if(strcasecmp(line, "cursor") == 0)
+25 -9
View File
@@ -55,6 +55,16 @@ typedef enum FFLocalIpCompactType
FF_LOCALIP_COMPACT_TYPE_ONELINE,
} FFLocalIpCompactType;
typedef enum FFDiskType
{
FF_DISK_TYPE_NONE = 0,
FF_DISK_TYPE_REGULAR_BIT = 1 << 0,
FF_DISK_TYPE_HIDDEN_BIT = 1 << 1,
FF_DISK_TYPE_EXTERNAL_BIT = 1 << 2,
FF_DISK_TYPE_SUBVOLUME_BIT = 1 << 3,
FF_DISK_TYPE_UNKNOWN_BIT = 1 << 4,
} FFDiskType;
typedef enum FFBinaryPrefixType
{
FF_BINARY_PREFIX_TYPE_IEC, // 1024 Bytes = 1 KiB, 1024 KiB = 1 MiB, ... (standard)
@@ -77,6 +87,17 @@ typedef struct FFModuleArgs
FFstrbuf errorFormat;
} FFModuleArgs;
typedef enum FFLocalIpType
{
FF_LOCALIP_TYPE_NONE,
FF_LOCALIP_TYPE_LOOP_BIT = 1 << 0,
FF_LOCALIP_TYPE_IPV4_BIT = 1 << 1,
FF_LOCALIP_TYPE_IPV6_BIT = 1 << 2,
FF_LOCALIP_TYPE_MAC_BIT = 1 << 3,
FF_LOCALIP_TYPE_COMPACT_BIT = 1 << 10,
} FFLocalIpType;
typedef struct FFconfig
{
struct
@@ -130,6 +151,7 @@ typedef struct FFconfig
FFModuleArgs shell;
FFModuleArgs display;
FFModuleArgs de;
FFModuleArgs wallpaper;
FFModuleArgs wifi;
FFModuleArgs wm;
FFModuleArgs wmTheme;
@@ -204,10 +226,7 @@ typedef struct FFconfig
bool terminalVersion;
FFstrbuf diskFolders;
bool diskShowRemovable;
bool diskShowHidden;
bool diskShowUnknown;
bool diskShowSubvolumes;
FFDiskType diskShowTypes;
FFDisplayCompactType displayCompactType;
bool displayDetectName;
@@ -219,12 +238,8 @@ typedef struct FFconfig
FFstrbuf separatorString;
bool localIpShowLoop;
bool localIpV6First;
bool localIpShowIpV4;
bool localIpShowIpV6;
FFstrbuf localIpNamePrefix;
FFLocalIpCompactType localIpCompactType;
FFLocalIpType localIpShowType;
FFstrbuf publicIpUrl;
uint32_t publicIpTimeout;
@@ -318,6 +333,7 @@ void ffPrintWM(FFinstance* instance);
void ffPrintWMTheme(FFinstance* instance);
void ffPrintTheme(FFinstance* instance);
void ffPrintIcons(FFinstance* instance);
void ffPrintWallpaper(FFinstance* instance);
void ffPrintFont(FFinstance* instance);
void ffPrintCursor(FFinstance* instance);
void ffPrintTerminal(FFinstance* instance);
+16 -26
View File
@@ -9,7 +9,7 @@
static void printDisk(FFinstance* instance, const FFDisk* disk)
{
FFstrbuf key;
FF_STRBUF_AUTO_DESTROY key;
ffStrbufInit(&key);
if(instance->config.disk.key.length == 0)
@@ -23,11 +23,11 @@ static void printDisk(FFinstance* instance, const FFDisk* disk)
});
}
FFstrbuf usedPretty;
FF_STRBUF_AUTO_DESTROY usedPretty;
ffStrbufInit(&usedPretty);
ffParseSize(disk->bytesUsed, instance->config.binaryPrefixType, &usedPretty);
FFstrbuf totalPretty;
FF_STRBUF_AUTO_DESTROY totalPretty;
ffStrbufInit(&totalPretty);
ffParseSize(disk->bytesTotal, instance->config.binaryPrefixType, &totalPretty);
@@ -37,7 +37,7 @@ static void printDisk(FFinstance* instance, const FFDisk* disk)
{
ffPrintLogoAndKey(instance, key.chars, 0, NULL);
FFstrbuf str;
FF_STRBUF_AUTO_DESTROY str;
ffStrbufInit(&str);
if(disk->bytesTotal > 0)
@@ -60,12 +60,11 @@ static void printDisk(FFinstance* instance, const FFDisk* disk)
else
ffStrbufAppendS(&str, "Unknown ");
if(disk->type == FF_DISK_TYPE_EXTERNAL && !(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
if(disk->type & FF_DISK_TYPE_EXTERNAL_BIT && !(instance->config.percentType & FF_PERCENTAGE_TYPE_HIDE_OTHERS_BIT))
ffStrbufAppendS(&str, "[Removable]");
ffStrbufTrimRight(&str, ' ');
ffStrbufPutTo(&str, stdout);
ffStrbufDestroy(&str);
}
else
{
@@ -78,16 +77,12 @@ static void printDisk(FFinstance* instance, const FFDisk* disk)
{FF_FORMAT_ARG_TYPE_UINT, &disk->filesUsed},
{FF_FORMAT_ARG_TYPE_UINT, &disk->filesTotal},
{FF_FORMAT_ARG_TYPE_UINT8, &filesPercentage},
{FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type == FF_DISK_TYPE_EXTERNAL)},
{FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type == FF_DISK_TYPE_HIDDEN)},
{FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type & FF_DISK_TYPE_EXTERNAL_BIT)},
{FF_FORMAT_ARG_TYPE_BOOL, FF_FORMAT_ARG_VALUE_BOOL(disk->type & FF_DISK_TYPE_HIDDEN_BIT)},
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem},
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->name}
});
}
ffStrbufDestroy(&totalPretty);
ffStrbufDestroy(&usedPretty);
ffStrbufDestroy(&key);
}
static void printMountpoint(FFinstance* instance, const FFlist* disks, const char* mountpoint)
@@ -113,7 +108,7 @@ static void printMountpoints(FFinstance* instance, const FFlist* disks)
const char separator = ':';
#endif
FFstrbuf mountpoints;
FF_STRBUF_AUTO_DESTROY mountpoints;
ffStrbufInitCopy(&mountpoints, &instance->config.diskFolders);
ffStrbufTrim(&mountpoints, separator);
@@ -131,24 +126,19 @@ static void printMountpoints(FFinstance* instance, const FFlist* disks)
static void printAutodetected(FFinstance* instance, const FFlist* disks)
{
for(uint32_t i = 0; i < disks->length; i++)
bool found = false;
FF_LIST_FOR_EACH(FFDisk, disk, *disks)
{
const FFDisk* disk = ffListGet(disks, i);
if(disk->type == FF_DISK_TYPE_EXTERNAL && !instance->config.diskShowRemovable)
continue;
if(disk->type == FF_DISK_TYPE_SUBVOLUME && !instance->config.diskShowSubvolumes)
continue;
if(disk->type == FF_DISK_TYPE_HIDDEN && !instance->config.diskShowHidden)
continue;
if(disk->bytesTotal == 0 && !instance->config.diskShowUnknown)
if(!(disk->type & instance->config.diskShowTypes))
continue;
printDisk(instance, disk);
found = true;
}
if (!found)
ffPrintError(instance, FF_DISK_MODULE_NAME, 0, &instance->config.disk, "No disk found");
}
void ffPrintDisk(FFinstance* instance)
+9 -48
View File
@@ -1,70 +1,31 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "common/parsing.h"
#include "detection/gtk_qt/gtk_qt.h"
#include "detection/displayserver/displayserver.h"
#include "detection/icons/icons.h"
#define FF_ICONS_MODULE_NAME "Icons"
#define FF_ICONS_NUM_FORMAT_ARGS 5
#define FF_ICONS_NUM_FORMAT_ARGS 1
void ffPrintIcons(FFinstance* instance)
{
#if defined(__ANDROID__) || defined(__APPLE__) || defined(_WIN32)
FF_STRBUF_AUTO_DESTROY icons;
ffStrbufInit(&icons);
const char* error = ffDetectIcons(instance, &icons);
FF_UNUSED(instance);
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons, "Icons detection is not supported");
return;
#else
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0)
if(error)
{
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons, "Icons aren't supported in TTY");
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons, "%s", error);
return;
}
const FFstrbuf* plasma = &ffDetectQt(instance)->icons;
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->icons;
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->icons;
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->icons;
if(plasma->length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
{
ffPrintError(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons, "No icons could be found");
return;
}
FF_STRBUF_AUTO_DESTROY gtkPretty;
ffStrbufInit(&gtkPretty);
ffParseGTK(&gtkPretty, gtk2, gtk3, gtk4);
if(instance->config.icons.outputFormat.length == 0)
{
ffPrintLogoAndKey(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons.key);
if(plasma->length > 0)
{
ffStrbufWriteTo(plasma, stdout);
fputs(" [QT]", stdout);
if(gtkPretty.length > 0)
fputs(", ", stdout);
}
ffStrbufPutTo(&gtkPretty, stdout);
ffStrbufPutTo(&icons, stdout);
}
else
{
ffPrintFormat(instance, FF_ICONS_MODULE_NAME, 0, &instance->config.icons, FF_ICONS_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, plasma},
{FF_FORMAT_ARG_TYPE_STRBUF, gtk2},
{FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
{FF_FORMAT_ARG_TYPE_STRBUF, gtk4},
{FF_FORMAT_ARG_TYPE_STRBUF, &gtkPretty}
{FF_FORMAT_ARG_TYPE_STRBUF, &icons}
});
}
#endif
}
+38 -62
View File
@@ -5,28 +5,9 @@
#define FF_LOCALIP_MODULE_NAME "Local IP"
#define FF_LOCALIP_NUM_FORMAT_ARGS 2
static int sortIpsV4First(const FFLocalIpResult* left, const FFLocalIpResult* right)
static int sortIps(const FFLocalIpResult* left, const FFLocalIpResult* right)
{
int name = ffStrbufComp(&left->name, &right->name);
if (name != 0)
return name;
if (left->ipv6 != right->ipv6)
return left->ipv6 == false ? -1 : 1;
return ffStrbufComp(&left->addr, &right->addr);
}
static int sortIpsV6First(const FFLocalIpResult* left, const FFLocalIpResult* right)
{
int name = ffStrbufComp(&left->name, &right->name);
if (name != 0)
return name;
if (left->ipv6 != right->ipv6)
return left->ipv6 == true ? -1 : 1;
return ffStrbufComp(&left->addr, &right->addr);
return ffStrbufComp(&left->name, &right->name);
}
static void formatKey(const FFinstance* instance, const FFLocalIpResult* ip, FFstrbuf* key)
@@ -47,32 +28,27 @@ static void formatKey(const FFinstance* instance, const FFLocalIpResult* ip, FFs
}
}
static void printIpsOneline(FFlist* ips)
static void printIp(FFLocalIpResult* ip)
{
uint32_t index = 0;
FF_LIST_FOR_EACH(FFLocalIpResult, ip, *ips)
bool flag = false;
if (ip->ipv4.length)
{
if (index++ > 0)
putchar(' ');
ffStrbufWriteTo(&ip->addr, stdout);
ffStrbufWriteTo(&ip->ipv4, stdout);
flag = true;
}
}
static void printIpsWithKey(FFinstance* instance, FFlist* ips)
{
FFLocalIpResult* ip = (FFLocalIpResult*) ffListGet(ips, 0);
if (instance->config.localIpCompactType == FF_LOCALIP_COMPACT_TYPE_MULTILINE)
if (ip->ipv6.length)
{
FF_STRBUF_AUTO_DESTROY key;
ffStrbufInit(&key);
formatKey(instance, ip, &key);
ffPrintLogoAndKey(instance, key.chars, 0, NULL);
if (flag) putchar(' ');
ffStrbufWriteTo(&ip->ipv6, stdout);
flag = true;
}
if (ip->mac.length)
{
if (flag)
printf(" (%s)", ip->mac.chars);
else
ffStrbufWriteTo(&ip->mac, stdout);
}
printIpsOneline(ips);
if (instance->config.localIpCompactType == FF_LOCALIP_COMPACT_TYPE_ONELINE)
printf(" (%s) ", ip->name.chars);
else
putchar('\n');
}
void ffPrintLocalIp(FFinstance* instance)
@@ -94,26 +70,18 @@ void ffPrintLocalIp(FFinstance* instance)
return;
}
ffListSort(&results, instance->config.localIpV6First ? (void*) sortIpsV6First : (void*) sortIpsV4First);
ffListSort(&results, (void*) sortIps);
if (instance->config.localIpCompactType != FF_LOCALIP_COMPACT_TYPE_NONE)
if (instance->config.localIpShowType & FF_LOCALIP_TYPE_COMPACT_BIT)
{
if (instance->config.localIpCompactType == FF_LOCALIP_COMPACT_TYPE_ONELINE)
ffPrintLogoAndKey(instance, FF_LOCALIP_MODULE_NAME, 0, &instance->config.localIP.key);
FF_LIST_AUTO_DESTROY ips;
ffListInit(&ips, sizeof(FFLocalIpResult)); // weak references
ffPrintLogoAndKey(instance, FF_LOCALIP_MODULE_NAME, 0, &instance->config.localIP.key);
FF_LIST_FOR_EACH(FFLocalIpResult, ip, results)
{
if (ips.length > 0 && !ffStrbufEqual(&ip->name, &ip[-1].name))
{
printIpsWithKey(instance, &ips);
ips.length = 0;
}
*(FFLocalIpResult*)ffListAdd(&ips) = *ip;
if ((void*) ip != (void*) results.data)
fputs(" - ", stdout);
printIp(ip);
}
printIpsWithKey(instance, &ips);
}
else
{
@@ -126,18 +94,26 @@ void ffPrintLocalIp(FFinstance* instance)
if(instance->config.localIP.outputFormat.length == 0)
{
ffPrintLogoAndKey(instance, key.chars, 0, NULL);
ffStrbufPutTo(&ip->addr, stdout);
printIp(ip);
putchar('\n');
}
else
{
ffPrintFormatString(instance, key.chars, 0, NULL, &instance->config.localIP.outputFormat, FF_LOCALIP_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->addr},
{FF_FORMAT_ARG_TYPE_STRING, ip->ipv6 ? "IPv6" : "IPv4"}
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv4},
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->ipv6},
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->mac},
{FF_FORMAT_ARG_TYPE_STRBUF, &ip->name},
});
}
ffStrbufDestroy(&ip->name);
ffStrbufDestroy(&ip->addr);
}
}
FF_LIST_FOR_EACH(FFLocalIpResult, ip, results)
{
ffStrbufDestroy(&ip->name);
ffStrbufDestroy(&ip->ipv4);
ffStrbufDestroy(&ip->ipv6);
ffStrbufDestroy(&ip->mac);
}
}
+3 -3
View File
@@ -22,8 +22,8 @@ void ffPrintPlayer(FFinstance* instance)
//If we are on a website, prepend the website name
if(
ffStrbufIgnCaseCompS(&media->busNameShort, "spotify") == 0 ||
ffStrbufIgnCaseCompS(&media->busNameShort, "vlc") == 0
ffStrbufIgnCaseCompS(&media->playerId, "spotify") == 0 ||
ffStrbufIgnCaseCompS(&media->playerId, "vlc") == 0
) {} // do noting, surely not a website, even if the url is set
else if(ffStrbufStartsWithS(&media->url, "https://www."))
ffStrbufAppendS(&playerPretty, media->url.chars + 12);
@@ -66,7 +66,7 @@ void ffPrintPlayer(FFinstance* instance)
ffPrintFormat(instance, FF_PLAYER_MODULE_NAME, 0, &instance->config.player, FF_PLAYER_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &playerPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, &media->player},
{FF_FORMAT_ARG_TYPE_STRBUF, &media->busNameShort},
{FF_FORMAT_ARG_TYPE_STRBUF, &media->playerId},
{FF_FORMAT_ARG_TYPE_STRBUF, &media->url}
});
}
+9 -83
View File
@@ -1,104 +1,30 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "common/parsing.h"
#include "detection/gtk_qt/gtk_qt.h"
#include "detection/displayserver/displayserver.h"
#include "detection/theme/theme.h"
#define FF_THEME_MODULE_NAME "Theme"
#define FF_THEME_NUM_FORMAT_ARGS 7
#define FF_THEME_NUM_FORMAT_ARGS 1
void ffPrintTheme(FFinstance* instance)
{
#if defined(__ANDROID__) || defined(__APPLE__) || defined(_WIN32)
FF_UNUSED(instance);
ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme, "Theme detection is not supported");
return;
#else
const FFDisplayServerResult* wmde = ffConnectDisplayServer(instance);
if(ffStrbufIgnCaseCompS(&wmde->wmProtocolName, FF_WM_PROTOCOL_TTY) == 0)
FF_STRBUF_AUTO_DESTROY theme;
ffStrbufInit(&theme);
const char* error = ffDetectTheme(instance, &theme);
if (error)
{
ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme, "Theme isn't supported in TTY");
ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme, "%s", error);
return;
}
const FFQtResult* plasma = ffDetectQt(instance);
const FFstrbuf* gtk2 = &ffDetectGTK2(instance)->theme;
const FFstrbuf* gtk3 = &ffDetectGTK3(instance)->theme;
const FFstrbuf* gtk4 = &ffDetectGTK4(instance)->theme;
if(plasma->widgetStyle.length == 0 && plasma->colorScheme.length == 0 && gtk2->length == 0 && gtk3->length == 0 && gtk4->length == 0)
{
ffPrintError(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme, "No themes found");
return;
}
FF_STRBUF_AUTO_DESTROY plasmaColorPretty;
ffStrbufInit(&plasmaColorPretty);
if(ffStrbufStartsWithIgnCase(&plasma->colorScheme, &plasma->widgetStyle))
ffStrbufAppendNS(&plasmaColorPretty, plasma->colorScheme.length - plasma->widgetStyle.length, &plasma->colorScheme.chars[plasma->widgetStyle.length]);
else
ffStrbufAppend(&plasmaColorPretty, &plasma->colorScheme);
ffStrbufTrim(&plasmaColorPretty, ' ');
FF_STRBUF_AUTO_DESTROY gtkPretty;
ffStrbufInit(&gtkPretty);
ffParseGTK(&gtkPretty, gtk2, gtk3, gtk4);
if(instance->config.theme.outputFormat.length == 0)
{
ffPrintLogoAndKey(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme.key);
if(plasma->widgetStyle.length > 0)
{
ffStrbufWriteTo(&plasma->widgetStyle, stdout);
if(plasma->colorScheme.length > 0)
{
fputs(" (", stdout);
if(plasmaColorPretty.length > 0)
ffStrbufWriteTo(&plasmaColorPretty, stdout);
else
ffStrbufWriteTo(&plasma->colorScheme, stdout);
putchar(')');
}
}
else if(plasma->colorScheme.length > 0)
{
if(plasmaColorPretty.length > 0)
ffStrbufWriteTo(&plasmaColorPretty, stdout);
else
ffStrbufWriteTo(&plasma->colorScheme, stdout);
}
if(plasma->widgetStyle.length > 0 || plasma->colorScheme.length > 0)
{
fputs(" [QT]", stdout);
if(gtkPretty.length > 0)
fputs(", ", stdout);
}
ffStrbufPutTo(&gtkPretty, stdout);
ffStrbufPutTo(&theme, stdout);
}
else
{
ffPrintFormat(instance, FF_THEME_MODULE_NAME, 0, &instance->config.theme, FF_THEME_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &plasma->widgetStyle},
{FF_FORMAT_ARG_TYPE_STRBUF, &plasma->colorScheme},
{FF_FORMAT_ARG_TYPE_STRBUF, &plasmaColorPretty},
{FF_FORMAT_ARG_TYPE_STRBUF, gtk2},
{FF_FORMAT_ARG_TYPE_STRBUF, gtk3},
{FF_FORMAT_ARG_TYPE_STRBUF, gtk4},
{FF_FORMAT_ARG_TYPE_STRBUF, &gtkPretty}
{FF_FORMAT_ARG_TYPE_STRBUF, &theme}
});
}
#endif
}
+31
View File
@@ -0,0 +1,31 @@
#include "fastfetch.h"
#include "common/printing.h"
#include "detection/wallpaper/wallpaper.h"
#define FF_WALLPAPER_MODULE_NAME "Wallpaper"
#define FF_WALLPAPER_NUM_FORMAT_ARGS 1
void ffPrintWallpaper(FFinstance* instance)
{
FF_STRBUF_AUTO_DESTROY wallpaper;
ffStrbufInit(&wallpaper);
const char* error = ffDetectWallpaper(instance, &wallpaper);
if(error)
{
ffPrintError(instance, FF_WALLPAPER_MODULE_NAME, 0, &instance->config.wallpaper, "%s", error);
return;
}
if(instance->config.wallpaper.outputFormat.length == 0)
{
ffPrintLogoAndKey(instance, FF_WALLPAPER_MODULE_NAME, 0, &instance->config.wallpaper.key);
ffStrbufPutTo(&wallpaper, stdout);
}
else
{
ffPrintFormat(instance, FF_WALLPAPER_MODULE_NAME, 0, &instance->config.wallpaper, FF_WALLPAPER_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &wallpaper}
});
}
}
+1
View File
@@ -1,4 +1,5 @@
#include <stdlib.h>
#include <assert.h>
static inline void ffWrapFree(void* pPtr)
{