Make a few changes to the status bar and modules

This commit is contained in:
speedie 2022-11-26 19:16:22 +01:00
parent de29e5f09b
commit 0fcdf896b6
14 changed files with 72 additions and 70 deletions

View file

@ -73,6 +73,7 @@ PRINT() {
# argument 1
case "$ARG1" in
"") CLICK ;;
"--print") PRINT > /tmp/module_bat ;;
"--print-file") PRINT > /tmp/module_bat ;;
"--print") PRINT ;;
"--click") CLICK ;;
esac

View file

@ -61,8 +61,7 @@ PRINT() {
MONTH="$(date +%m)"
YEAR="$(date +%Y)"
echo "$ITEM3_SEPARATOR $ITEM3_ICON $ITEM3_FORMAT" | sed "s|@d|$DAY|; s|@m|$MONTH|; s|@y|$YEAR|"
echo "$ITEM3_APPEND"
echo "$ITEM3_SEPARATOR $ITEM3_ICON $ITEM3_FORMAT$ITEM3_APPEND" | sed "s|@d|$DAY|; s|@m|$MONTH|; s|@y|$YEAR|"
fi
fi
}
@ -84,6 +83,7 @@ RCAL() {
# argument 1
case "$ARG1" in
"") CLICK ;;
"--print") PRINT > /tmp/module_date ;;
"--print-file") PRINT > /tmp/module_date ;;
"--print") PRINT ;;
"--click") CLICK ;;
esac

View file

@ -71,16 +71,15 @@ PRINT() {
# Check if we're recording with dfmpeg or not
if [ "$ENABLE_ITEM7" = "true" ]; then
if [ -e "/tmp/dfmpeg-recording" ]; then
echo "$ITEM7_SEPARATOR $ITEM7_ICON $ITEM7_RECORDING_TEXT"
echo "$ITEM7_SEPARATOR $ITEM7_ICON $ITEM7_RECORDING_TEXT$ITEM7_APPEND"
fi
echo "$ITEM7_APPEND"
fi
}
# argument 1
case "$ARG1" in
"") CLICK ;;
"--print") PRINT > /tmp/module_dfmpeg ;;
"--print-file") PRINT > /tmp/module_dfmpeg ;;
"--print") PRINT ;;
"--click") CLICK ;;
esac

View file

@ -226,10 +226,8 @@ PRINT() {
# actually print it
if [ "$data" != "" ]; then
echo "$ITEM9_SEPARATOR $ITEM9_ICON $data"
echo "$ITEM9_SEPARATOR $ITEM9_ICON $data$ITEM9_APPEND"
fi
echo "$ITEM9_APPEND"
fi
fi
fi
@ -239,7 +237,7 @@ PRINT() {
# argument 1
case "$ARG1" in
"") CLICK ;;
"--print") PRINT > /tmp/module_music ;;
"--print-raw") PRINT ;;
"--print-file") PRINT > /tmp/module_music ;;
"--print") PRINT ;;
"--click") CLICK ;;
esac

View file

@ -67,8 +67,7 @@ PRINT() {
NETWORK_TRANSMITTED="$(cat /tmp/module_net_tx)"
NETWORK_RECEIVED="$(cat /tmp/module_net_rx)"
echo "$ITEM6_SEPARATOR $ITEM6_ICON $ITEM6_FORMAT" | sed "s|@t|$NETWORK_TRANSMITTED|g; s|@r|$NETWORK_RECEIVED|g"
echo "$ITEM6_APPEND"
echo "$ITEM6_SEPARATOR $ITEM6_ICON $ITEM6_FORMAT$ITEM6_APPEND" | sed "s|@t|$NETWORK_TRANSMITTED|g; s|@r|$NETWORK_RECEIVED|g"
fi
fi
}
@ -76,7 +75,8 @@ PRINT() {
# argument 1
case "$ARG1" in
"") CLICK ;;
"--print") PRINT > /tmp/module_net ;;
"--print-file") PRINT > /tmp/module_net ;;
"--print") PRINT ;;
"--click") CLICK ;;
esac

View file

@ -57,8 +57,7 @@ PRINT() {
newscount="$(newsboat -x print-unread | awk '{ print $1 }')"
if [ "$newscount" != "Error:" ]; then
echo "$ITEM10_SEPARATOR $ITEM10_ICON $newscount $ITEM10_TEXT"
echo "$ITEM10_APPEND"
echo "$ITEM10_SEPARATOR $ITEM10_ICON $newscount $ITEM10_TEXT$ITEM10_APPEND"
fi
fi
fi
@ -67,6 +66,7 @@ PRINT() {
# argument 1
case "$ARG1" in
"") CLICK ;;
"--print") PRINT > /tmp/module_news ;;
"--print-file") PRINT > /tmp/module_news ;;
"--print") PRINT ;;
"--click") CLICK ;;
esac

View file

@ -60,10 +60,8 @@ PRINT() {
fi
if [ -e "${BINDIR}free" ]; then
echo "$ITEM1_SEPARATOR $ITEM1_ICON $ITEM1_FORMAT" | sed "s|@u|$USEDRAM|; s|@t|$TOTALRAM|"
echo "$ITEM1_SEPARATOR $ITEM1_ICON $ITEM1_FORMAT$ITEM1_APPEND" | sed "s|@u|$USEDRAM|; s|@t|$TOTALRAM|"
fi
echo "$ITEM1_APPEND"
fi
}
@ -71,6 +69,7 @@ PRINT() {
# argument 1
case "$ARG1" in
"") CLICK ;;
"--print") PRINT > /tmp/module_ram ;;
"--print-file") PRINT > /tmp/module_ram ;;
"--print") PRINT ;;
"--click") CLICK ;;
esac

View file

@ -62,8 +62,7 @@ PRINT() {
else
sensors | grep temp1 | awk '{ print $2 }' | grep -q "F" && echo "$ITEM8_SEPARATOR $ITEM8_ICON $(sensors -f | grep temp1 | awk '{ print $2 }')"
fi
echo "$ITEM8_APPEND"
[ -z "$ITEM8_APPEND" ] || printf "$ITEM8_APPEND\n"
fi
fi
}
@ -71,10 +70,9 @@ PRINT() {
# argument 1
case "$ARG1" in
"") CLICK ;;
"--print") PRINT > /tmp/module_temp ;;
"--print-file") PRINT > /tmp/module_temp ;;
"--print") PRINT ;;
"--click") CLICK ;;
esac
if [ "$(cat /tmp/module_temp | wc -c)" -lt "6" ]; then
rm -f /tmp/module_temp
fi
[ -e "/tmp/module_temp" ] && [ "$(cat /tmp/module_temp | wc -c)" -lt "6" ] && rm -f /tmp/module_temp

View file

@ -51,8 +51,7 @@ PRINT() {
HOURS="$(date +%H)"
MINUTES="$(date +%M)"
SECONDS="$(date +%S)"
echo "$ITEM2_SEPARATOR $ITEM2_ICON $ITEM2_FORMAT" | sed "s|@h|$HOURS|; s|@m|$MINUTES|; s|@s|$SECONDS|"
echo "$ITEM2_APPEND"
echo "$ITEM2_SEPARATOR $ITEM2_ICON $ITEM2_FORMAT$ITEM2_APPEND" | sed "s|@h|$HOURS|; s|@m|$MINUTES|; s|@s|$SECONDS|"
fi
fi
}
@ -60,6 +59,7 @@ PRINT() {
# argument 1
case "$ARG1" in
"") CLICK ;;
"--print") PRINT > /tmp/module_time ;;
"--print-file") PRINT > /tmp/module_time ;;
"--print") PRINT ;;
"--click") CLICK ;;
esac

View file

@ -54,7 +54,7 @@ PRINT() {
echo "$ITEM4_SEPARATOR $ITEM4_ICON $(echo $(amixer -c 0 get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/")%)"
fi
echo "$ITEM4_APPEND"
[ -z "$ITEM4_APPEND" ] || echo "$ITEM4_APPEND"
fi
# get mute
@ -68,6 +68,7 @@ PRINT() {
# argument 1
case "$ARG1" in
"") CLICK ;;
"--print") PRINT > /tmp/module_vol ;;
"--print-file") PRINT > /tmp/module_vol ;;
"--print") PRINT ;;
"--click") CLICK ;;
esac

View file

@ -70,7 +70,7 @@ PRINT() {
echo "$ITEM5_SEPARATOR $ITEM5_ICON $(cat /tmp/wstatus)"
fi
echo "$ITEM5_APPEND"
[ -z "$ITEM5_APPEND" ] || echo "$ITEM5_APPEND"
else
curl -so /tmp/itest wttr.in && hasinternet=true
@ -87,6 +87,7 @@ PRINT() {
# argument 1
case "$ARG1" in
"") CLICK ;;
"--print") PRINT > /tmp/module_weather ;;
"--print-file") PRINT > /tmp/module_weather ;;
"--print") PRINT ;;
"--click") CLICK ;;
esac

View file

@ -346,7 +346,7 @@ esac
# RAM usage
ITEM1() {
module_ram --print
module_ram --print-file
if [ -e "/tmp/module_ram" ]; then
cat /tmp/module_ram
@ -355,7 +355,7 @@ ITEM1() {
# Time
ITEM2() {
module_time --print
module_time --print-file
if [ -e "/tmp/module_time" ]; then
cat /tmp/module_time
@ -364,7 +364,7 @@ ITEM2() {
# Date
ITEM3() {
module_date --print
module_date --print-file
if [ -e "/tmp/module_date" ]; then
cat /tmp/module_date
@ -373,7 +373,7 @@ ITEM3() {
# Volume
ITEM4() {
module_vol --print
module_vol --print-file
if [ -e "/tmp/module_vol" ]; then
cat /tmp/module_vol
@ -382,7 +382,7 @@ ITEM4() {
# Weather
ITEM5() {
module_weather --print
module_weather --print-file
if [ -e "/tmp/module_weather" ]; then
cat /tmp/module_weather
@ -391,7 +391,7 @@ ITEM5() {
# Network traffic
ITEM6() {
module_net --print
module_net --print-file
if [ -e "/tmp/module_net" ]; then
cat /tmp/module_net
@ -400,7 +400,7 @@ ITEM6() {
# Dfmpeg status
ITEM7() {
module_dfmpeg --print
module_dfmpeg --print-file
if [ -e "/tmp/module_dfmpeg" ]; then
cat /tmp/module_dfmpeg
@ -409,7 +409,7 @@ ITEM7() {
# CPU temp
ITEM8() {
module_temp --print
module_temp --print-file
if [ -e "/tmp/module_temp" ]; then
cat /tmp/module_temp
@ -418,7 +418,7 @@ ITEM8() {
# mocp/cmus status
ITEM9() {
module_music --print
module_music --print-file
if [ -e "/tmp/module_music" ]; then
cat /tmp/module_music
@ -427,7 +427,7 @@ ITEM9() {
# Newsboat unreads
ITEM10() {
module_news --print
module_news --print-file
if [ -e "/tmp/module_news" ]; then
cat /tmp/module_news
@ -436,7 +436,7 @@ ITEM10() {
# Battery percentage/charging status
ITEM11() {
module_bat --print
module_bat --print-file
if [ -e "/tmp/module_bat" ]; then
cat /tmp/module_bat

View file

@ -5950,6 +5950,7 @@ spawn(const Arg *arg)
if (statuscmdn == statuscmds[i].id) {
statuscmd[2] = statuscmds[i].cmd;
setenv("BUTTON", lastbutton, 1);
system("rm -f /tmp/speedwm-button");
int writestatus = fputs(lastbutton, buttonfile);
if (writestatus == EOF) {
fprintf(stderr, "speedwm: failed to write statuscmd button.\n");
@ -6764,21 +6765,23 @@ updatestatus(void)
statusw = TEXTWM(stext) - lrpad + 2;
} else {
if (!selmon->hidestatus) {
copyvalidchars(stext, rawstext);
char *text, *s, ch;
statusw = 0;
for (text = s = stext; *s; s++) {
if ((unsigned char)(*s) < ' ') {
ch = *s;
*s = '\0';
statusw += TEXTWM(text) - lrpad;
*s = ch;
text = s + 1;
}
}
statusw += TEXTWM(text) - lrpad + 2;
}
copyvalidchars(stext, rawstext);
char *text, *s, ch;
statusw = 0;
for (text = s = stext; *s; s++) {
if ((unsigned char)(*s) < ' ') {
ch = *s;
*s = '\0';
statusw += TEXTWM(text) - lrpad;
*s = ch;
text = s + 1;
}
}
statusw += TEXTWM(text) - lrpad + 2;
}
}
if (statusallmons) {
for(m = mons; m; m = m->next)
drawbaritems(m);

View file

@ -20,13 +20,15 @@
*
*/
static const StatusCmd statuscmds[] = {
{ "module_ram --click", 1 },
{ "module_time --click", 2 },
{ "module_date --click", 3 },
{ "module_vol --click", 4 },
{ "module_weather --click", 5 },
{ "module_net --click", 6 },
{ "module_dfmpeg --click", 7 },
{ "module_temp --click", 8 },
{ "module_music --click", 9 },
{ "module_time --click", 1 },
{ "module_date --click", 2 },
{ "module_bat --click", 3 },
{ "module_vol --click", 4 },
{ "module_ram --click", 5 },
{ "module_net --click", 6 },
{ "module_temp --click", 7 },
{ "module_weather --click", 8 },
{ "module_music --click", 9 },
{ "module_dfmpeg --click", 10 },
{ "module_news --click", 11 },
};