Add new window switcher on super+tab and smaller fixes
This commit is contained in:
26
awesome/src/tools/helpers/cpu_freq.lua
Normal file
26
awesome/src/tools/helpers/cpu_freq.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
local awful = require("awful")
|
||||
local watch = awful.widget.watch
|
||||
|
||||
watch(
|
||||
[[ bash -c "cat /proc/cpuinfo | grep "MHz" | awk '{print int($4)}'" ]],
|
||||
3,
|
||||
function(_, stdout)
|
||||
local cpu_freq = {}
|
||||
|
||||
for value in stdout:gmatch("%d+") do
|
||||
table.insert(cpu_freq, value)
|
||||
end
|
||||
|
||||
local average = 0
|
||||
|
||||
if User_config.clock_mode == "average" then
|
||||
for i = 1, #cpu_freq do
|
||||
average = average + cpu_freq[i]
|
||||
end
|
||||
average = math.floor(average / #cpu_freq)
|
||||
awesome.emit_signal("update::cpu_freq_average", average)
|
||||
elseif User_config.clock_mode then
|
||||
awesome.emit_signal("update::cpu_freq_core", cpu_freq[User_config.clock_mode])
|
||||
end
|
||||
end
|
||||
)
|
||||
14
awesome/src/tools/helpers/cpu_temp.lua
Normal file
14
awesome/src/tools/helpers/cpu_temp.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
local awful = require("awful")
|
||||
local watch = awful.widget.watch
|
||||
|
||||
watch(
|
||||
[[ bash -c "sensors | grep 'Package id 0:' | awk '{print $4}'" ]],
|
||||
3,
|
||||
function(_, stdout)
|
||||
local temp = tonumber(stdout:match("%d+"))
|
||||
awesome.emit_signal(
|
||||
"update::cpu_temp",
|
||||
temp
|
||||
)
|
||||
end
|
||||
)
|
||||
26
awesome/src/tools/helpers/cpu_usage.lua
Normal file
26
awesome/src/tools/helpers/cpu_usage.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
local awful = require("awful")
|
||||
local watch = awful.widget.watch
|
||||
|
||||
local total_prev = 0
|
||||
local idle_prev = 0
|
||||
|
||||
watch(
|
||||
[[ 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 total = user + nice + system + idle + iowait + irq + softirq + steal
|
||||
|
||||
local diff_idle = idle - idle_prev
|
||||
local diff_total = total - total_prev
|
||||
local diff_usage = math.floor(((1000 * (diff_total - diff_idle) / diff_total + 5) / 10) + 0.5)
|
||||
|
||||
awesome.emit_signal("update::cpu_usage", diff_usage)
|
||||
|
||||
total_prev = total
|
||||
idle_prev = idle
|
||||
collectgarbage("collect")
|
||||
end
|
||||
)
|
||||
10
awesome/src/tools/helpers/gpu_temp.lua
Normal file
10
awesome/src/tools/helpers/gpu_temp.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
local awful = require("awful")
|
||||
local watch = awful.widget.watch
|
||||
|
||||
watch(
|
||||
[[ bash -c "nvidia-smi -q -d TEMPERATURE | grep 'GPU Current Temp' | awk '{print $5}'"]],
|
||||
3,
|
||||
function(_, stdout)
|
||||
awesome.emit_signal("update::gpu_temp", stdout:match("%d+"):gsub("\n", ""))
|
||||
end
|
||||
)
|
||||
11
awesome/src/tools/helpers/gpu_usage.lua
Normal file
11
awesome/src/tools/helpers/gpu_usage.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
local awful = require("awful")
|
||||
local watch = awful.widget.watch
|
||||
|
||||
watch(
|
||||
[[ bash -c "nvidia-smi -q -d UTILIZATION | grep Gpu | awk '{print $3}'"]],
|
||||
3,
|
||||
function(_, stdout)
|
||||
stdout = stdout:match("%d+")
|
||||
awesome.emit_signal("update::gpu_usage", stdout)
|
||||
end
|
||||
)
|
||||
6
awesome/src/tools/helpers/init.lua
Normal file
6
awesome/src/tools/helpers/init.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
require("src.tools.helpers.cpu_temp")
|
||||
require("src.tools.helpers.cpu_usage")
|
||||
require("src.tools.helpers.cpu_freq")
|
||||
require("src.tools.helpers.ram")
|
||||
require("src.tools.helpers.gpu_usage")
|
||||
require("src.tools.helpers.gpu_temp")
|
||||
11
awesome/src/tools/helpers/ram.lua
Normal file
11
awesome/src/tools/helpers/ram.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
local awful = require("awful")
|
||||
local watch = awful.widget.watch
|
||||
|
||||
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")
|
||||
awesome.emit_signal("update::ram_widget", MemTotal, MemFree, MemAvailable)
|
||||
end
|
||||
)
|
||||
Reference in New Issue
Block a user