diff options
Diffstat (limited to '.config/awesome/services/common.lua')
-rw-r--r-- | .config/awesome/services/common.lua | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/.config/awesome/services/common.lua b/.config/awesome/services/common.lua index ad1f998..9657c8a 100644 --- a/.config/awesome/services/common.lua +++ b/.config/awesome/services/common.lua @@ -1,12 +1,10 @@ local gfs = require "gears.filesystem" local gtimer = require "gears.timer" local phosphor = require "assets.phosphor" +local qcolor = require "quarrel.color" local qjson = require "quarrel.json" local qmath = require "quarrel.math" local qnative = require "quarrel.native" -local qstore = require "quarrel.store" -local qvars = require "quarrel.vars" -local UPower = require("lgi").UPowerGlib --- Register a service ---@param name string @@ -39,9 +37,9 @@ if not gfs.file_readable "/tmp/wp_audio_status" then assert(io.open("/tmp/wp_audio_status", "w")):write("{}"):close() end -qstore.audio_file = qnative.util.open_file "/tmp/wp_audio_status" -qstore.brightness_file = qnative.util.open_file "/sys/class/backlight/amdgpu_bl1/actual_brightness" -qstore.wifi_file = qnative.util.open_file "/proc/net/wireless" +local audio_file = qnative.util.open_file "/tmp/wp_audio_status" +-- qstore.brightness_file = qnative.util.open_file "/sys/class/backlight/amdgpu_bl1/actual_brightness" +local wifi_file = qnative.util.open_file "/proc/net/wireless" -- follows the format `service = { provider, icon_provider }` ---@class Service @@ -53,7 +51,7 @@ local services = { audio = { -- volume, muted function() - local audio_status = qjson.decode(read(qstore.audio_file)) + local audio_status = qjson.decode(read(audio_file)) local default_sink = audio_status["G435 Wireless Gaming Headset Analog Stereo"] if not default_sink then @@ -64,7 +62,7 @@ local services = { end, function(volume, muted) if muted or not volume then - return phosphor.speaker_simple_x_fill, qvars.colors.red + return phosphor.speaker_simple_x_fill, qcolor.palette.red() end local icon_data = qmath.step_value(volume, { @@ -75,32 +73,32 @@ local services = { { 100 }, }) - return phosphor["speaker_simple_" .. icon_data .. "_fill"], qvars.colors.fg - end, - }, - brightness = { - -- brightness - function() - return read(qstore.brightness_file, "n") - end, - function(brightness) - local icon_data = qmath.step_value(brightness, { - { 0, "cloud_moon" }, - { 51, "moon" }, - { 102, "sun_horizon" }, - { 153, "sun_dim" }, - { 204, "sun" }, - { 255 }, - }) - - return phosphor[icon_data .. "_fill"], qvars.colors.fg + return phosphor["speaker_simple_" .. icon_data .. "_fill"], qcolor.palette.fg() end, }, + -- brightness = { + -- -- brightness + -- function() + -- return read(qstore.brightness_file, "n") + -- end, + -- function(brightness) + -- local icon_data = qmath.step_value(brightness, { + -- { 0, "cloud_moon" }, + -- { 51, "moon" }, + -- { 102, "sun_horizon" }, + -- { 153, "sun_dim" }, + -- { 204, "sun" }, + -- { 255 }, + -- }) + -- + -- return phosphor[icon_data .. "_fill"], qcolor.palette.fg() + -- end, + -- }, wifi = { -- essid, strength, connected function() - local lines = qstore.wifi_file:lines() - qstore.wifi_file:rewind() + local lines = wifi_file:lines() + wifi_file:rewind() if not lines[3] then return nil, 0, false @@ -112,7 +110,7 @@ local services = { end, function(_, strength, connected) if not connected then - return phosphor.wifi_x_fill, qvars.colors.red + return phosphor.wifi_x_fill, qcolor.palette.red() end local icon_data = qmath.step_value(strength, { @@ -123,7 +121,7 @@ local services = { { 100 }, }) - return phosphor["wifi_" .. icon_data[1] .. "_fill"], qvars.colors[icon_data[2]] + return phosphor["wifi_" .. icon_data[1] .. "_fill"], qcolor.palette[icon_data[2]]() end, }, } |