aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2025-03-12 10:47:07 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2025-03-12 10:47:07 +0100
commitde66ea72bb4c819815183202c945c727748d8f1a (patch)
treedfc47c99875f47615bacdf035e014ef2fb7166b6
parent0e19a6c6cc9ae3078d8bb683b4fdc97cc01ddab4 (diff)
parentaefad6d79104a14ef06b303f92feda226ee9b9ba (diff)
downloadayatana-indicator-power-de66ea72bb4c819815183202c945c727748d8f1a.tar.gz
ayatana-indicator-power-de66ea72bb4c819815183202c945c727748d8f1a.tar.bz2
ayatana-indicator-power-de66ea72bb4c819815183202c945c727748d8f1a.zip
Merge branch 'FakeShell-main'
Attributes GH PR #95: https://github.com/AyatanaIndicators/ayatana-indicator-power/pull/95
-rw-r--r--src/deviceinfo-flashlight.c12
-rw-r--r--src/flashlight.c20
2 files changed, 32 insertions, 0 deletions
diff --git a/src/deviceinfo-flashlight.c b/src/deviceinfo-flashlight.c
index 1bbf14d..91e9f02 100644
--- a/src/deviceinfo-flashlight.c
+++ b/src/deviceinfo-flashlight.c
@@ -30,3 +30,15 @@ char* flashlight_switch_path()
struct DeviceInfo* di = deviceinfo_new();
return deviceinfo_get(di, "FlashlightSwitchPath", "");
}
+
+char* flashlight_simple_enable_value()
+{
+ struct DeviceInfo* di = deviceinfo_new();
+ return deviceinfo_get(di, "FlashlightSimpleEnableValue", "");
+}
+
+char* flashlight_simple_disable_value()
+{
+ struct DeviceInfo* di = deviceinfo_new();
+ return deviceinfo_get(di, "FlashlightSimpleDisableValue", "");
+}
diff --git a/src/flashlight.c b/src/flashlight.c
index 88e93fd..337c01c 100644
--- a/src/flashlight.c
+++ b/src/flashlight.c
@@ -34,6 +34,8 @@
#ifdef ENABLE_LIBDEVICEINFO
extern char* flashlight_path();
extern char* flashlight_switch_path();
+extern char* flashlight_simple_enable_value();
+extern char* flashlight_simple_disable_value();
#endif
const size_t qcom_sysfs_size = 7;
@@ -141,7 +143,25 @@ toggle_flashlight_action_simple()
fd = fopen(flash_sysfs_path, "w");
if (fd != NULL) {
+# ifdef ENABLE_LIBDEVICEINFO
+ char* enable_value = flashlight_simple_enable_value();
+ char* disable_value = flashlight_simple_disable_value();
+
+ const char* value_to_write;
+ if (activated)
+ value_to_write = (strcmp(disable_value, "") != 0) ? disable_value : SIMPLE_DISABLE;
+ else
+ value_to_write = (strcmp(enable_value, "") != 0) ? enable_value : SIMPLE_ENABLE;
+
+ fprintf(fd, "%s", value_to_write);
+
+ if (enable_value)
+ free(enable_value);
+ if (disable_value)
+ free(disable_value);
+# else
fprintf(fd, activated ? SIMPLE_DISABLE : SIMPLE_ENABLE);
+# endif
fclose(fd);
return 1;
}