fix #10 and #13. Various other fixes and small changes

This commit is contained in:
Kievits Rene
2022-05-25 11:27:03 +02:00
parent b5f513a344
commit ff202de163
28 changed files with 1664 additions and 1280 deletions

View File

@@ -1,7 +1,6 @@
------------------------------
-- This is the audio widget --
------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("src.theme.colors")
@@ -60,26 +59,27 @@ return function(s)
awful.spawn.easy_async_with_shell(
"./.config/awesome/src/scripts/vol.sh volume",
function(stdout)
local icon = icondir .. "volume"
stdout = stdout:gsub("%%", "")
local volume = tonumber(stdout) or 0
audio_widget.container.audio_layout.spacing = dpi(5)
audio_widget.container.audio_layout.label.visible = true
if volume < 1 then
icon = icon .. "-mute"
audio_widget.container.audio_layout.spacing = dpi(0)
audio_widget.container.audio_layout.label.visible = false
elseif volume >= 1 and volume < 34 then
icon = icon .. "-low"
elseif volume >= 34 and volume < 67 then
icon = icon .. "-medium"
elseif volume >= 67 then
icon = icon .. "-high"
local icon = icondir .. "volume"
stdout = stdout:gsub("%%", "")
local volume = tonumber(stdout) or 0
audio_widget.container.audio_layout.spacing = dpi(5)
audio_widget.container.audio_layout.label.visible = true
if volume < 1 then
icon = icon .. "-mute"
audio_widget.container.audio_layout.spacing = dpi(0)
audio_widget.container.audio_layout.label.visible = false
elseif volume >= 1 and volume < 34 then
icon = icon .. "-low"
elseif volume >= 34 and volume < 67 then
icon = icon .. "-medium"
elseif volume >= 67 then
icon = icon .. "-high"
end
audio_widget.container.audio_layout.label:set_text(volume .. "%")
audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(
gears.color.recolor_image(icon .. ".svg", color["Grey900"]))
awesome.emit_signal("get::volume", volume)
end
audio_widget.container.audio_layout.label:set_text(volume .. "%")
audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icon .. ".svg", color["Grey900"]))
awesome.emit_signal("get::volume", volume)
end
)
end
@@ -87,30 +87,32 @@ return function(s)
awful.spawn.easy_async_with_shell(
"./.config/awesome/src/scripts/vol.sh mute",
function(stdout)
if stdout:match("yes") then
audio_widget.container.audio_layout.label.visible = false
audio_widget.container:set_right(0)
audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. "volume-mute" .. ".svg", color["Grey900"]))
awesome.emit_signal("get::volume_mute", true)
else
audio_widget.container:set_right(10)
awesome.emit_signal("get::volume_mute", false)
get_volume()
if stdout:match("yes") then
audio_widget.container.audio_layout.label.visible = false
audio_widget.container:set_right(0)
audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(
gears.color.recolor_image(icondir .. "volume-mute" .. ".svg", color["Grey900"]))
awesome.emit_signal("get::volume_mute", true)
else
audio_widget.container:set_right(10)
awesome.emit_signal("get::volume_mute", false)
get_volume()
end
end
end
)
end
-- Signals
Hover_signal(audio_widget, color["Yellow200"])
Hover_signal(audio_widget, color["Yellow200"], color["Grey900"])
audio_widget:connect_signal(
"button::press",
function()
awesome.emit_signal("module::slider:update")
awesome.emit_signal("widget::volume_osd:rerun")
awesome.emit_signal("volume_controller::toggle", s)
end
awesome.emit_signal("module::slider:update")
awesome.emit_signal("widget::volume_osd:rerun")
awesome.emit_signal("volume_controller::toggle", s)
awesome.emit_signal("volume_controller::toggle:keygrabber")
end
)
gears.timer {

View File

@@ -1,7 +1,6 @@
--------------------------------
-- This is the battery widget --
--------------------------------
-- Awesome Libs
local awful = require("awful")
local color = require("src.theme.colors")
@@ -71,23 +70,23 @@ return function()
awful.spawn.easy_async_with_shell(
[[ upower -i $(upower -e | grep BAT) | grep "time to " ]],
function(stdout)
if stdout == nil or stdout == '' then
battery_tooltip:set_text('No Battery Found')
return
if stdout == nil or stdout == '' then
battery_tooltip:set_text('No Battery Found')
return
end
local rem_time = ""
if stdout:match("hour") then
rem_time = "Hours"
else
rem_time = "Minutes"
end
local bat_time = stdout:match("%d+,%d") or stdout:match("%d+.%d") or ""
if stdout:match("empty") then
battery_tooltip:set_text("Remaining battery time: " .. bat_time .. " " .. rem_time)
elseif stdout:match("time to full") then
battery_tooltip:set_text("Battery fully charged in: " .. bat_time .. " " .. rem_time)
end
end
local rem_time = ""
if stdout:match("hour") then
rem_time = "Hours"
else
rem_time = "Minutes"
end
local bat_time = stdout:match("%d+,%d") or stdout:match("%d+.%d") or ""
if stdout:match("empty") then
battery_tooltip:set_text("Remaining battery time: " .. bat_time .. " " .. rem_time)
elseif stdout:match("time to full") then
battery_tooltip:set_text("Battery fully charged in: " .. bat_time .. " " .. rem_time)
end
end
)
end
get_battery_info()
@@ -109,92 +108,96 @@ return function()
awful.spawn.easy_async_with_shell(
[[sh -c "upower -i $(upower -e | grep BAT) | grep percentage | awk '{print \$2}' |tr -d '\n%'"]],
function(stdout)
local battery_percentage = tonumber(stdout)
local battery_percentage = tonumber(stdout)
if not battery_percentage then
return
end
battery_widget.container.battery_layout.spacing = dpi(5)
battery_widget.container.battery_layout.label.visible = true
battery_widget.container.battery_layout.label:set_text(battery_percentage .. '%')
local icon = 'battery'
if status == 'fully-charged' or status == 'charging' and battery_percentage == 100 then
icon = icon .. '-' .. 'charging'
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121")))
return
end
if battery_percentage > 0 and battery_percentage < 10 and status == 'discharging' then
icon = icon .. '-' .. 'alert'
if (os.difftime(os.time(), last_battery_check) > 300 or notify_critical_battery) then
last_battery_check = os.time()
notify_critical_battery = false
battery_warning()
if not battery_percentage then
return
end
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121")))
return
battery_widget.container.battery_layout.spacing = dpi(5)
battery_widget.container.battery_layout.label.visible = true
battery_widget.container.battery_layout.label:set_text(battery_percentage .. '%')
local icon = 'battery'
if status == 'fully-charged' or status == 'charging' and battery_percentage == 100 then
icon = icon .. '-' .. 'charging'
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(
gears.color.recolor_image(icondir .. icon .. '.svg', "#212121")))
return
end
if battery_percentage > 0 and battery_percentage < 10 and status == 'discharging' then
icon = icon .. '-' .. 'alert'
if (os.difftime(os.time(), last_battery_check) > 300 or notify_critical_battery) then
last_battery_check = os.time()
notify_critical_battery = false
battery_warning()
end
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(
gears.color.recolor_image(icondir .. icon .. '.svg', "#212121")))
return
end
if battery_percentage > 0 and battery_percentage < 10 then
icon = icon .. '-' .. status .. '-' .. 'outline'
elseif battery_percentage >= 10 and battery_percentage < 20 then
icon = icon .. '-' .. status .. '-' .. '10'
elseif battery_percentage >= 20 and battery_percentage < 30 then
icon = icon .. '-' .. status .. '-' .. '20'
elseif battery_percentage >= 30 and battery_percentage < 40 then
icon = icon .. '-' .. status .. '-' .. '30'
elseif battery_percentage >= 40 and battery_percentage < 50 then
icon = icon .. '-' .. status .. '-' .. '40'
elseif battery_percentage >= 50 and battery_percentage < 60 then
icon = icon .. '-' .. status .. '-' .. '50'
elseif battery_percentage >= 60 and battery_percentage < 70 then
icon = icon .. '-' .. status .. '-' .. '60'
elseif battery_percentage >= 70 and battery_percentage < 80 then
icon = icon .. '-' .. status .. '-' .. '70'
elseif battery_percentage >= 80 and battery_percentage < 90 then
icon = icon .. '-' .. status .. '-' .. '80'
elseif battery_percentage >= 90 and battery_percentage < 100 then
icon = icon .. '-' .. status .. '-' .. '90'
end
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(
gears.color.recolor_image(icondir .. icon .. '.svg', "#212121")))
end
if battery_percentage > 0 and battery_percentage < 10 then
icon = icon .. '-' .. status .. '-' .. 'outline'
elseif battery_percentage >= 10 and battery_percentage < 20 then
icon = icon .. '-' .. status .. '-' .. '10'
elseif battery_percentage >= 20 and battery_percentage < 30 then
icon = icon .. '-' .. status .. '-' .. '20'
elseif battery_percentage >= 30 and battery_percentage < 40 then
icon = icon .. '-' .. status .. '-' .. '30'
elseif battery_percentage >= 40 and battery_percentage < 50 then
icon = icon .. '-' .. status .. '-' .. '40'
elseif battery_percentage >= 50 and battery_percentage < 60 then
icon = icon .. '-' .. status .. '-' .. '50'
elseif battery_percentage >= 60 and battery_percentage < 70 then
icon = icon .. '-' .. status .. '-' .. '60'
elseif battery_percentage >= 70 and battery_percentage < 80 then
icon = icon .. '-' .. status .. '-' .. '70'
elseif battery_percentage >= 80 and battery_percentage < 90 then
icon = icon .. '-' .. status .. '-' .. '80'
elseif battery_percentage >= 90 and battery_percentage < 100 then
icon = icon .. '-' .. status .. '-' .. '90'
end
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. icon .. '.svg', "#212121")))
end
)
end
Hover_signal(battery_widget, color["Purple200"])
Hover_signal(battery_widget, color["Purple200"], color["Grey900"])
battery_widget:connect_signal(
'button::press',
function()
awful.spawn("xfce4-power-manager-settings")
end
awful.spawn("xfce4-power-manager-settings")
end
)
battery_widget:connect_signal(
"mouse::enter",
function()
get_battery_info()
end
get_battery_info()
end
)
watch(
[[sh -c "upower -i $(upower -e | grep BAT) | grep state | awk '{print \$2}' | tr -d '\n'"]],
5,
function(widget, stdout)
local status = stdout:gsub('%\n', '')
if status == nil or status == '' then
battery_widget.container.battery_layout.spacing = dpi(0)
battery_widget.container.battery_layout.label.visible = false
battery_tooltip:set_text('No battery found')
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(gears.color.recolor_image(icondir .. 'battery-off' .. '.svg', "#212121")))
local status = stdout:gsub('%\n', '')
if status == nil or status == '' then
battery_widget.container.battery_layout.spacing = dpi(0)
battery_widget.container.battery_layout.label.visible = false
battery_tooltip:set_text('No battery found')
battery_widget.container.battery_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(
gears.color.recolor_image(icondir .. 'battery-off' .. '.svg', "#212121")))
end
update_battery(status)
end
update_battery(status)
end
)
return battery_widget

