簡體   English   中英

很棒的 wm 中的 cpu 臨時小部件

[英]cpu temp widget in awesome wm

我最近開始使用很棒的 wm 4.2 版並且非常喜歡它; 顯着改善了我的工作流程。 我嘗試了一些主題,例如模仿者和其他主題,但它們對我來說太花哨了。 我喜歡默認配置並在這里閱讀: https ://awesomewm.org/apidoc/index.html 以及來自模仿者和其他人的 rc.lua 和 theme.lua 文件,並且已經實現了其中的一些; 鍵綁定、布局操作、啟動程序。 我想創建一個顯示 cpu temp 的小部件,我按照https://awesomewm.org/apidoc/classes/awful.widget.watch.html 的說明進行了制作,如下所示:

wibox.widget.textbox('  |  '),
awful.widget.watch(
  'bash -c "cat/sys/class/hwmon/hwmon0/device/temp1_input"', 15),
wibox.widget.textbox('  |  '),
awful.widget.watch(
  'bash -c "cat /sys/class/hwmon/hwmon0/device/temp3_input"', 15),

它有效,但它顯示大數字,即 43000 而不是 43。我該如何更改? 如果可能,43°C。

如果你得到正確的數字並且只想除以 1000,你可以使用 可選的回調

awful.widget.watch('bash -c "cat /sys/class/hwmon/hwmon0/device/temp1_input"', 15, 
  function(widget, s) widget:set_text(tonumber(s)/1000) end)

只需使用sensors ,就更容易了。 我通過創建一個更新sensors值的小部件來實現這一點:

local wibox = require("wibox")
local awful = require("awful")

local temprature = wibox.widget {
    widget = awful.widget.watch('bash -c "sensors | grep CPU |     awk \'{print $2}\' | se
d \'s/C/C   /\'"', 5),
}

local temprature_clr = wibox.widget.background()
temprature_clr:set_widget(temprature)
temprature_clr:set_fg("#e5a75b")

return temprature_clr

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM