ports/sysutils/xfce4-power-manager/files/patch-src_xfpm-backlight-helper.c
Guido Falsi b2f2269daf Welcome XFCE 4.16 to the FreeBSD ports tree!
Upstream announce: https://xfce.org/about/news/?post=1608595200

This XFCE release dropped support for GTK2 plugins and also dropped
GTK2 from all components.

WARNING: please check UPDATING before upgrading your packages. In
case of problems also read the libexo pkg-message.

Due to this some panel plugins and libraries will be removed since
they cannot compile anymore:

- print/xfce4-print
- x11/xfce4-quicklauncher-plugin
- x11/xfce4-wmdock-plugin
- x11-toolkits/libxfce4gui

These further components also fail to build or work and are being
marked BROKEN, deprecated and marked for removal:

- science/xfce4-equake-plugin
- x11/xfce4-embed-plugin
- deskutils/orage
- deskutils/xfce4-volumed [1]

deskutils/xfce4-notes-plugin will be also marked BROKEN, but there
is active development in it's upstream repository and a fixed release
is expected soon.

deskutils/xfce4-generic-slider will also be marked broken, since
it fails to compile. [2]

Thanks also to riggs, Olivier Duchateau <duchateau.olivier@gmail.com>
and the people in Approved and Reviewed lines below for help and
contributions.

Reviewed by:		woodsb02
Approved by:		sergey.dyatko@gmail.com (maintainer) [1],
			ehaupt [2]
Differential Revision:	https://reviews.freebsd.org/D27846
2021-01-02 16:36:33 +00:00

42 lines
1.2 KiB
C

--- src/xfpm-backlight-helper.c.orig 2020-01-26 23:15:39 UTC
+++ src/xfpm-backlight-helper.c
@@ -49,6 +49,8 @@
#define EXIT_CODE_INVALID_USER 4
#define EXIT_CODE_NO_BRIGHTNESS_SWITCH 5
+#define MAX_DEVICE_NUM 8
+
#if !defined(BACKEND_TYPE_FREEBSD)
#define BACKLIGHT_SYSFS_LOCATION "/sys/class/backlight"
#define BRIGHTNESS_SWITCH_LOCATION "/sys/module/video/parameters/brightness_switch_enabled"
@@ -204,19 +206,23 @@ 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);
}
/*