View File

@@ -67,13 +67,13 @@ return function()
awful.spawn.easy_async_with_shell(
'./.config/awesome/src/scripts/bt.sh',
function(stdout2)
if stdout2 == nil or stdout2:gsub("\n", "") == "" then
bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently not connected")
else
connected_device = stdout2:gsub("%(", ""):gsub("%)", "")
bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently connected to:\n" .. connected_device)
if stdout2 == nil or stdout2:gsub("\n", "") == "" then
bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently not connected")
else
connected_device = stdout2:gsub("%(", ""):gsub("%)", "")
bluetooth_tooltip:set_text("Bluetooth is turned " .. bluetooth_state .. "\n" .. "You are currently connected to:\n" .. connected_device)
end
end
end
)
end
bluetooth_widget.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icon .. ".svg", color["Grey900"]))
@@ -82,49 +82,49 @@ return function()
)
-- Signals
Hover_signal(bluetooth_widget, color["Blue200"])
Hover_signal(bluetooth_widget, color["Blue200"], color["Grey900"])
bluetooth_widget:connect_signal(
"button::press",
function()
awful.spawn.easy_async_with_shell(
"rfkill list bluetooth",
function(stdout)
if stdout:gsub("\n", "") ~= '' then
if bluetooth_state == "off" then
awful.spawn.easy_async_with_shell(
[[
awful.spawn.easy_async_with_shell(
"rfkill list bluetooth",
function(stdout)
if stdout:gsub("\n", "") ~= '' then
if bluetooth_state == "off" then
awful.spawn.easy_async_with_shell(
[[
rfkill unblock bluetooth
sleep 1
bluetoothctl power on
]],
function()
naughty.notification {
title = "System Notification",
app_name = "Bluetooth",
message = "Bluetooth activated"
}
end
)
else
awful.spawn.easy_async_with_shell(
[[
]] ,
function()
naughty.notification {
title = "System Notification",
app_name = "Bluetooth",
message = "Bluetooth activated"
}
end
)
else
awful.spawn.easy_async_with_shell(
[[
bluetoothctl power off
rfkill block bluetooth
]],
function()
naughty.notification {
title = "System Notification",
app_name = "Bluetooth",
message = "Bluetooth deactivated"
}
]] ,
function()
naughty.notification {
title = "System Notification",
app_name = "Bluetooth",
message = "Bluetooth deactivated"
}
end
)
end
end
)
end
end
)
end
)
end
)
return bluetooth_widget

