From 38508b06dc35760b48d1aafa1c1a6026f50002c5 Mon Sep 17 00:00:00 2001 From: Marcel von Maltitz Date: Fri, 19 Jul 2019 18:46:28 +0200 Subject: Make ram-widget compatible for non-english OS The output of the free command is grep'ed while assuming english column names. This grep fails when given non-english localization. Setting the LANGUAGE variable inside the bash invocation solves this problem. --- ram-widget/ram-widget.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ram-widget/ram-widget.lua b/ram-widget/ram-widget.lua index 3072068..a783b3c 100644 --- a/ram-widget/ram-widget.lua +++ b/ram-widget/ram-widget.lua @@ -42,7 +42,7 @@ local function getPercentage(value) return math.floor(value / (total+total_swap) * 100 + 0.5) .. '%' end -watch('bash -c "free | grep -z Mem.*Swap.*"', 1, +watch('bash -c "LANGUAGE=en_US.UTF-8 free | grep -z Mem.*Swap.*"', 1, function(widget, stdout, stderr, exitreason, exitcode) total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap = stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*Swap:%s*(%d+)%s*(%d+)%s*(%d+)') -- cgit v1.2.3 From daf66a1a16a091717de2baf5b8d24c098fc7a6e9 Mon Sep 17 00:00:00 2001 From: ticktronaut Date: Thu, 1 Aug 2019 10:35:16 +0200 Subject: Fixed buggy spawning of os.time(). --- battery-widget/battery.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/battery-widget/battery.lua b/battery-widget/battery.lua index 6d9f086..aa3623d 100644 --- a/battery-widget/battery.lua +++ b/battery-widget/battery.lua @@ -109,7 +109,7 @@ watch("acpi -i", 10, batteryType = "battery-empty%s-symbolic" if status ~= 'Charging' and os.difftime(os.time(), last_battery_check) > 300 then -- if 5 minutes have elapsed since the last warning - last_battery_check = time() + last_battery_check = os.time() show_battery_warning() end -- cgit v1.2.3 From cd6776c8b0e23ef7cb34a9979012c2a6edb8b295 Mon Sep 17 00:00:00 2001 From: blix4 Date: Mon, 26 Aug 2019 22:28:43 -0700 Subject: add option to show temperature in both units Separate options for the widget itself, and in the popup. Also note that this changes the precision slightly: * on the widget itself: now uses string formatting to round, instead of removing the decimal * on the popup: rounds to 1 decimal place in popup (was showing 2 decimal places before) --- secrets.lua | 13 ++++++++++++- weather-widget/weather.lua | 41 +++++++++++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/secrets.lua b/secrets.lua index 19f35b8..ab87b9f 100644 --- a/secrets.lua +++ b/secrets.lua @@ -5,6 +5,15 @@ -- @copyright 2019 Pavel Makhov -------------------------------------------- +local function getenv_bool(var_name, default_val) + val = os.getenv(var_name) + if val ~= nil then + return val:lower() == 'true' + else + return default_val + end +end + local secrets = { -- Yandex.Translate API key - https://tech.yandex.com/translate/ translate_widget_api_key = os.getenv('AWW_TRANSLATE_API_KEY') or 'API_KEY', @@ -12,7 +21,9 @@ local secrets = { -- OpenWeatherMap API key - https://openweathermap.org/appid weather_widget_api_key = os.getenv('AWW_WEATHER_API_KEY') or 'API_KEY', weather_widget_city = os.getenv('AWW_WEATHER_CITY') or 'Montreal,ca', - weather_widget_units = os.getenv('AWW_WEATHER_UNITS') or 'metric' -- for celsius, or 'imperial' for fahrenheit + weather_widget_units = os.getenv('AWW_WEATHER_UNITS') or 'metric', -- for celsius, or 'imperial' for fahrenheit + weather_both_temp_units_widget = getenv_bool('AWW_WEATHER_BOTH_UNITS_WIDGET', false), -- on widget, if true shows "22 C (72 F)", instead of only "22 C" + weather_both_temp_units_popup = getenv_bool('AWW_WEATHER_BOTH_UNITS_POPUP', true) -- in the popup, if true shows "22.3 C (72.2 F)" instead of only "22.3 C" } return secrets diff --git a/weather-widget/weather.lua b/weather-widget/weather.lua index 2d80947..d6693cf 100644 --- a/weather-widget/weather.lua +++ b/weather-widget/weather.lua @@ -98,9 +98,39 @@ local function to_direction(degrees) return directions[math.floor((degrees % 360) / 22.5) + 1] end +-- Convert degrees Celsius to Fahrenheit +local function celsius_to_fahrenheit(c) + return c*9/5+32 +end + +-- Convert degrees Fahrenheit to Celsius +local function fahrenheit_to_celsius(f) + return (f-32)*5/9 +end + local weather_timer = gears.timer({ timeout = 60 }) local resp +local function gen_temperature_str(temp, fmt_str, show_other_units) + local temp_str = string.format(fmt_str, temp) + local s = temp_str .. '°' .. (secrets.weather_widget_units == 'metric' and 'C' or 'F') + + if (show_other_units) then + local temp_conv, units_conv + if (secrets.weather_widget_units == 'metric') then + temp_conv = celsius_to_fahrenheit(temp) + units_conv = 'F' + else + temp_conv = fahrenheit_to_celsius(temp) + units_conv = 'C' + end + + local temp_conv_str = string.format(fmt_str, temp_conv) + s = s .. ' ' .. '('.. temp_conv_str .. '°' .. units_conv .. ')' + end + return s +end + weather_timer:connect_signal("timeout", function () local resp_json = {} local res, status = http.request{ @@ -132,9 +162,8 @@ weather_timer:connect_signal("timeout", function () elseif (resp_json ~= nil and resp_json ~= '') then resp = json.decode(resp_json) icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon] - temp_widget:set_text(string.gsub(resp.main.temp, "%.%d+", "") - .. '°' - .. (secrets.weather_widget_units == 'metric' and 'C' or 'F')) + temp_widget:set_text(gen_temperature_str(resp.main.temp, '%.0f', + secrets.weather_both_temp_units_widget)) end end) weather_timer:start() @@ -149,13 +178,13 @@ weather_widget:connect_signal("mouse::enter", function() text = '' .. resp.weather[1].main .. ' (' .. resp.weather[1].description .. ')
' .. 'Humidity: ' .. resp.main.humidity .. '%
' .. - 'Temperature: ' .. resp.main.temp .. '°' - .. (secrets.weather_widget_units == 'metric' and 'C' or 'F') .. '
' .. + 'Temperature: ' .. gen_temperature_str(resp.main.temp, '%.1f', + secrets.weather_both_temp_units_popup) .. '
' .. 'Pressure: ' .. resp.main.pressure .. 'hPa
' .. 'Clouds: ' .. resp.clouds.all .. '%
' .. 'Wind: ' .. resp.wind.speed .. 'm/s (' .. to_direction(resp.wind.deg) .. ')', timeout = 5, hover_timeout = 10, - width = 200 + width = (secrets.weather_both_temp_units_popup == true and 210 or 200) } end) -- cgit v1.2.3 From e9b4b6323f975a12aa41a4a0d4e3c93c423ab0d5 Mon Sep 17 00:00:00 2001 From: blix4 Date: Tue, 27 Aug 2019 00:20:08 -0700 Subject: volume widget support amixer with no device specified This works on my setup without having pulseaudio installed. --- secrets.lua | 3 +++ volume-widget/README.md | 25 +++++++++++++++++++++++++ volume-widget/volume.lua | 19 ++++++++++++++----- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/secrets.lua b/secrets.lua index 19f35b8..7d0f773 100644 --- a/secrets.lua +++ b/secrets.lua @@ -6,6 +6,9 @@ -------------------------------------------- local secrets = { + -- See volume-widget/README.md + volume_audio_controller = os.getenv('AWW_VOLUME_CONTROLLER') or 'pulse', -- 'pulse' or 'alsa_only' + -- Yandex.Translate API key - https://tech.yandex.com/translate/ translate_widget_api_key = os.getenv('AWW_TRANSLATE_API_KEY') or 'API_KEY', diff --git a/volume-widget/README.md b/volume-widget/README.md index 118abc6..494be24 100644 --- a/volume-widget/README.md +++ b/volume-widget/README.md @@ -31,6 +31,31 @@ s.mytasklist, -- Middle widget sudo sed -i 's/bebebe/ed4737/g' ./audio-volume-muted-symbolic_red.svg ``` +### Pulse or ALSA only + +Try running this command: + +```amixer -D pulse sget Master``` + +If that prints something like this, then the default setting of 'pulse' is probably fine: +``` +Simple mixer control 'Master',0 + Capabilities: pvolume pvolume-joined pswitch pswitch-joined + Playback channels: Mono + Limits: Playback 0 - 64 + Mono: Playback 64 [100%] [0.00dB] [on] + +``` + +If it prints something like this: +``` +$ amixer -D pulse sget Master +ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused + +amixer: Mixer attach pulse error: Connection refused +``` +then try setting the environment variable `AWW_VOLUME_CONTROLLER` to `alsa_only`. + ## Control volume To mute/unmute click on the widget. To increase/decrease volume scroll up or down when mouse cursor is over the widget. diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua index 8124bcf..04f1c26 100644 --- a/volume-widget/volume.lua +++ b/volume-widget/volume.lua @@ -13,12 +13,21 @@ local wibox = require("wibox") local watch = require("awful.widget.watch") local spawn = require("awful.spawn") +local secrets = require("awesome-wm-widgets.secrets") + local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" -local GET_VOLUME_CMD = 'amixer -D pulse sget Master' -local INC_VOLUME_CMD = 'amixer -D pulse sset Master 5%+' -local DEC_VOLUME_CMD = 'amixer -D pulse sset Master 5%-' -local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle' +if secrets.volume_audio_controller == 'pulse' then + device_arg = '-D pulse' +else + device_arg = '' +end + +local GET_VOLUME_CMD = 'amixer ' .. device_arg .. ' sget Master' +local INC_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master 5%+' +local DEC_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master 5%-' +local TOG_VOLUME_CMD = 'amixer ' .. device_arg .. ' sset Master toggle' + local volume_widget = wibox.widget { { @@ -64,4 +73,4 @@ end) watch(GET_VOLUME_CMD, 1, update_graphic, volume_widget) -return volume_widget \ No newline at end of file +return volume_widget -- cgit v1.2.3 From 05e9a909bd29bc7e9a50ba6e5ff6fdecd4503f2a Mon Sep 17 00:00:00 2001 From: blix4 Date: Tue, 27 Aug 2019 00:30:32 -0700 Subject: clean up a global variable --- volume-widget/volume.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua index 04f1c26..fe7ff2c 100644 --- a/volume-widget/volume.lua +++ b/volume-widget/volume.lua @@ -17,6 +17,7 @@ local secrets = require("awesome-wm-widgets.secrets") local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" +local device_arg if secrets.volume_audio_controller == 'pulse' then device_arg = '-D pulse' else -- cgit v1.2.3 From 0232c179cbbd946b6d997afbf67fddb866d5d0fd Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sun, 1 Sep 2019 22:08:02 -0400 Subject: Update README.MD --- translate-widget/README.MD | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/translate-widget/README.MD b/translate-widget/README.MD index dcc603f..9c87ed0 100644 --- a/translate-widget/README.MD +++ b/translate-widget/README.MD @@ -13,7 +13,7 @@ This widget allows quickly translate words or phrases without opening a browser ## Installation 1. Clone repo under **~/.config/awesome/** -1. Get an [API key](https://translate.yandex.com/developers/keys) and paste it in **translate.lua** as value of the `API_KEY` variable +1. Get an [API key](https://translate.yandex.com/developers/keys) and paste it in **secrets.lua** as value of the ` translate_widget_api_key` variable 1. Require widget in **rc.lua**: ```lua @@ -23,6 +23,8 @@ This widget allows quickly translate words or phrases without opening a browser 1. Add a shortcut to run translate prompt: ```lua - awful.key({ modkey }, "c", function() translate.show_translate_prompt() end, { description = "run translate prompt", group = "launcher" }), + awful.key({ modkey }, "c", + function() translate.show_translate_prompt() end, + { description = "run translate prompt", group = "launcher" }), ``` -- cgit v1.2.3