ports/sysutils/xfce4-power-manager/files/patch-src_xfpm-backlight-helper.c
Guido Falsi 939e8ca9ba Welcome XFCE 4.20 to the FreeBSD ports tree!
Announcement: https://xfce.org/about/news/?post=1734220800

This release has experimental Wayland support, but not all components
have been ported, YMMV. From upstream announcement:

Important Notice: Please be aware that the Wayland support in Xfce
4.20 is experimental. It is recommended for advanced users only,
as you may encounter bugs and experience incomplete functionality.
Proceed with caution!

Highlight of this commit:

- Adding new port x11/libxfce4windowing
- Changing some WWW links to XFCE project gitlab
- Cleaned up Makefiles
- Remove unneeded intltool dependencies
- Added WAYLAND option where applicable, enabled by default

Many thanks to Olivier Duchateau <duchateau.olivier@gmail.com> who
provided a set of patches I started work from.

PR:		283345
2024-12-21 21:39:17 +01:00

43 lines
1.2 KiB
C

--- src/xfpm-backlight-helper.c.orig 2024-11-21 06:26:21 UTC
+++ src/xfpm-backlight-helper.c
@@ -51,6 +51,8 @@
#define EXIT_CODE_INVALID_USER 4
#define EXIT_CODE_NO_BRIGHTNESS_SWITCH 5
+#define MAX_DEVICE_NUM 8
+
#ifndef BACKEND_TYPE_FREEBSD
#define BACKLIGHT_SYSFS_LOCATION "/sys/class/backlight"
#define BRIGHTNESS_SWITCH_LOCATION "/sys/module/video/parameters/brightness_switch_enabled"
@@ -211,20 +213,24 @@ backlight_helper_get_device (void)
/* devices in priority order */
gchar *types[] = { "lcd", "crt", "out", "ext", "tv", NULL };
gchar *device = NULL;
- gint i;
+ gint i, j;
- device = (gchar *) g_malloc (sizeof (gchar));
+ device = (gchar *) g_malloc (sizeof (gchar) * 8);
for (i = 0; types[i] != NULL; i++)
{
- g_snprintf (device, (gulong) strlen (types[i]), "%s0", types[i]);
+ for (j = 0; j < MAX_DEVICE_NUM; j++) {
+ g_snprintf (device, 8, "%s%i", types[i], j);
- /* stop, when first device is found */
- if (acpi_video_is_enabled (device))
- break;
+ /* stop, when first device is found */
+ if (acpi_video_is_enabled (device))
+ return (device);
+ }
}
- return device;
+ g_free (device);
+
+ return (NULL);
}
/*