View File

@@ -39,7 +39,8 @@ return function()
id = "label",
align = "center",
valign = "center",
widget = wibox.widget.textbox
format = "%H:%M",
widget = wibox.widget.textclock
},
id = "clock_layout",
layout = wibox.layout.fixed.horizontal
@@ -57,22 +58,7 @@ return function()
widget = wibox.container.background
}
local set_clock = function()
clock_widget.container.clock_layout.label:set_text(os.date("%H:%M"))
end
-- Updates the clock every 5 seconds, worst case you are 5 seconds behind
-- ¯\_(ツ)_/¯
gears.timer {
timeout = 5,
autostart = true,
call_now = true,
callback = function()
set_clock()
end
}
Hover_signal(clock_widget, color["Orange200"])
Hover_signal(clock_widget, color["Orange200"], color["Grey900"])
return clock_widget
end

View File

@@ -145,21 +145,21 @@ return function(widget, clock_mode)
[[ cat "/proc/stat" | grep '^cpu ' ]],
3,
function(_, stdout)
local user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice =
stdout:match("(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s")
local user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice =
stdout:match("(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s")
local total = user + nice + system + idle + iowait + irq + softirq + steal
local total = user + nice + system + idle + iowait + irq + softirq + steal
local diff_idle = idle - idle_prev
local diff_total = total - total_prev
local diff_usage = (1000 * (diff_total - diff_idle) / diff_total + 5) / 10
local diff_idle = idle - idle_prev
local diff_total = total - total_prev
local diff_usage = (1000 * (diff_total - diff_idle) / diff_total + 5) / 10
cpu_usage_widget.container.cpu_layout.label.text = tostring(math.floor(diff_usage)) .. "%"
cpu_usage_widget.container.cpu_layout.label.text = tostring(math.floor(diff_usage)) .. "%"
total_prev = total
idle_prev = idle
collectgarbage("collect")
end
total_prev = total
idle_prev = idle
collectgarbage("collect")
end
)
watch(
@@ -167,53 +167,53 @@ return function(widget, clock_mode)
3,
function(_, stdout)
local temp_icon
local temp_color
local temp_icon
local temp_color
local temp_num = tonumber(stdout:match("%d+"))
if temp_num < 50 then
temp_color = color["Green200"]
temp_icon = icon_dir .. "thermometer-low.svg"
elseif temp_num >= 50 and temp_num < 80 then
temp_color = color["Orange200"]
temp_icon = icon_dir .. "thermometer.svg"
elseif temp_num >= 80 then
temp_color = color["Red200"]
temp_icon = icon_dir .. "thermometer-high.svg"
local temp_num = tonumber(stdout:match("%d+"))
if temp_num < 50 then
temp_color = color["Green200"]
temp_icon = icon_dir .. "thermometer-low.svg"
elseif temp_num >= 50 and temp_num < 80 then
temp_color = color["Orange200"]
temp_icon = icon_dir .. "thermometer.svg"
elseif temp_num >= 80 then
temp_color = color["Red200"]
temp_icon = icon_dir .. "thermometer-high.svg"
end
Hover_signal(cpu_temp, temp_color, color["Grey900"])
cpu_temp.container.cpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon)
cpu_temp:set_bg(temp_color)
cpu_temp.container.cpu_layout.label.text = math.floor(temp_num) .. "°C"
end
Hover_signal(cpu_temp, temp_color)
cpu_temp.container.cpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon)
cpu_temp:set_bg(temp_color)
cpu_temp.container.cpu_layout.label.text = math.floor(temp_num) .. "°C"
end
)
watch(
[[ bash -c "cat /proc/cpuinfo | grep "MHz" | awk '{print int($4)}'" ]],
3,
function(_, stdout)
local cpu_freq = {}
local cpu_freq = {}
for value in stdout:gmatch("%d+") do
table.insert(cpu_freq, value)
end
local average = 0
if clock_mode == "average" then
for i = 1, #cpu_freq do
average = average + cpu_freq[i]
for value in stdout:gmatch("%d+") do
table.insert(cpu_freq, value)
end
local average = 0
if clock_mode == "average" then
for i = 1, #cpu_freq do
average = average + cpu_freq[i]
end
average = math.floor(average / #cpu_freq)
cpu_clock.container.cpu_layout.label.text = tonumber(average) .. "Mhz"
elseif clock_mode then
cpu_clock.container.cpu_layout.label.text = tonumber(cpu_freq[clock_mode]) .. "Mhz"
end
average = math.floor(average / #cpu_freq)
cpu_clock.container.cpu_layout.label.text = tonumber(average) .. "Mhz"
elseif clock_mode then
cpu_clock.container.cpu_layout.label.text = tonumber(cpu_freq[clock_mode]) .. "Mhz"
end
end
)
Hover_signal(cpu_usage_widget, color["Blue200"])
Hover_signal(cpu_clock, color["Purple200"])
Hover_signal(cpu_usage_widget, color["Blue200"], color["Grey900"])
Hover_signal(cpu_clock, color["Purple200"], color["Grey900"])
if widget == "usage" then
return cpu_usage_widget

View File

@@ -72,20 +72,20 @@ return function()
}
-- Signals
Hover_signal(date_widget, color["Teal200"])
Hover_signal(date_widget, color["Teal200"], color["Grey900"])
date_widget:connect_signal(
"mouse::enter",
function()
awesome.emit_signal("widget::calendar_osd:stop", true)
end
awesome.emit_signal("widget::calendar_osd:stop", true)
end
)
date_widget:connect_signal(
"mouse::leave",
function()
awesome.emit_signal("widget::calendar_osd:rerun", true)
end
awesome.emit_signal("widget::calendar_osd:rerun", true)
end
)
return date_widget

View File

@@ -54,7 +54,7 @@ return function(widget)
end,
widget = wibox.container.background
}
Hover_signal(gpu_usage_widget, color["Green200"])
Hover_signal(gpu_usage_widget, color["Green200"], color["Grey900"])
local gpu_temp_widget = wibox.widget {
{
@@ -102,8 +102,8 @@ return function(widget)
[[ bash -c "nvidia-smi -q -d UTILIZATION | grep Gpu | awk '{print $3}'"]],
3,
function(_, stdout)
gpu_usage_widget.container.gpu_layout.label.text = stdout:gsub("\n", "") .. "%"
end
gpu_usage_widget.container.gpu_layout.label.text = stdout:gsub("\n", "") .. "%"
end
)
-- GPU Temperature
@@ -112,26 +112,26 @@ return function(widget)
3,
function(_, stdout)
local temp_icon
local temp_color
local temp_num = tonumber(stdout)
local temp_icon
local temp_color
local temp_num = tonumber(stdout)
if temp_num < 50 then
temp_color = color["Green200"]
temp_icon = icon_dir .. "thermometer-low.svg"
elseif temp_num >= 50 and temp_num < 80 then
temp_color = color["Orange200"]
temp_icon = icon_dir .. "thermometer.svg"
elseif temp_num >= 80 then
temp_color = color["Red200"]
temp_icon = icon_dir .. "thermometer-high.svg"
if temp_num < 50 then
temp_color = color["Green200"]
temp_icon = icon_dir .. "thermometer-low.svg"
elseif temp_num >= 50 and temp_num < 80 then
temp_color = color["Orange200"]
temp_icon = icon_dir .. "thermometer.svg"
elseif temp_num >= 80 then
temp_color = color["Red200"]
temp_icon = icon_dir .. "thermometer-high.svg"
end
Hover_signal(gpu_temp_widget, temp_color, color["Grey900"])
gpu_temp_widget.container.gpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon)
gpu_temp_widget:set_bg(temp_color)
gpu_temp_widget.container.gpu_layout.label.text = tostring(temp_num) .. "°C"
end
Hover_signal(gpu_temp_widget, temp_color)
gpu_temp_widget.container.gpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon)
gpu_temp_widget:set_bg(temp_color)
gpu_temp_widget.container.gpu_layout.label.text = tostring(temp_num) .. "°C"
end
)
if widget == "usage" then

