aboutsummaryrefslogtreecommitdiff
path: root/linux/home/.config/xob
diff options
context:
space:
mode:
Diffstat (limited to 'linux/home/.config/xob')
-rwxr-xr-xlinux/home/.config/xob/launch.sh10
-rwxr-xr-xlinux/home/.config/xob/manage-brightness16
-rwxr-xr-xlinux/home/.config/xob/manage-microphone56
-rwxr-xr-xlinux/home/.config/xob/manage-volume46
-rw-r--r--linux/home/.config/xob/styles.cfg100
5 files changed, 228 insertions, 0 deletions
diff --git a/linux/home/.config/xob/launch.sh b/linux/home/.config/xob/launch.sh
new file mode 100755
index 0000000..46d4861
--- /dev/null
+++ b/linux/home/.config/xob/launch.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+killall -q xob
+pkill -f manage-volume
+pkill -f manage-brightness
+pkill -f manage-microphone
+
+"$HOME"/.config/xob/manage-volume | xob -s default &
+"$HOME"/.config/xob/manage-brightness | xob -s default &
+"$HOME"/.config/xob/manage-microphone | xob -s default &
diff --git a/linux/home/.config/xob/manage-brightness b/linux/home/.config/xob/manage-brightness
new file mode 100755
index 0000000..496900f
--- /dev/null
+++ b/linux/home/.config/xob/manage-brightness
@@ -0,0 +1,16 @@
+#!/bin/node
+
+const fs = require('fs')
+const { exec } = require("child_process");
+
+let device = "intel_backlight";
+
+brightnessFile = `/sys/class/backlight/${device}/brightness`;
+maxBrightnessFile = `/sys/class/backlight/${device}/max_brightness`;
+
+maxValue = parseInt(fs.readFileSync(maxBrightnessFile, 'utf8'));
+
+fs.watch(brightnessFile, () => {
+ value = parseInt(fs.readFileSync(brightnessFile, 'utf8'));
+ console.log(Math.round(value / maxValue * 100));
+})
diff --git a/linux/home/.config/xob/manage-microphone b/linux/home/.config/xob/manage-microphone
new file mode 100755
index 0000000..3bf5972
--- /dev/null
+++ b/linux/home/.config/xob/manage-microphone
@@ -0,0 +1,56 @@
+#!/usr/bin/env python3
+
+import sys
+
+from pulsectl import Pulse, PulseLoopStop
+
+
+def callback(ev):
+ if ev.index == source_index:
+ raise PulseLoopStop
+
+
+def current_status(source):
+ return round(source.volume.value_flat * 100), source.mute == 1
+
+
+def get_default_source_idx():
+ default_source_name = pulse.server_info().default_source_name
+ try:
+ source_index = next(index for index, source in sources.items()
+ if source.name == default_source_name)
+ return source_index
+ except StopIteration:
+ raise StopIteration("No default source was found.")
+
+
+try:
+ with Pulse() as pulse:
+ sources = {s.index: s for s in pulse.source_list()}
+
+ if len(sys.argv) > 1:
+ # Source index from command line argument if provided
+ source_index = int(sys.argv[1])
+ if source_index not in sources:
+ raise KeyError(
+ f"Source index {source_index} not found in list of sources."
+ )
+ else:
+ # Automatic determination of default source otherwise
+ source_index = get_default_source_idx()
+
+ pulse.event_mask_set('source')
+ pulse.event_callback_set(callback)
+ last_value, last_mute = current_status(sources[source_index])
+
+ while True:
+ pulse.event_listen()
+ sources = {s.index: s for s in pulse.source_list()}
+ value, mute = current_status(sources[source_index])
+ if value != last_value or mute != last_mute:
+ print(str(value) + ('!' if mute else ''))
+ last_value, last_mute = value, mute
+ sys.stdout.flush()
+
+except Exception as e:
+ print(f"ERROR: {e}", file=sys.stderr)
diff --git a/linux/home/.config/xob/manage-volume b/linux/home/.config/xob/manage-volume
new file mode 100755
index 0000000..d05a92f
--- /dev/null
+++ b/linux/home/.config/xob/manage-volume
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+
+from pulsectl import Pulse, PulseLoopStop
+import sys
+
+with Pulse() as pulse:
+ while True:
+ def callback(ev):
+ if ev.index == sink_index: raise PulseLoopStop
+
+ def current_status(sink):
+ return round(sink.volume.value_flat * 100), sink.mute == 1
+
+ def get_default_sink_idx():
+ default_sink_name = pulse.server_info().default_sink_name
+ try:
+ sink_index = next(index for index,sink in sinks.items() if sink.name == default_sink_name)
+ return sink_index
+ except StopIteration: raise StopIteration("No default sink was found.")
+
+ try:
+ sinks = {s.index:s for s in pulse.sink_list()}
+ if len(sys.argv) > 1:
+ # Sink index from command line argument if provided
+ sink_index = int(sys.argv[1])
+ if not sink_index in sinks:
+ raise KeyError(f"Sink index {sink_index} not found in list of sinks.")
+ else:
+ # Automatic determination of default sink otherwise
+ sink_index = get_default_sink_idx()
+
+ pulse.event_mask_set('sink')
+ pulse.event_callback_set(callback)
+ last_value, last_mute = current_status(sinks[sink_index])
+
+ while True:
+ pulse.event_listen()
+ sinks = {s.index:s for s in pulse.sink_list()}
+ value, mute = current_status(sinks[sink_index])
+ if value != last_value or mute != last_mute:
+ print(str(value) + ('!' if mute else ''))
+ last_value, last_mute = value, mute
+ sys.stdout.flush()
+
+ except Exception as e:
+ print(f"ERROR: {e}", file=sys.stderr)
diff --git a/linux/home/.config/xob/styles.cfg b/linux/home/.config/xob/styles.cfg
new file mode 100644
index 0000000..d236ff8
--- /dev/null
+++ b/linux/home/.config/xob/styles.cfg
@@ -0,0 +1,100 @@
+#vol = {
+# x = {relative = 1 ;offset = 88}
+# y = {relative = 0 ;offset = 32}
+# length = {relative = 0; offset = 0;};
+# padding = 0;
+# border = 0;
+# outline = 0;
+# thickness = 20;
+# orientation = "vertical"
+# color = {
+# normal = {
+# fg = "#ffffff";
+# bg = "#000000";
+# border = "#ffffff";
+# };
+# alt = {
+# fg = "#dc322f";
+# bg = "#000000";
+# border = "#dc322f";
+# };
+# overflow = {
+# fg = "#555555";
+# bg = "#000000";
+# border = "#555555";
+# };
+# altoverflow = {
+# fg = "#550000";
+# bg = "#000000";
+# border = "#550000";
+# };
+# };
+#};
+#
+#brightness = {
+# x = {relative = 1 ;offset = 88}
+# y = {relative = 0 ;offset = 88}
+# length = {relative = 0; offset = 0;};
+# padding = 0;
+# border = 0;
+# outline = 0;
+# thickness = 20;
+# orientation = "vertical"
+# color = {
+# normal = {
+# fg = "#ffffff";
+# bg = "#000000";
+# border = "#ffffff";
+# };
+# alt = {
+# fg = "#dc322f";
+# bg = "#000000";
+# border = "#dc322f";
+# };
+# overflow = {
+# fg = "#555555";
+# bg = "#000000";
+# border = "#555555";
+# };
+# altoverflow = {
+# fg = "#550000";
+# bg = "#000000";
+# border = "#550000";
+# };
+# };
+#};
+default = {
+ x = {relative = 1; offset = -48;};
+ y = {relative = 0.5; offset = 0;};
+ length = {relative = 0.3; offset = 0;};
+ thickness = 24;
+ outline = 3;
+ border = 4;
+ padding = 3;
+ orientation = "vertical";
+
+ overflow = "proportional";
+
+ color = {
+ normal = {
+ fg = "#ffffff";
+ bg = "#00000090";
+ border = "#ffffff";
+ };
+ alt = {
+ fg = "#555555";
+ bg = "#00000090";
+ border = "#555555";
+ };
+ overflow = {
+ fg = "#ff0000";
+ bg = "#00000090";
+ border = "#ff0000";
+ };
+ altoverflow = {
+ fg = "#550000";
+ bg = "#00000090";
+ border = "#550000";
+ };
+ };
+};