summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordianshi <dianshi@main.lv>2020-07-18 18:28:08 +0100
committerdianshi <dianshi@main.lv>2020-07-18 18:28:08 +0100
commit167af45ab98240f9930424dec6784ccb875f7b04 (patch)
tree864ee3cd0d58ac8cdc45bdf14a8e1484a68e38d8
parent0aeabc5237e0046f6c9c186a87f9e00484f9643a (diff)
downloadosystem-167af45ab98240f9930424dec6784ccb875f7b04.tar.gz
osystem-167af45ab98240f9930424dec6784ccb875f7b04.zip
obacklight initial commit. to be set backlight brightness
-rw-r--r--obacklight/Makefile8
-rw-r--r--obacklight/obacklight.ml51
2 files changed, 59 insertions, 0 deletions
diff --git a/obacklight/Makefile b/obacklight/Makefile
new file mode 100644
index 0000000..1e51d9a
--- /dev/null
+++ b/obacklight/Makefile
@@ -0,0 +1,8 @@
+make:
+ ocamlc unix.cma str.cma obacklight.ml -o obacklight
+
+static:
+ ocamlopt unix.cmxa -ccopt -static obacklight.ml -o obacklight
+
+clean:
+ rm -f *.cmi *.cmx *.o *.cmo \ No newline at end of file
diff --git a/obacklight/obacklight.ml b/obacklight/obacklight.ml
new file mode 100644
index 0000000..6360574
--- /dev/null
+++ b/obacklight/obacklight.ml
@@ -0,0 +1,51 @@
+open Arg
+
+(*
+ Sett default path to sysfs
+ *)
+let default_sysfs_dir = ref "/sys"
+let default_backlight_path = ref (String.concat "" (List.append [!default_sysfs_dir] ["/class/backlight/intel_backlight"]))
+let default_backlight_maxbrightness_path = ref (String.concat "" (List.append [!default_backlight_path] ["/max_brightness"]))
+let default_backlight_brightness_path = ref (String.concat "" (List.append [!default_backlight_path] ["/brightness"]))
+
+let set_backlight_path () = default_backlight_path := (String.concat "" (List.append [!default_sysfs_dir] ["/class/backlight/intel_backlight"]))
+let set_backlight_maxbrightness_path () = default_backlight_maxbrightness_path := (String.concat "" (List.append [!default_backlight_path] ["/max_brightness"]))
+let set_backlight_brightness_path () = default_backlight_brightness_path := (String.concat "" (List.append [!default_backlight_path] ["/brightness"]))
+
+
+let print_debug () =
+begin
+ let _ = Printf.printf "sysfs: %s\n" !default_sysfs_dir in
+ let _ = Printf.printf "backlight: %s\n" !default_backlight_path in
+ let _ = Printf.printf "max_brightness: %s\n" !default_backlight_maxbrightness_path in
+ Printf.printf "brightness: %s\n" !default_backlight_brightness_path
+end
+
+let set_sysfs_dir dir =
+begin
+ (Printf.printf "Setting value of sysfs to %s\n" dir);
+ default_sysfs_dir := dir;
+ set_backlight_path ();
+ set_backlight_maxbrightness_path ();
+ set_backlight_brightness_path ()
+end
+
+let main =
+begin
+ (*
+ let speclist =
+ [
+ ("-s",Arg.String (set_sysfs_dir),"Sysfs directory")
+ ] in
+ let usage_msg = "set backlight value" in
+ let _ = Arg.parse speclist print_endline usage_msg in
+ (* If there is not argument print value of default path *)
+ (* If there is 1 argument set value to brigthness *)
+ *)
+ print_debug ();
+end
+
+let () = main;;
+
+
+