381 lines
8.9 KiB
Bash
Executable File
381 lines
8.9 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
|
|
# Colors
|
|
|
|
#_orange="%{F#FF9E00}"
|
|
#_green="%{F#00FF00}"
|
|
#_cyan="%{F#00F0FF}"
|
|
#_pink="%{F#FF00B6}"
|
|
#_red="%{F#FF0000}"
|
|
#_blue="%{F#002EFF}"
|
|
#_purple="%{F#7C00FF}"
|
|
#_yellow="%{F#FFF000}"
|
|
|
|
# Functions
|
|
|
|
## Define OS version
|
|
_os_type(){
|
|
|
|
_net="$(ifconfig trunk0 | grep active | head -1 | awk '{print $1}')"
|
|
|
|
case $_net in
|
|
"em0") _os="OpenBSD $(sysctl -n kern.osrelease) $(sysctl -n kern.osversion)" ;;
|
|
"iwn0") _os="$(sysctl -n kern.osrelease) $(sysctl -n kern.osversion)" ;;
|
|
esac
|
|
|
|
echo "${_os}"
|
|
|
|
}
|
|
|
|
## Thelemic date
|
|
_thelemic_date(){
|
|
|
|
# Vars
|
|
_dayw=$(date "+%a") ## Day of the week
|
|
_daym=$(date "+%d") ## Day of the mounth
|
|
_mounth=$(date "+%m") ## Mounth number
|
|
_year=$(date "+%Y") ## Current year
|
|
_year_zero="1904"
|
|
_year_diff="$(echo "${_year} - ${_year_zero}" | bc)"
|
|
_year_cicles="$(echo "scale=0; ${_year_diff} / 22" | bc)"
|
|
_year_cur_cicle="$(echo "${_year_diff} - (${_year_cicles} * 22)" | bc)"
|
|
#_zone="-z -3" ## Time zone
|
|
_lat="-20.351034"
|
|
_log="-40.284485"
|
|
#_coord="-zl ${_log} ${_lat}"
|
|
_sun="$(astrolog -n ${_zone} ${_coord} | head -4 | tail -1 | awk '{print $3}' | sed 's/[0-9]//g')"
|
|
_sun_pos="$(astrolog -n ${_zone} ${_coord} | head -4 | tail -1 | awk '{print $3}' | ghead -c 2 | sed 's/[A-Z]//')"
|
|
_moon="$(astrolog -n ${_zone} ${_coord} | head -5 | tail -1 | awk '{print $2}' | sed 's/[0-9]//g')"
|
|
_moon_pos="$(astrolog -n ${_zone} ${_coord} | head -5 | tail -1 | awk '{print $2}' | ghead -c 2 | sed 's/[A-Z]//')"
|
|
_net="$(ifconfig trunk0 | grep active | head -1 | awk '{print $1}')"
|
|
|
|
case $_sun in
|
|
"Aqu") _sun_done="Aquarii";;
|
|
"Gem") _sun_done="Geminorum";;
|
|
"Sag") _sun_done="Sagittarii";;
|
|
"Tau") _sun_done="Tauri";;
|
|
"Ari") _sun_done="Arietis";;
|
|
"Pis") _sun_done="Piscis";;
|
|
"Cap") _sun_done="Capricorni";;
|
|
"Can") _sun_done="Cancri";;
|
|
"Sco") _sun_done="Scorpii";;
|
|
"Lib") _sun_done="Librae";;
|
|
"Leo") _sun_done="Leonis";;
|
|
"Vir") _sun_done="Virginis";;
|
|
esac
|
|
|
|
case $_moon in
|
|
"Aqu") _moon_done="Aquarii";;
|
|
"Gem") _moon_done="Geminorum";;
|
|
"Sag") _moon_done="Sagittarii";;
|
|
"Tau") _moon_done="Tauri";;
|
|
"Ari") _moon_done="Arietis";;
|
|
"Pis") _moon_done="Piscis";;
|
|
"Cap") _moon_done="Capricorni";;
|
|
"Can") _moon_done="Cancri";;
|
|
"Sco") _moon_done="Scorpii";;
|
|
"Lib") _moon_done="Librae";;
|
|
"Leo") _moon_done="Leonis";;
|
|
"Vir") _moon_done="Virginis";;
|
|
esac
|
|
|
|
case $_dayw in
|
|
"Sun") _dayw_done="Solis";;
|
|
"Mon") _dayw_done="Lunae";;
|
|
"Tue") _dayw_done="Martis";;
|
|
"Wed") _dayw_done="Mercurii";;
|
|
"Thu") _dayw_done="Jovis";;
|
|
"Fri") _dayw_done="Veneris";;
|
|
"Sat") _dayw_done="Saturnis";;
|
|
esac
|
|
|
|
case $_net in
|
|
"em0") _date="Sol in ${_sun_pos}° ${_sun_done} : Luna in ${_moon_pos}° ${_moon_done} : Dies ${_dayw_done} : Anno Vviii e.l." ;;
|
|
"iwn0") _date="Sol in ${_sun_pos}° ${_sun_done} Luna in ${_moon_pos}° ${_moon_done} Dies ${_dayw_done} Anno Vviii e.l." ;;
|
|
esac
|
|
|
|
# Main function
|
|
echo "$_date"
|
|
|
|
# echo "
|
|
# ☉︎ in ${_sun_pos}° ${_sun_done}
|
|
# ☽︎ in ${_moon_pos}° ${_moon_done}
|
|
# Dies ${_dayw_done}
|
|
# Anno V:viii a.n.
|
|
#"
|
|
}
|
|
|
|
## Show current group
|
|
_grp(){
|
|
|
|
_cur_grp="$(xprop -root _NET_CURRENT_DESKTOP | awk -F '=' '{print $2}' | sed 's/ //')"
|
|
|
|
echo "${_orange}Grp: ${_green}${_cur_grp}"
|
|
|
|
}
|
|
|
|
## Show memory usage
|
|
_mem(){
|
|
|
|
_smt="$(sysctl -n hw.smt)"
|
|
|
|
### Define number of threads
|
|
if [ "$_smt" = "0" ]; then
|
|
|
|
_h="7"
|
|
|
|
elif [ "$_smt" = "1" ]; then
|
|
|
|
_h="11"
|
|
|
|
fi
|
|
|
|
### Get memory usage
|
|
_mem_use="$(top -d1 | \
|
|
head -n ${_h} | \
|
|
tail -1 | \
|
|
awk '{print $3}' | \
|
|
awk -F / '{print $1}' | \
|
|
sed s/M//)"
|
|
|
|
_b=999
|
|
|
|
### Build the output
|
|
if [ "$_mem_use" -ge "$_b" ]; then
|
|
echo "${_cyan}: ${_green}$(echo "scale=2; $_mem_use / 1024" | bc)G/16G"
|
|
else
|
|
echo "${_cyan}: ${_green}0$(echo "scale=2; $_mem_use / 1024" | bc)G/16G"
|
|
fi
|
|
|
|
}
|
|
|
|
## Define cpu clock rate
|
|
_cpu_clock(){
|
|
|
|
_CSPEED="$(sysctl -n hw.cpuspeed)"
|
|
|
|
_CP="$(echo "scale=2; $_CSPEED / 1024" | bc)"
|
|
|
|
echo "${_orange}CPU: ${_green}${_CP}Ghz"
|
|
|
|
}
|
|
|
|
## Get hardware temperatures
|
|
_temp(){
|
|
|
|
### Some limits
|
|
y=60
|
|
r=70
|
|
|
|
### Get cpu temp
|
|
_cpu_temp="$(sysctl -n hw.sensors.cpu0.temp0 | awk '{print $1}' | awk -F '.' '{print $1}')"
|
|
### Get acpitz temp
|
|
_acpitz_temp="$(sysctl -n hw.sensors.acpitz0.temp0 | awk '{print $1}' | awk -F '.' '{print $1}')"
|
|
### Correct bug temperature
|
|
_temp_c="$(echo "scale=0; $_cpu_temp - 15" | bc)"
|
|
_temp_a="$(echo "scale=0; $_acpitz_temp - 15" | bc)"
|
|
|
|
### Some color acording to temperature
|
|
if [ "$_temp_c" -ge "$r" ]; then
|
|
_tempc="${_red}${_cpu_temp}ºC"
|
|
elif [ "$_temp_c" -ge "$y" ]; then
|
|
_tempc="%{F#FFF000}${_temp_c}ºC"
|
|
else
|
|
_tempc="${_green}${_temp_c}ºC"
|
|
fi
|
|
|
|
if [ "$_temp_a" -ge "$r" ]; then
|
|
_tempa="${_red}${_temp_a}ºC"
|
|
elif [ "$_temp_a" -ge "$y" ]; then
|
|
_tempa="%{F#FFF000}${_temp_a}ºC"
|
|
else
|
|
_tempa="${_green}${_temp_a}ºC"
|
|
fi
|
|
|
|
### Build output
|
|
echo "${_pink}CPU: ${_tempc} ${_purple}ACPITZ: ${_tempa}"
|
|
}
|
|
|
|
_fan_speed(){
|
|
|
|
_fspeed="$(sysctl -n hw.sensors.acpithinkpad0.fan0 | awk '{print $1}')"
|
|
|
|
_fp="$(echo "scale=2; $_fspeed / 1024" | bc)"
|
|
|
|
echo -e "${_yellow}FAN: ${_green}${_fp}kRPM"
|
|
|
|
}
|
|
|
|
_smt_func(){
|
|
|
|
_smt="$(sysctl -n hw.smt)"
|
|
|
|
echo "${_orange}SMT: ${_green}${_smt}"
|
|
|
|
}
|
|
|
|
_sec(){
|
|
|
|
_sec_lvl="$(sysctl -n kern.securelevel)"
|
|
|
|
if [ $_sec_lvl = "1" ]; then
|
|
|
|
_result="${_green}$_sec_lvl"
|
|
|
|
elif [ $_sec_lvl = "2" ]; then
|
|
|
|
_result="${_orange}$_sec_lvl"
|
|
|
|
else
|
|
|
|
_result="${_red}ERROR!"
|
|
|
|
fi
|
|
|
|
echo "${_red}Sec_lvl= $_result"
|
|
|
|
}
|
|
|
|
## PF Status
|
|
_pf(){
|
|
|
|
_pf_status="$(rcctl get pf | sed 's/pf=//')"
|
|
|
|
case "$_pf_status" in
|
|
"YES") echo "${_pink}PF: ${_green}ON";;
|
|
"NO") echo "${_pink}PF: ${_red}OFF";;
|
|
esac
|
|
|
|
}
|
|
|
|
_rec(){
|
|
|
|
_audio="$(sysctl -n kern.audio.record)"
|
|
_video="$(sysctl -n kern.video.record)"
|
|
|
|
if [ $_audio = 0 ]; then
|
|
_audio_color="${_green}$_audio"
|
|
else
|
|
_audio_color="${_orange}$_audio"
|
|
fi
|
|
|
|
if [ $_video = 0 ]; then
|
|
_video_color="${_green}$_video"
|
|
else
|
|
_video_color="${_orange}$_video"
|
|
fi
|
|
|
|
echo "${_blue}Video: $_video_color ${_purple}Audio: $_audio_color"
|
|
|
|
}
|
|
|
|
_network(){
|
|
|
|
_net="$(ifconfig trunk0 | grep active | head -1 | awk '{print $1}')"
|
|
_iplocal="$(ifconfig trunk0 | tail -1 | awk '{print $2}')"
|
|
_wifiname="$(ifconfig iwn0 | tail -1 | awk '{print $3}')"
|
|
_wifistr="$(ifconfig iwn0 | tail -1 | awk '{print $8}' | sed 's/dBm//')"
|
|
|
|
|
|
if [ "$_wifistr" -ge -45 ]; then
|
|
_wifistr_color="${_green}${_wifistr}dbm"
|
|
elif [ "$_wifistr" -lt -45 ] && [ "$_wifistr" -ge -60 ]; then
|
|
_wifistr_color="${_orange}${_wifistr}dbm"
|
|
elif [ "$_wifistr" -lt -60 ]; then
|
|
_wifistr_color="${_red}${_wifistr}dbm"
|
|
fi
|
|
|
|
if [ "$_net" = "em0" ]; then
|
|
|
|
echo "${_cyan}${_net}: ${_green}${_iplocal}"
|
|
|
|
elif [ "$_net" = "iwn0" ]; then
|
|
|
|
echo "${_cyan}${_wifiname}: ${_green}${_iplocal} ${_wifistr_color}"
|
|
else
|
|
echo "No network!"
|
|
fi
|
|
|
|
}
|
|
|
|
_mail(){
|
|
|
|
_mail_count="$(grep '^To:' /var/mail/b2r1s8 | wc -l | sed 's/ //g')"
|
|
|
|
case $_mail_count in
|
|
"0") echo ":${_mail_count}";;
|
|
*) echo ":${_mail_count}";;
|
|
esac
|
|
|
|
}
|
|
|
|
_sound(){
|
|
|
|
_vol="$(sndioctl -n output.level)"
|
|
_vol_done="$(echo "scale=0; $_vol * 100" | bc | awk -F'[.=]' '{print $1}')%"
|
|
|
|
echo "${_pink}Sound: ${_green}${_vol_done}"
|
|
|
|
}
|
|
|
|
_batt(){
|
|
|
|
_full="$(sysctl -n hw.sensors.acpibat0.watthour0 | awk '{print $1}')"
|
|
|
|
_real="$(sysctl -n hw.sensors.acpibat0.watthour3 | awk '{print $1}')"
|
|
|
|
_percent="$(echo "scale=2; ${_real} / ${_full} * 100" | bc | awk -F '.' '{print $1}')"
|
|
_state="$(sysctl -n hw.sensors.acpibat0.raw0 | awk '{print $3}' | sed s/\)\,//)"
|
|
|
|
case $_state in
|
|
"discharging") _states="dis" ;;
|
|
"charging") _states="cha" ;;
|
|
"idle") _states="idl" ;;
|
|
"full") _states="ful" ;;
|
|
esac
|
|
|
|
_y=50
|
|
_r=30
|
|
|
|
if [ "$_percent" -ge "$_y" ]; then
|
|
_percent_color="${_green}${_percent}%"
|
|
elif [ "$_percent" -ge "$_r" ]; then
|
|
_percent_color="${_yellow}${_percent}%"
|
|
else
|
|
_percent_color="${_red}${_percent}%"
|
|
fi
|
|
|
|
echo "${_orange}${_states}: ${_percent_color}"
|
|
|
|
}
|
|
|
|
_clock(){
|
|
|
|
_net="$(ifconfig trunk0 | grep active | head -1 | awk '{print $1}')"
|
|
_day="$()"
|
|
|
|
case $_net in
|
|
"em0") _date=$(date "+%a %Y-%m-%d e.v. %H:%M:%S") ;;
|
|
"iwn0") _date=$(date "+%Y-%m-%d e.v. %H:%M:%S") ;;
|
|
*) _date=$(date "+%a %Y-%m-%d e.v. %H:%M:%S") ;;
|
|
esac
|
|
|
|
echo -n "$_date"
|
|
|
|
}
|
|
|
|
#$(_os_type) \
|
|
#$(_smt_func) \
|
|
#$(_sec) \
|
|
#$(_pf) \
|
|
#$(_rec) \
|
|
#$(_temp) \
|
|
#$(_fan_speed) \
|
|
#$(_thelemic_date) \
|
|
|
|
while true; do
|
|
echo " \
|
|
$(_grp) $(_mem) $(_network) $(_mail) $(_sound) $(_batt) $(_clock) "
|
|
sleep 1
|
|
done
|