View File

@@ -59,10 +59,10 @@ return function(s)
awful.spawn.easy_async_with_shell(
[[ setxkbmap -query | grep layout | awk '{print $2}' ]],
function(stdout)
local layout = stdout:gsub("\n", "")
kblayout_widget.container.kblayout_layout.label.text = layout
awesome.emit_signal("update::background:kblayout")
end
local layout = stdout:gsub("\n", "")
kblayout_widget.container.kblayout_layout.label.text = layout
awesome.emit_signal("update::background:kblayout")
end
)
end
@@ -72,12 +72,12 @@ return function(s)
local xkeyboard_country_code = {
{ "af", "أفغانيش(Afghanistan)", "AFG" }, -- Afghanistan
{ "al", "shqip(Albania)", "ALB" }, -- Albania
{ "am", "հայերեն(Armenia)", "ARM" }, -- Armenia
{ "al", "Shqip(Albania)", "ALB" }, -- Albania
{ "am", "Hայերեն(Armenia)", "ARM" }, -- Armenia
{ "ara", "عربي(Arab)", "ARB" }, -- Arabic
{ "at", "Österreichisch (Austria)", "AUT" }, -- Austria
{ "az", "Azərbaycan(Azerbaijan)", "AZE" }, -- Azerbaijan
{ "ba", "bosanski(Bosnia and Herzegovina)", "BIH" }, -- Bosnia and Herzegovina
{ "ba", "Bosanski(Bosnia and Herzegovina)", "BIH" }, -- Bosnia and Herzegovina
{ "bd", "", "BGD" }, -- Bangladesh
{ "be", "", "BEL" }, -- Belgium
{ "bg", "", "BGR" }, -- Bulgaria
@@ -219,22 +219,22 @@ return function(s)
awesome.connect_signal(
"update::background:kblayout",
function()
awful.spawn.easy_async_with_shell(
[[ setxkbmap -query | grep layout | awk '{print $2}' ]],
function(stdout)
local layout = stdout:gsub("\n", "")
if kb_layout_item.keymap == layout then
kb_layout_item.bg = color["DeepPurple200"]
kb_layout_item:get_children_by_id("background2")[1].fg = color["Grey900"]
kb_layout_item:get_children_by_id("background1")[1].fg = color["Grey900"]
else
kb_layout_item.bg = color["Grey800"]
kb_layout_item:get_children_by_id("background2")[1].fg = color["Red200"]
kb_layout_item:get_children_by_id("background1")[1].fg = color["Purple200"]
end
awful.spawn.easy_async_with_shell(
[[ setxkbmap -query | grep layout | awk '{print $2}' ]],
function(stdout)
local layout = stdout:gsub("\n", "")
if kb_layout_item.keymap == layout then
kb_layout_item.bg = color["DeepPurple200"]
kb_layout_item:get_children_by_id("background2")[1].fg = color["Grey900"]
kb_layout_item:get_children_by_id("background1")[1].fg = color["Grey900"]
else
kb_layout_item.bg = color["Grey800"]
kb_layout_item:get_children_by_id("background2")[1].fg = color["Red200"]
kb_layout_item:get_children_by_id("background1")[1].fg = color["Purple200"]
end
end
)
end
)
end
)
get_kblayout()
@@ -242,15 +242,15 @@ return function(s)
kb_layout_item:connect_signal(
"button::press",
function()
awful.spawn.easy_async_with_shell(
"setxkbmap " .. keymap,
function()
awesome.emit_signal("kblayout::hide:kbmenu")
mousegrabber.stop()
get_kblayout()
awful.spawn.easy_async_with_shell(
"setxkbmap " .. keymap,
function()
awesome.emit_signal("kblayout::hide:kbmenu")
mousegrabber.stop()
get_kblayout()
end
)
end
)
end
)
return kb_layout_item
end
@@ -294,25 +294,23 @@ return function(s)
kb_menu_widget:connect_signal(
"mouse::leave",
function()
mousegrabber.run(
function()
kblayout_widget.bg = color["Green200"]
if mouse.is_left_mouse_button_pressed then
mousegrabber.run(
function()
kblayout_widget.bg = color["Green200"]
awesome.emit_signal("kblayout::hide:kbmenu")
mousegrabber.stop()
end
return true
end,
"arrow"
)
end
return true
end,
"arrow"
)
end
)
kb_menu_widget:connect_signal(
"mouse::enter",
function()
mousegrabber.stop()
end
mousegrabber.stop()
end
)
kb_menu_widget:setup(
@@ -323,38 +321,38 @@ return function(s)
awful.spawn.easy_async_with_shell(
"setxkbmap -query | grep layout: | awk '{print $2}'",
function(stdout)
for j, n in ipairs(user_vars.kblayout) do
if stdout:match(n) then
if j == #user_vars.kblayout then
awful.spawn.easy_async_with_shell(
"setxkbmap " .. user_vars.kblayout[1],
function()
get_kblayout()
for j, n in ipairs(user_vars.kblayout) do
if stdout:match(n) then
if j == #user_vars.kblayout then
awful.spawn.easy_async_with_shell(
"setxkbmap " .. user_vars.kblayout[1],
function()
get_kblayout()
end
)
else
awful.spawn.easy_async_with_shell(
"setxkbmap " .. user_vars.kblayout[j + 1],
function()
get_kblayout()
end
)
end
)
else
awful.spawn.easy_async_with_shell(
"setxkbmap " .. user_vars.kblayout[j + 1],
function()
get_kblayout()
end
)
end
end
end
end
)
end
awesome.connect_signal(
"kblayout::toggle",
function()
toggle_kb_layout()
end
toggle_kb_layout()
end
)
-- Signals
Hover_signal(kblayout_widget, color["Green200"])
Hover_signal(kblayout_widget, color["Green200"], color["Grey900"])
local kblayout_keygrabber = awful.keygrabber {
autostart = false,
@@ -368,23 +366,23 @@ return function(s)
kblayout_widget:connect_signal(
"button::press",
function()
mousegrabber.stop()
if kb_menu_widget.visible then
kb_menu_widget.visible = false
kblayout_keygrabber:stop()
else
kb_menu_widget.visible = true
kblayout_keygrabber:start()
mousegrabber.stop()
if kb_menu_widget.visible then
kb_menu_widget.visible = false
kblayout_keygrabber:stop()
else
kb_menu_widget.visible = true
kblayout_keygrabber:start()
end
end
end
)
awesome.connect_signal(
"kblayout::hide:kbmenu",
function()
kb_menu_widget.visible = false
kblayout_keygrabber:stop()
end
kb_menu_widget.visible = false
kblayout_keygrabber:stop()
end
)
get_kblayout()

View File

@@ -33,13 +33,13 @@ return function()
}
-- Signals
Hover_signal(layout, color["LightBlue200"])
Hover_signal(layout, color["LightBlue200"], color["Grey900"])
layout:connect_signal(
"button::press",
function()
awful.layout.inc(-1)
end
awful.layout.inc(-1)
end
)
return layout

View File

@@ -131,21 +131,21 @@ return function()
awful.spawn.easy_async_with_shell(
[[ iw dev ]] .. interfaces.wlan_interface .. [[ link ]],
function(stdout)
local essid = stdout:match("SSID: (.-)\n") or "N/A"
local bitrate = stdout:match("tx bitrate: (.+/s)") or "N/A"
local message = "Connected to <b>" .. essid .. "</b>\nSignal strength <b>" .. tostring(wifi_strength) .. "%</b>\n" .. "Bit rate <b>" .. tostring(bitrate) .. "</b>"
local essid = stdout:match("SSID: (.-)\n") or "N/A"
local bitrate = stdout:match("tx bitrate: (.+/s)") or "N/A"
local message = "Connected to <b>" .. essid .. "</b>\nSignal strength <b>" .. tostring(wifi_strength) .. "%</b>\n" .. "Bit rate <b>" .. tostring(bitrate) .. "</b>"
if healthy then
update_tooltip(message)
else
update_tooltip("You are connected but have no internet" .. message)
end
if healthy then
update_tooltip(message)
else
update_tooltip("You are connected but have no internet" .. message)
end
if reconnect_startup or startup then
notify_connected(essid)
update_reconnect_startup(false)
if reconnect_startup or startup then
notify_connected(essid)
update_reconnect_startup(false)
end
end
end
)
end
@@ -153,20 +153,20 @@ return function()
awful.spawn.easy_async_with_shell(
check_for_internet,
function(stdout)
local icon = "wifi-strength"
if not stdout:match("Connected but no internet") then
if startup or reconnect_startup then
awesome.emit_signal("system::network_connected")
local icon = "wifi-strength"
if not stdout:match("Connected but no internet") then
if startup or reconnect_startup then
awesome.emit_signal("system::network_connected")
end
icon = icon .. '-' .. tostring(strength)
update_wireless_data(true)
else
icon = icon .. "-" .. tostring(strength)
update_wireless_data(false)
end
icon = icon .. '-' .. tostring(strength)
update_wireless_data(true)
else
icon = icon .. "-" .. tostring(strength)
update_wireless_data(false)
network_widget.container.network_layout.spacing = dpi(8)
network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. icon .. ".svg", color["Grey900"]))
end
network_widget.container.network_layout.spacing = dpi(8)
network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(gears.color.recolor_image(icondir .. icon .. ".svg", color["Grey900"]))
end
)
end
@@ -174,16 +174,16 @@ return function()
awful.spawn.easy_async_with_shell(
[[ awk 'NR==3 {printf "%3.0f", ($3/70)*100}' /proc/net/wireless ]],
function(stdout)
if not tonumber(stdout) then
return
if not tonumber(stdout) then
return
end
wifi_strength = tonumber(stdout)
network_widget.container.network_layout.spacing = dpi(8)
network_widget.container.network_layout.label.visible = true
network_widget.container.network_layout.label:set_text(tostring(wifi_strength .. "%"))
local wifi_strength_rounded = math.floor(wifi_strength / 25 + 0.5)
update_wireless_icon(wifi_strength_rounded)
end
wifi_strength = tonumber(stdout)
network_widget.container.network_layout.spacing = dpi(8)
network_widget.container.network_layout.label.visible = true
network_widget.container.network_layout.label:set_text(tostring(wifi_strength .. "%"))
local wifi_strength_rounded = math.floor(wifi_strength / 25 + 0.5)
update_wireless_icon(wifi_strength_rounded)
end
)
end
@@ -205,26 +205,26 @@ return function()
awful.spawn.easy_async_with_shell(
check_for_internet,
function(stdout)
local icon = "ethernet"
local icon = "ethernet"
if stdout:match("Connected but no internet") then
icon = "no-internet"
update_tooltip(
"No internet"
)
else
update_tooltip("You are connected to:\nEthernet Interface <b>" .. interfaces.lan_interface .. "</b>")
if startup or reconnect_startup then
awesome.emit_signal("system::network_connected")
notify_connected()
update_startup()
if stdout:match("Connected but no internet") then
icon = "no-internet"
update_tooltip(
"No internet"
)
else
update_tooltip("You are connected to:\nEthernet Interface <b>" .. interfaces.lan_interface .. "</b>")
if startup or reconnect_startup then
awesome.emit_signal("system::network_connected")
notify_connected()
update_startup()
end
update_reconnect_startup(false)
end
update_reconnect_startup(false)
network_widget.container.network_layout.label.visible = false
network_widget.container.network_layout.spacing = dpi(0)
network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(icondir .. icon .. ".svg")
end
network_widget.container.network_layout.label.visible = false
network_widget.container.network_layout.spacing = dpi(0)
network_widget.container.network_layout.icon_margin.icon_layout.icon:set_image(icondir .. icon .. ".svg")
end
)
end
@@ -302,15 +302,15 @@ return function()
print_network_mode
]=],
function(stdout)
local mode = stdout:gsub("%\n", "")
if stdout:match("No internet connected") then
update_disconnected()
elseif stdout:match("wireless") then
update_wireless()
elseif stdout:match("wired") then
update_wired()
local mode = stdout:gsub("%\n", "")
if stdout:match("No internet connected") then
update_disconnected()
elseif stdout:match("wireless") then
update_wireless()
elseif stdout:match("wired") then
update_wired()
end
end
end
)
end
@@ -324,13 +324,13 @@ return function()
}
-- Signals
Hover_signal(network_widget, color["Red200"])
Hover_signal(network_widget, color["Red200"], color["Grey900"])
network_widget:connect_signal(
"button::press",
function()
awful.spawn("gnome-control-center wlan")
end
awful.spawn("gnome-control-center wlan")
end
)
return network_widget

