Configuration_Files/misc/bar.es

64 lines
2.0 KiB
JavaScript
Executable File

#!/bin/es
fn interval{
n=`{date|sed -ne 's^.*[0-9][0-9]:[0-9][0-9]:\([0-9][0-9]\).*^\1^p'}
sleep `{expr - 60 `{expr % $n 60}}
}
# Display Time using 24h notation.
fn clock{
date|sed -ne 's^.*\([0-9][0-9]\):\([0-9][0-9]\):[0-9][0-9].*^\1\2^p'
}
# Acquire the name of the current machine's primary interface.
fn iface_get{
if{~ $HOSTNAME speculatores}
{printf wlp2s0}\
{printf eno1}
}
# Acquire the IP of the current connection. Needs to be made portable.
fn ip{
x=`{ifconfig wlp2s0|sed -ne 's^.*addr:\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*^\1^p'}
if{~ `{route|sed 3!d|cut -b1-7} 'default'}
{if {!~ $x ''}
{printf %s $x}\
{printf %s 'G/W'}
}\
{printf N/A}
}
# Display the current battery capacity and status
fn pwr{
if{~ `{cat /sys/class/power_supply/BAT1/status} 'Discharging'}\
{printf --%s%% `{cat /sys/class/power_supply/BAT1/capacity}}\
{printf ++%s%% `{cat /sys/class/power_supply/BAT1/capacity}}
}
fn tmp_helper{
snarf 'http://wttr.in/?format=3' -|sed -ne \
's^.*\(.[0-9][0-9]*.C\)^\1^p' > $FXDE_DIR/fxde-core/info/temp
touch $FXDE_DIR/fxde-core/info/timepiece
}
fn tmp{
ival=120
# If we've rolled over into a second minute and timepiece does not exist...
if {`{expr % `{expr - $ival `{expr \* `{date|cut -d':' -f2} 60}} 60}&&\
! test -e $FXDE_DIR/fxde-core/info/timepiece}
{printf UPD
tmp_helper}\
{test -e $FXDE_DIR/fxde-core/info/timepiece && ! `{expr % `{expr - 120 `{expr \* `{date|cut -d':' -f2} 60}} 1200}}
{rm $FXDE_DIR/fxde-core/info/timepiece}\
{test -s $FXDE_DIR/fxde-core/info/temp}
{cat $FXDE_DIR/fxde-core/info/temp}\
{printf CND}
}
fn curdesk iter {if{~ $wm shod}{if {~ `{lsd|sed $iter!d|cut -b1} '*'}{printf %i $iter}{curdesk `{expr + 1 $iter}}}{printf %s N/A}}
while {true}{
printf '%%{l}[ %s | %%{A:xcalendar:}%s%%{A} | %s | %s ]\n' `{pwr} `{clock} `{ip} `{curdesk 1}
sleep 1
}