aboutsummaryrefslogtreecommitdiff
path: root/src/flashlight.c
diff options
context:
space:
mode:
authorJan Sprinz (NeoTheThird) <neo@neothethird.de>2018-03-25 22:18:55 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-03-25 22:21:10 +0200
commit868fa1688edaaa48696f59d3fafe44dc9afcb940 (patch)
tree76c5bde2510ba80548dad2f2ca6e82dda3dd2095 /src/flashlight.c
parentcf33215b5030fc9d6708edbfd27332910d3322c8 (diff)
downloadayatana-indicator-power-868fa1688edaaa48696f59d3fafe44dc9afcb940.tar.gz
ayatana-indicator-power-868fa1688edaaa48696f59d3fafe44dc9afcb940.tar.bz2
ayatana-indicator-power-868fa1688edaaa48696f59d3fafe44dc9afcb940.zip
Added warning to avoid overheating of the LED.
Ported from UBports power indicator: commit ef020b31be15f1126d3e5ea5ec399179aad586b8 Author: Jan Sprinz (NeoTheThird) <neo@neothethird.de> Date: Sat Sep 16 16:02:50 2017 +0200 Forgot semicolon *blush* commit c8be2d9a142e17bdfa86ee68e23a18ba0680c244 Author: Jan Sprinz (NeoTheThird) <neo@neothethird.de> Date: Sat Sep 16 15:53:29 2017 +0200 Change var name commit 3d6a37503bafcbf397220dcfac5624a686f2f900 Author: Jan Sprinz (NeoTheThird) <neo@neothethird.de> Date: Sat Sep 16 14:24:05 2017 +0200 Added warning to avoid overheating of the LED Ported-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Diffstat (limited to 'src/flashlight.c')
-rw-r--r--src/flashlight.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/flashlight.c b/src/flashlight.c
index 3c5e8b1..63553e5 100644
--- a/src/flashlight.c
+++ b/src/flashlight.c
@@ -31,6 +31,7 @@ const size_t qcom_sysfs_size = 2;
const char* const qcom_sysfs[] = {"/sys/class/leds/torch-light/brightness", "/sys/class/leds/led:flash_torch/brightness"};
char* flash_sysfs_path = NULL;
+gboolean activated = 0;
int
set_sysfs_path()
@@ -44,29 +45,34 @@ set_sysfs_path()
return 0;
}
+gboolean
+flashlight_activated()
+{
+ return activated;
+}
+
void
toggle_flashlight_action(GAction *action,
GVariant *parameter G_GNUC_UNUSED,
gpointer data G_GNUC_UNUSED)
{
GVariant *state;
- gboolean b;
FILE* fd;
if (!set_sysfs_path())
return;
state = g_action_get_state(action);
- b = g_variant_get_boolean(state);
+ activated = g_variant_get_boolean(state);
g_variant_unref(state);
fd = fopen(flash_sysfs_path, "w");
if (fd != NULL){
- if (b)
+ if (activated)
fprintf(fd, QCOM_DISABLE);
else
fprintf(fd, QCOM_ENABLE);
fclose(fd);
- g_action_change_state(action, g_variant_new_boolean(!b));
+ g_action_change_state(action, g_variant_new_boolean(!activated));
}
}