View File

@@ -50,13 +50,13 @@ return function()
}
-- Signals
Hover_signal(power_widget, color["Red200"])
Hover_signal(power_widget, color["Red200"], color["Grey900"])
power_widget:connect_signal(
"button::release",
function()
awesome.emit_signal("module::powermenu:show")
end
awesome.emit_signal("module::powermenu:show")
end
)
return power_widget

View File

@@ -55,17 +55,17 @@ return function()
widget = wibox.container.background
}
Hover_signal(ram_widget, color["Red200"])
Hover_signal(ram_widget, color["Red200"], color["Grey900"])
watch(
[[ bash -c "cat /proc/meminfo| grep Mem | awk '{print $2}'" ]],
3,
function(_, stdout)
local MemTotal, MemFree, MemAvailable = stdout:match("(%d+)\n(%d+)\n(%d+)\n")
local MemTotal, MemFree, MemAvailable = stdout:match("(%d+)\n(%d+)\n(%d+)\n")
ram_widget.container.ram_layout.label.text = tostring(string.format("%.1f", ((MemTotal - MemAvailable) / 1024 / 1024)) .. "/" .. string.format("%.1f", (MemTotal / 1024 / 1024)) .. "GB"):gsub(",", ".")
end
ram_widget.container.ram_layout.label.text = tostring(string.format("%.1f", ((MemTotal - MemAvailable) / 1024 / 1024)) .. "/" .. string.format("%.1f", (MemTotal / 1024 / 1024)) .. "GB"):gsub(",", ".")
end
)
return ram_widget

