You are not logged in.
Pages: 1
I have an arch setup on my laptop, with xmonad as the window manager and xmobar as the bar. I want to monitor the fan speed, so that the output changes color on the bar, depending on the rpm value. I tried to do it like this:
#! /bin/bash
fan1=3000
fan2=4000
fan=$(sensors | grep -i fan | awk '{print $2}')
fan=${fan%???}
if [ "$fan" -ge "$fan2" ] ; then
echo "<fc=#C1514E>$fan RPM</fc>"
elif [ "$fan" -ge "$fan1" ] ; then
echo "<fc=#C1A24E>$fan RPM</fc>"
else
echo "<fc=#AAC0F0>$fan RPM</fc>"
fiWhen I run this in the terminal, I get
3143 RPMbut $
3 RPM displayed on the bar. My xombar config is
-- Xmobar (http://projects.haskell.org/xmobar/)
-- Color scheme: Solarized Dark
-- Dependencies:
-- otf-font-awesome
-- ttf-mononoki
-- ttf-ubuntu-font-family
-- htop
-- emacs
-- pacman (Arch Linux)
-- trayer
-- 'dtos-local-bin' (from dtos-core-repo)
Config { font = "xft:Ubuntu:weight=bold:pixelsize=20:antialias=true:hinting=true, Font Awesome 6 Free-Solid:style=solid: pixelsize=20, Font Awesome 6 Brands:pixelsize=18, Font Awesome 5 Free-Solid:style=solid:pixelsize=16"
, additionalFonts = [ "xft:Mononoki:pixelsize=11:antialias=true:hinting=true"
, "xft:Font Awesome 6 Free Solid:pixelsize=18"
, "xft:Font Awesome 6 Brands:pixelsize=18"
]
, bgColor = "#002b36"
, fgColor = "#839496"
, alpha = 0
, border = NoBorder
, borderWidth = 0
-- Position TopSize and BottomSize take 3 arguments:
-- an alignment parameter (L/R/C) for Left, Right or Center.
-- an integer for the percentage width, so 100 would be 100%.
-- an integer for the minimum pixel height for xmobar, so 24 would force a height of at least 24 pixels.
-- NOTE: The height should be the same as the trayer (system tray) height.
, position = TopSize L 100 24
, lowerOnStart = True
, hideOnStart = False
, allDesktops = True
, persistent = True
, iconRoot = ".xmonad/xpm/" -- default: "."
, commands = [
-- Echos a "penguin" icon in front of the kernel output.
-- Run Com "echo" ["<fn=3>\xf17c</fn>"] "penguin" 3600
-- Get kernel version (script found in .local/bin)
-- , Run Com ".local/bin/kernel" [] "kernel" 36000
-- Cpu usage in percent
-- , Run Cpu ["-t", "<fn=2>\xf108</fn> cpu: (<total>%)","-H","50","--high","red"] 20
-- Ram used number and percent
-- , Run Memory ["-t", "<fn=2>\xf233</fn> mem: <used>M (<usedratio>%)"] 20
-- Disk space free
-- , Run DiskU [("/", "<fn=2>\xf0c7</fn> hdd: <free> free")] [] 60
-- Echos up arrow in front of temperature
Run Com "echo" ["<fn=2><\xf108></fn>"] "uparrow" 3600
-- CPU temperature
,Run Com ".local/bin/temp" [] "temp" 100
-- ,Run Com "echo" ["<fn=2><\xf108></fn>"] "uparrow" 3600
-- Fan speed
,Run Com ".local/bin/fan" [] "fan" 100
-- Echos an "up arrow" icon in front of the uptime output.
-- , Run Com "echo" ["<fn=2>\xf0aa</fn>"] "uparrow" 3600
-- -- Uptime
-- , Run Uptime ["-t", "uptime: <days>d <hours>h"] 360
-- Echos a "bell" icon in front of the pacman updates.
, Run Com "echo" ["<fn=2>\xf0f3</fn>"] "bell" 3600
-- Check for pacman updates (script found in .local/bin)
, Run Com ".local/bin/pacupdate" [] "pacupdate" 50
-- Echos a "battery" icon in front of the pacman updates.
, Run Com "echo" ["<fn=2>\xf242</fn>"] "baticon" 3600
-- Battery
, Run BatteryP ["BAT0"] ["-t", "<acstatus><watts> (<left>%)"] 360
-- Time and date
, Run Date " %A, %B %d, %Y %H:%M " "date" 50
-- Script that dynamically adjusts xmobar padding depending on number of trayer icons.
, Run Com ".config/xmobar/trayer-padding-icon.sh" [] "trayerpad" 20
-- Prints out the left side items such as workspaces, layout, etc.
, Run UnsafeStdinReader
]
, sepChar = "%"
, alignSep = "}{"
, template = "%UnsafeStdinReader% }{ <fc=#da8548>%uparrow% %temp%</fc><fc=#da8548>%% %fan%</fc><fc=#c678dd> %bell% <action=`alacritty -e sudo pacman -Syu`>%pacupdate%</action></fc> <fc=#da8548>%baticon% %battery%</fc> <fc=#46d9ff><action=`emacsclient -c -a 'emacs' --eval '(doom/window-maximize-buffer(dt/year-calendar))'`>%date%</action></fc> %trayerpad%"
} How can I fix this?
Last edited by Gabachin (2022-10-25 22:09:16)
Offline
What is the output of sensors? Do you only have one fan? Why are you deliberately chopping three digits off the value with "fan=${fan%???}"?
As for what you say the output is when run from the terminal, that just doesn't add up. Where are the color codes?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
It turns out that I read the wrong line in the sensors command output, and so originally clipped the decimals that appeared there to the thousandth place. Once I fixed this, the script rendered as expected. In the terminal it gives
}%{F#ffa500} 3903 RPMand on the bar
3903 RPMSo I will mark this post as fixed since I do not see any way to delete it.
Last edited by Gabachin (2022-10-25 22:06:58)
Offline
Pages: 1