View File

@@ -30,7 +30,7 @@ return function(s)
bg = color["BlueGrey800"]
}
-- Signals
Hover_signal(systray.container, color["Red200"])
Hover_signal(systray.container, color["Red200"], color["Grey900"])
awesome.connect_signal("systray::update", function()
local num_entries = awesome.systray()

View File

@@ -1,3 +1,8 @@
--------------------------------
-- This is the taglist widget --
--------------------------------
-- Awesome Libs
local wibox = require("wibox")
local awful = require("awful")
local gears = require("gears")
@@ -8,52 +13,29 @@ require("src.tools.icon_handler")
local list_update = function(widget, buttons, label, data, objects)
widget:reset()
for i, object in ipairs(objects) do
local tag_icon = wibox.widget {
nil,
{
id = "icon",
resize = true,
widget = wibox.widget.imagebox
},
nil,
layout = wibox.layout.align.horizontal
}
local tag_icon_margin = wibox.widget {
tag_icon,
forced_width = dpi(33),
margins = dpi(3),
widget = wibox.container.margin
}
local tag_label = wibox.widget {
text = "",
align = "center",
valign = "center",
visible = true,
font = user_vars.font.extrabold,
forced_width = dpi(25),
widget = wibox.widget.textbox
}
local tag_label_margin = wibox.widget {
tag_label,
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin
}
for _, object in ipairs(objects) do
local tag_widget = wibox.widget {
id = "widget_margin",
{
{
{
text = "",
align = "center",
valign = "center",
visible = true,
font = user_vars.font.extrabold,
forced_width = dpi(25),
id = "label",
widget = wibox.widget.textbox
},
id = "margin",
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin
},
id = "container",
tag_label_margin,
layout = wibox.layout.fixed.horizontal
},
fg = color["White"],
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
@@ -83,8 +65,7 @@ local list_update = function(widget, buttons, label, data, objects)
tag_widget:buttons(create_buttons(buttons, object))
local text, bg_color, bg_image, icon, args = label(object, tag_label)
tag_label:set_text(object.index)
tag_widget.container.margin.label:set_text(object.index)
if object.urgent == true then
tag_widget:set_bg(color["RedA200"])
tag_widget:set_fg(color["Grey900"])
@@ -97,7 +78,7 @@ local list_update = function(widget, buttons, label, data, objects)
-- Set the icon for each client
for _, client in ipairs(object:clients()) do
tag_label_margin:set_right(0)
tag_widget.container.margin:set_right(0)
local icon = wibox.widget {
{
id = "icon_container",
@@ -108,7 +89,6 @@ local list_update = function(widget, buttons, label, data, objects)
},
widget = wibox.container.place
},
tag_icon_margin,
forced_width = dpi(33),
margins = dpi(6),
widget = wibox.container.margin
@@ -121,63 +101,65 @@ local list_update = function(widget, buttons, label, data, objects)
})
end
--#region Hover_signal
local old_wibox, old_cursor, old_bg
tag_widget:connect_signal(
"mouse::enter",
function()
old_bg = tag_widget.bg
if object == awful.screen.focused().selected_tag then
tag_widget.bg = '#dddddd' .. 'dd'
else
tag_widget.bg = '#3A475C' .. 'dd'
old_bg = tag_widget.bg
if object == awful.screen.focused().selected_tag then
tag_widget.bg = '#dddddd' .. 'dd'
else
tag_widget.bg = '#3A475C' .. 'dd'
end
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
tag_widget:connect_signal(
"button::press",
function()
if object == awful.screen.focused().selected_tag then
tag_widget.bg = '#bbbbbb' .. 'dd'
else
tag_widget.bg = '#3A475C' .. 'dd'
if object == awful.screen.focused().selected_tag then
tag_widget.bg = '#bbbbbb' .. 'dd'
else
tag_widget.bg = '#3A475C' .. 'dd'
end
end
end
)
tag_widget:connect_signal(
"button::release",
function()
if object == awful.screen.focused().selected_tag then
tag_widget.bg = '#dddddd' .. 'dd'
else
tag_widget.bg = '#3A475C' .. 'dd'
if object == awful.screen.focused().selected_tag then
tag_widget.bg = '#dddddd' .. 'dd'
else
tag_widget.bg = '#3A475C' .. 'dd'
end
end
end
)
tag_widget:connect_signal(
"mouse::leave",
function()
tag_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
tag_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
end
)
--#endregion
widget:add(tag_widget)
widget:set_spacing(dpi(6))
end
end
local tag_list = function(s)
return function(s)
return awful.widget.taglist(
s,
awful.widget.taglist.filter.noempty,
@@ -186,49 +168,49 @@ local tag_list = function(s)
{},
1,
function(t)
t:view_only()
end
t:view_only()
end
),
awful.button(
{ modkey },
1,
function(t)
if client.focus then
client.focus:move_to_tag(t)
if client.focus then
client.focus:move_to_tag(t)
end
end
end
),
awful.button(
{},
3,
function(t)
if client.focus then
client.focus:toggle_tag(t)
if client.focus then
client.focus:toggle_tag(t)
end
end
end
),
awful.button(
{ modkey },
3,
function(t)
if client.focus then
client.focus:toggle_tag(t)
if client.focus then
client.focus:toggle_tag(t)
end
end
end
),
awful.button(
{},
4,
function(t)
awful.tag.viewnext(t.screen)
end
awful.tag.viewnext(t.screen)
end
),
awful.button(
{},
5,
function(t)
awful.tag.viewprev(t.screen)
end
awful.tag.viewprev(t.screen)
end
)
),
{},
@@ -236,5 +218,3 @@ local tag_list = function(s)
wibox.layout.fixed.horizontal()
)
end
return tag_list

View File

@@ -1,3 +1,8 @@
---------------------------------
-- This is the tasklist widget --
---------------------------------
-- Awesome Libs
local awful = require('awful')
local wibox = require('wibox')
local dpi = require('beautiful').xresources.apply_dpi
@@ -83,7 +88,7 @@ local list_update = function(widget, buttons, label, data, objects)
task_widget:buttons(create_buttons(buttons, object))
local text, bg, bg_image, icon, args = label(object, task_widget.container.layout_it.title)
local text, _ = label(object, task_widget.container.layout_it.title)
if object == client.focus then
if text == nil or text == '' then
task_widget.container.layout_it.title:set_margins(0)
@@ -112,61 +117,64 @@ local list_update = function(widget, buttons, label, data, objects)
widget:add(task_widget)
widget:set_spacing(dpi(6))
--#region Hover_signal
local old_wibox, old_cursor, old_bg
task_widget:connect_signal(
"mouse::enter",
function()
old_bg = task_widget.bg
if object == client.focus then
task_widget.bg = '#dddddddd'
else
task_widget.bg = '#3A475Cdd'
old_bg = task_widget.bg
if object == client.focus then
task_widget.bg = '#dddddddd'
else
task_widget.bg = '#3A475Cdd'
end
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
local w = mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = "hand1"
end
end
)
task_widget:connect_signal(
"button::press",
function()
if object == client.focus then
task_widget.bg = "#ffffffaa"
else
task_widget.bg = '#3A475Caa'
if object == client.focus then
task_widget.bg = "#ffffffaa"
else
task_widget.bg = '#3A475Caa'
end
end
end
)
task_widget:connect_signal(
"button::release",
function()
if object == client.focus then
task_widget.bg = "#ffffffdd"
else
task_widget.bg = '#3A475Cdd'
if object == client.focus then
task_widget.bg = "#ffffffdd"
else
task_widget.bg = '#3A475Cdd'
end
end
end
)
task_widget:connect_signal(
"mouse::leave",
function()
task_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
task_widget.bg = old_bg
if old_wibox then
old_wibox.cursor = old_cursor
old_wibox = nil
end
end
end
)
--#endregion
end
return widget
end
local tasklist = function(s)
return function(s)
return awful.widget.tasklist(
s,
awful.widget.tasklist.filter.currenttags,
@@ -175,24 +183,24 @@ local tasklist = function(s)
{},
1,
function(c)
if c == client.focus then
c.minimized = true
else
c.minimized = false
if not c:isvisible() and c.first_tag then
c.first_tag:view_only()
if c == client.focus then
c.minimized = true
else
c.minimized = false
if not c:isvisible() and c.first_tag then
c.first_tag:view_only()
end
c:emit_signal('request::activate')
c:raise()
end
c:emit_signal('request::activate')
c:raise()
end
end
),
awful.button(
{},
3,
function(c)
c:kill()
end
c:kill()
end
)
),
{},
@@ -200,5 +208,3 @@ local tasklist = function(s)
wibox.layout.fixed.horizontal()
)
end
return tasklist