speedwm-personal/status
2022-08-30 11:51:05 +02:00

778 lines
32 KiB
Bash
Executable file

#!/bin/sh
# Status bar for speedwm
# Written by speedie.gq in POSIX sh for https://speedie.gq/speedwm
# Licensed under the GNU GPLv3 free software license.
#
# NOTE: Anything in the DISPLAY function will be printed to your status bar.
# This means stdout will be printed regardless.
# You can output to /dev/null to silence most commands.
#
# Once you're done editing, run 'make clean install'.
#
# CONFIG
# This is the configuration for the status bar
#
# I highly recommend editing ~/.config/speedwm-de/status/config instead though
# All settings with the exception of changing the order of items can be
# changed there. Otherwise, carefully edit the file and recompile speedwm!
# General settings
USEWAL=true # Use Pywal if possible (true/false)
RUNONCE=false # Only run status bar once (true/false)
SLEEPTIME=7 # How long delay in seconds between each reload (int)
DATEBINDIR="/bin/" # Directory where your 'date' binary is. Default should be fine for most people
SETMETHOD="xsetroot -name" # Method used to set the status bar
SEP="<" # Separator to use. Alternative separators: "❰", "<", "|"
COLORFG=true # Color foreground (true/false)
COLORBG=false # Color background (true/false)
USEBUILTINCOL=false # Use built in speedwm colors (col_status<num>). This also supports Pywal. (true/false)
# Status bar modules
# Set to true/false to enable/disable.
# Keep in mind, if the dependencies are not installed, then they will not be used regardless of what the option is set to.
ENABLE_ITEM1=true # Enable RAM usage (true/false)
ENABLE_ITEM2=true # Enable Time (HH:MM) (true/false)
ENABLE_ITEM3=true # Enable Date (DD/MM/YY) (true/false)
ENABLE_ITEM4=true # Enable Volume/Mute status (<perc>%) (true/false)
ENABLE_ITEM5=true # Enable Weather (true/false)
ENABLE_ITEM6=true # Enable Network Traffic (<num>B/s (true/false)
ENABLE_ITEM7=true # Enable dfmpeg status (true/false)
ENABLE_ITEM8=true # Enable CPU temp (true/false)
ENABLE_ITEM9=true # Enable music status (true/false)
ENABLE_ITEM10=false # Enable newsboat unread (true/false)
ENABLE_ITEM11=true # Enable battery percentage and charging status (true/false)
ENABLE_ITEM12=false # Enable #ff IRC backlog in status bar (true/false)
ITEM1_ICON=" " # Icon for ITEM1
ITEM2_ICON=" " # Icon for ITEM2
ITEM3_ICON=" " # Icon for ITEM3
ITEM4_ICON=" " # Icon for ITEM4
ITEM5_ICON=" " # Icon for ITEM5
ITEM6_ICON=" " # Icon for ITEM6
ITEM7_ICON=" " # Icon for ITEM7
ITEM8_ICON="糖" # Icon for ITEM8
ITEM9_ICON=" " # Icon for ITEM9
ITEM10_ICON=" " # Icon for ITEM10
ITEM11_ICON=" " # Icon for ITEM11
ITEM12_ICON=" " # Icon for ITEM12
ITEM9_BACKEND="auto" # Backend for the music status (cmus/mocp/auto)
ITEM9_DISPLAY_ARTIST="false" # Display artist or not (true/false)
ITEM9_DISPLAY_TITLE="false" # Display title or not (true/false)
ITEM9_DISPLAY_ALBUM="false" # Display album or not (true/false)
ITEM9_DISPLAY_GENRE="false" # Display genre or not (true/false)
ITEM9_DISPLAY_TIMEELAPSED="false" # Display time elapsed or not. If you use this, you will probably want the delay set pretty low. (true/false)
ITEM9_DISPLAY_TIMETOTAL="false" # Display total time or not (true/false_
ITEM9_DISPLAY_FILE="true" # Display filename or not. This option will disable everything else. Path and file extension will be cut. (true/false)
ITEM9_HIDE_EMPTY_ARTIST="true" # Hide empty artist (true/false)
ITEM9_HIDE_EMPTY_TITLE="true" # Hide empty title (true/false)
ITEM9_HIDE_EMPTY_ALBUM="true" # Hide empty album (true/false)
ITEM9_HIDE_EMPTY_GENRE="true" # Hide empty genre (true/false)
ITEM9_HIDE_EMPTY_FILE="true" # Hide empty file (true/false)
ITEM9_HIDE_EMPTY_TT="true" # Hide empty total time (true/false)
ITEM9_HIDE_EMPTY_TE="true" # Hide empty time elapsed (true/false)
ITEM9_PRE_FILE="" # Text to display before the filename
ITEM9_POST_FILE="" # Text to display after the filename
ITEM9_PRE_ARTIST="" # Text to display before the artist
ITEM9_POST_ARTIST="" # Text to display after the artist
ITEM9_PRE_TITLE="" # Text to display before the title
ITEM9_POST_TITLE="" # Text to display after the title
ITEM9_PRE_ALBUM="from " # Text to display before the album
ITEM9_POST_ALBUM="" # Text to display after the album
ITEM9_PRE_GENRE="(" # Text to display before the genre
ITEM9_POST_GENRE=")" # Text to display after the genre
ITEM9_PRE_TE="[" # Text to display before the time elapsed.
ITEM9_POST_TE=" /" # Text to display after the time elapsed.
ITEM9_PRE_TT=" " # Text to display before the total time.
ITEM9_POST_TT="]" # Text to display before the total time.
ITEM9_TT_TE_NO_SPACING="true" # No spacing between time elapsed and total time (true/false)
ITEM9_TE_REVERSE="true" # Reverse time elapsed (replace with time left) (true/false)
ITEM9_SEPARATOR="-" # Separator between ARTIST, TITLE and ALBUM
# Systray options
HIDE_STATUS_SYSTRAY=true # Hide the status when a systray is running (true/false)
SYSTRAY="trayer" # Systray to use (<systray executable>).
STATUS_WHEN_HIDDEN="" # Status to print when status is hidden (char)
# Order of colors and items in the status bar
PRINT() {
$SETMETHOD "\
$FSETCOLORCMD11\
$BSETCOLORCMD11\
$ITEMCMD2 \
$FSETCOLORCMD10\
$BSETCOLORCMD10\
$ITEMCMD3 \
$FSETCOLORCMD13\
$BSETCOLORCMD13\
$ITEMCMD11 \
$FSETCOLORCMD8\
$BSETCOLORCMD8\
$ITEMCMD4 \
$FSETCOLORCMD7\
$BSETCOLORCMD7\
$ITEMCMD1 \
$FSETCOLORCMD6\
$BSETCOLORCMD6\
$ITEMCMD6 \
$FSETCOLORCMD4\
$BSETCOLORCMD4\
$ITEMCMD8 \
$FSETCOLORCMD3\
$BSETCOLORCMD3\
$ITEMCMD5 \
$FSETCOLORCMD2\
$BSETCOLORCMD2\
$ITEMCMD9 \
$FSETCOLORCMD5\
$BSETCOLORCMD5\
$ITEMCMD7 \
$FSETCOLORCMD9\
$BSETCOLORCMD9\
$ITEMCMD10 \
$FSETCOLORCMD14\
$BSETCOLORCMD14\
$ITEMCMD12"
}
# Colors
####################################
# The colors under SETCOLORS will be used if Pywal is not enabled.
# Default colorscheme, for when pywal is not enabled or available.
# I recommend using Vim, vim-plugin and colorizer so that you can actually see the colors.
SETCOLORS() {
COLOR1=#131210
COLOR2=#bf616a
COLOR3=#A16F9D
COLOR4=#68ABAA
COLOR5=#A89F93
COLOR6=#D3A99B
COLOR7=#AFC9AC
COLOR8=#eae1cb
COLOR9=#a39d8e
COLOR10=#6D5E8E
COLOR11=#A16F9D
COLOR12=#D3A99B
COLOR13=#AFC9AC
COLOR14=#eae1cb
COLOR15=#6D5E8E
}
# Add colors to status2d compatible variable to use with xsetroot later.
SETCOLORS_CMD() {
if [ "$COLORFG" = "true" ]; then
FSETCOLORCMD1="^c${COLOR1}^"
FSETCOLORCMD2="^c${COLOR2}^"
FSETCOLORCMD3="^c${COLOR3}^"
FSETCOLORCMD4="^c${COLOR4}^"
FSETCOLORCMD5="^c${COLOR5}^"
FSETCOLORCMD6="^c${COLOR6}^"
FSETCOLORCMD7="^c${COLOR7}^"
FSETCOLORCMD8="^c${COLOR8}^"
FSETCOLORCMD9="^c${COLOR9}^"
FSETCOLORCMD10="^c${COLOR10}^"
FSETCOLORCMD11="^c${COLOR11}^"
FSETCOLORCMD12="^c${COLOR12}^"
FSETCOLORCMD13="^c${COLOR13}^"
FSETCOLORCMD14="^c${COLOR14}^"
FSETCOLORCMD15="^c${COLOR15}^"
fi
if [ "$COLORBG" = "true" ]; then
BSETCOLORCMD1="^b${COLOR1}^"
BSETCOLORCMD2="^b${COLOR2}^"
BSETCOLORCMD3="^b${COLOR3}^"
BSETCOLORCMD4="^b${COLOR4}^"
BSETCOLORCMD5="^b${COLOR5}^"
BSETCOLORCMD6="^b${COLOR6}^"
BSETCOLORCMD7="^b${COLOR7}^"
BSETCOLORCMD8="^b${COLOR8}^"
BSETCOLORCMD9="^b${COLOR9}^"
BSETCOLORCMD10="^b${COLOR10}^"
BSETCOLORCMD11="^b${COLOR11}^"
BSETCOLORCMD12="^b${COLOR12}^"
BSETCOLORCMD13="^b${COLOR13}^"
BSETCOLORCMD14="^b${COLOR14}^"
BSETCOLORCMD15="^b${COLOR15}^"
fi
if [ "$USEBUILTINCOL" = "true" ]; then
if [ "$COLORFG" = "true" ]; then
FSETCOLORCMD1="^C1^"
FSETCOLORCMD2="^C2^"
FSETCOLORCMD3="^C3^"
FSETCOLORCMD4="^C4^"
FSETCOLORCMD5="^C5^"
FSETCOLORCMD6="^C6^"
FSETCOLORCMD7="^C7^"
FSETCOLORCMD8="^C8^"
FSETCOLORCMD9="^C9^"
FSETCOLORCMD10="^C10^"
FSETCOLORCMD11="^C11^"
FSETCOLORCMD12="^C12^"
FSETCOLORCMD13="^C13^"
FSETCOLORCMD14="^C14^"
FSETCOLORCMD15="^C15^"
fi
if [ "$COLORBG" = "true" ]; then
BSETCOLORCMD1="^B1^"
BSETCOLORCMD2="^B2^"
BSETCOLORCMD3="^B3^"
BSETCOLORCMD4="^B4^"
BSETCOLORCMD5="^B5^"
BSETCOLORCMD6="^B6^"
BSETCOLORCMD7="^B7^"
BSETCOLORCMD8="^B8^"
BSETCOLORCMD9="^B9^"
BSETCOLORCMD10="^B10^"
BSETCOLORCMD11="^B11^"
BSETCOLORCMD12="^B12^"
BSETCOLORCMD13="^B13^"
BSETCOLORCMD14="^B14^"
BSETCOLORCMD15="^B15^"
fi
fi
}
# Grab colors from pywal if possible
# For example, 1,1p means the first line
SETCOLORS_WAL() {
if [ "$USEWAL" = "true" ]; then
if [ -e "$HOME/.cache/wal/colors" ]; then
COLOR1=$(sed -n 1,1p $HOME/.cache/wal/colors)
COLOR2=$(sed -n 2,2p $HOME/.cache/wal/colors)
COLOR3=$(sed -n 3,3p $HOME/.cache/wal/colors)
COLOR4=$(sed -n 4,4p $HOME/.cache/wal/colors)
COLOR5=$(sed -n 5,5p $HOME/.cache/wal/colors)
COLOR6=$(sed -n 6,6p $HOME/.cache/wal/colors)
COLOR7=$(sed -n 7,7p $HOME/.cache/wal/colors)
COLOR8=$(sed -n 8,8p $HOME/.cache/wal/colors)
COLOR9=$(sed -n 9,9p $HOME/.cache/wal/colors)
COLOR10=$(sed -n 10,10p $HOME/.cache/wal/colors)
COLOR11=$(sed -n 11,11p $HOME/.cache/wal/colors)
COLOR12=$(sed -n 12,12p $HOME/.cache/wal/colors)
COLOR13=$(sed -n 13,13p $HOME/.cache/wal/colors)
COLOR14=$(sed -n 14,14p $HOME/.cache/wal/colors)
COLOR15=$(sed -n 15,15p $HOME/.cache/wal/colors)
USINGWAL=true
fi
fi
}
# End of configuration
#########################################################################
# Set bindir
case "$BINDIR" in
"") BINDIR=$(cat /usr/share/speedwm-bindir) ;;
esac
mkdir -p $HOME/.config/speedwm-de/status
# Load config and create options if it does not exist
LOADCONFIG() {
if [ -e "$HOME/.config/speedwm-de/status/config" ]; then
. $HOME/.config/speedwm-de/status/config && echo "Loaded configuration file"
else
touch $HOME/.config/speedwm-de/status/config && echo "Created configuration file"
printf "USEWAL=$USEWAL # Use Pywal if possible (true/false)" > $HOME/.config/speedwm-de/status/config
printf "\nRUNONCE=$RUNONCE # Only run status bar once (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nSLEEPTIME=$SLEEPTIME # How long delay in seconds between each reload (int)" >> $HOME/.config/speedwm-de/status/config
printf "\nSEP='$SEP' # Separator to use. Alternative separators: '❰', '<', '|'" >> $HOME/.config/speedwm-de/status/config
printf "\n\nENABLE_ITEM1=$ENABLE_ITEM1 # Enable RAM usage (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM2=$ENABLE_ITEM2 # Enable Time (HH:MM) (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM3=$ENABLE_ITEM3 # Enable Date (DD/MM/YY) (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM4=$ENABLE_ITEM4 # Enable Volume/Mute status (<perc>) (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM5=$ENABLE_ITEM5 # Enable Weather (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM6=$ENABLE_ITEM6 # Enable Network Traffic (<num>B/s) (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM7=$ENABLE_ITEM7 # Enable dfmpeg status (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM8=$ENABLE_ITEM8 # Enable CPU temp (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM9=$ENABLE_ITEM9 # Enable music status (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM10=$ENABLE_ITEM10 # Enable newsboat unread (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM11=$ENABLE_ITEM11 # Enable battery percentage and charging status (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nENABLE_ITEM12=$ENABLE_ITEM12 # Enable #ff IRC backlogs in status bar (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\n\nITEM1_ICON='$ITEM1_ICON' # Icon for ITEM1" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM2_ICON='$ITEM2_ICON' # Icon for ITEM2" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM3_ICON='$ITEM3_ICON' # Icon for ITEM3" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM4_ICON='$ITEM4_ICON' # Icon for ITEM4" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM5_ICON='$ITEM5_ICON' # Icon for ITEM5" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM6_ICON='$ITEM6_ICON' # Icon for ITEM6" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM7_ICON='$ITEM7_ICON' # Icon for ITEM7" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM8_ICON='$ITEM8_ICON' # Icon for ITEM8" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_ICON='$ITEM9_ICON' # Icon for ITEM9" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM10_ICON='$ITEM10_ICON' # Icon for ITEM10" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM11_ICON='$ITEM11_ICON' # Icon for ITEM11" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM12_ICON='$ITEM12_ICON' # Icon for ITEM12" >> $HOME/.config/speedwm-de/status/config
printf "\n\nITEM9_BACKEND=$ITEM9_BACKEND # Backend for the music status (cmus/mocp/auto)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_DISPLAY_ARTIST=$ITEM9_DISPLAY_ARTIST # Display artist or not (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_DISPLAY_TITLE=$ITEM9_DISPLAY_TITLE # Display title or not (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_DISPLAY_ALBUM=$ITEM9_DISPLAY_ALBUM # Display album or not (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_DISPLAY_GENRE=$ITEM9_DISPLAY_GENRE # Display genre or not (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_DISPLAY_FILE=$ITEM9_DISPLAY_FILE # Display filename or not. This option will disable everything else. Path and file extension will be cut. (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_DISPLAY_TIMEELAPSED=$ITEM9_DISPLAY_TIMEELAPSED # Display time elapsed or not (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_DISPLAY_TIMETOTAL=$ITEM9_DISPLAY_TIMETOTAL # Display total time or not (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_PRE_FILE='$ITEM9_PRE_FILE' # Text to display before the filename" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_POST_FILE='$ITEM9_POST_FILE' # Text to display after the filename" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_PRE_ARTIST='$ITEM9_PRE_ARTIST' # Text to display before the artist" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_POST_ARTIST='$ITEM9_POST_ARTIST' # Text to display after the artist" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_PRE_TITLE='$ITEM9_PRE_TITLE' # Text to display before the title" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_POST_TITLE='$ITEM9_POST_TITLE' # Text to display after the title" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_PRE_ALBUM='$ITEM9_PRE_ALBUM' # Text to display before the album" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_POST_ALBUM='$ITEM9_POST_ALBUM' # Text to display after the album" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_PRE_GENRE='$ITEM9_PRE_GENRE' # Text to display before the genre" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_POST_GENRE='$ITEM9_POST_GENRE' # Text to display after the genre" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_PRE_TE='$ITEM9_PRE_TE' # Text to display before the time elapsed." >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_POST_TE='$ITEM9_POST_TE' # Text to display after the time elapsed." >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_PRE_TT='$ITEM9_PRE_TT' # Text to display before the total time." >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_POST_TT='$ITEM9_POST_TT' # Text to display before the total time." >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_TT_TE_NO_SPACING=$ITEM9_TT_TE_NO_SPACING # No spacing between time elapsed and total time (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_TE_REVERSE=$ITEM9_TE_REVERSE # Reverse time elapsed (replace with current time) (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_HIDE_EMPTY_ARTIST=$ITEM9_HIDE_EMPTY_ARTIST # Hide empty artist (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_HIDE_EMPTY_TITLE=$ITEM9_HIDE_EMPTY_ARTIST # Hide empty title (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_HIDE_EMPTY_ALBUM=$ITEM9_HIDE_EMPTY_ALBUM # Hide empty album (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_HIDE_EMPTY_GENRE=$ITEM9_HIDE_EMPTY_GENRE # Hide empty genre (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_HIDE_EMPTY_TT=$ITEM9_HIDE_EMPTY_TT # Hide empty total time (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_HIDE_EMPTY_TE=$ITEM9_HIDE_EMPTY_TE # Hide empty time elapsed (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nITEM9_SEPARATOR='$ITEM9_SEPARATOR' # Separator between ARTIST, TITLE and ALBUM" >> $HOME/.config/speedwm-de/status/config
printf "\n\nHIDE_STATUS_SYSTRAY=$HIDE_STATUS_SYSTRAY # Hide the status when a systray is running (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nSYSTRAY=$SYSTRAY # Systray to use (<systray executable>)" >> $HOME/.config/speedwm-de/status/config
printf "\nSTATUS_WHEN_HIDDEN=$STATUS_WHEN_HIDDEN # Status to print when status is hidden (char)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLORFG=$COLORFG # Color foreground (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLORBG=$COLORBG # Color background (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\nUSEBUILTINCOL=$USEBUILTINCOL # Use built in speedwm colors (col_status<num>). This also supports Pywal. (true/false)" >> $HOME/.config/speedwm-de/status/config
printf "\n\nCOLOR1=$COLOR1 # Color for ITEM1 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR2=$COLOR2 # Color for ITEM2 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR3=$COLOR3 # Color for ITEM3 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR6=$COLOR6 # Color for ITEM6 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR7=$COLOR7 # Color for ITEM7 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR8=$COLOR8 # Color for ITEM8 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR9=$COLOR9 # Color for ITEM9 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR10=$COLOR10 # Color for ITEM10 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR11=$COLOR11 # Color for ITEM11 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR12=$COLOR12 # Color for ITEM12 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR13=$COLOR13 # Color for ITEM13 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR14=$COLOR14 # Color for ITEM14 (hex color)" >> $HOME/.config/speedwm-de/status/config
printf "\nCOLOR15=$COLOR15 # Color for ITEM15 (hex color)\n" >> $HOME/.config/speedwm-de/status/config
fi
}
# Set it to /usr/bin if it was not possible to get it through /usr/share/speedwm-bindir
case "$BINDIR" in
"") BINDIR="/usr/bin" ;;
esac
# Check if muted, for use with volume status bar. Unmute if muted.
case "$MUTED" in
"") MUTED=false ;;
"true") MUTED=false ;;
esac
# Systray stuff
PRINT_SYSTRAY() {
if [ "$SYSTRAY" = "trayer" ]; then
grep -q "USE_SRG=true" $HOME/.config/speedwm-de/systray/config && SYSTRAY="trayer-srg"
fi
if [ "$HIDE_STATUS_SYSTRAY" = "true" ]; then
pgrep -x $SYSTRAY > /dev/null && SYSTRAYRUNNING=true
case "$SYSTRAYRUNNING" in
"true") $SETMETHOD "$STATUS_WHEN_HIDDEN" && exit 0 ;;
esac
fi
# Output of commands
# We're doing this so we can manipulate them easily for various reasons.
ITEMCMD1="$(echo "$(ITEM1)" | sed ':a;N;$!ba;s/\n//g')"
ITEMCMD2="$(echo "$(ITEM2)" | sed ':a;N;$!ba;s/\n//g')"
ITEMCMD3="$(echo "$(ITEM3)" | sed ':a;N;$!ba;s/\n//g')"
ITEMCMD4="$(echo "$(ITEM4)" | sed ':a;N;$!ba;s/\n//g')"
ITEMCMD5="$(echo "$(ITEM5)" | sed ':a;N;$!ba;s/\n//g')"
ITEMCMD6="$(echo "$(ITEM6)" | sed ':a;N;$!ba;s/\n//g')"
ITEMCMD7="$(echo "$(ITEM7)" | sed ':a;N;$!ba;s/\n//g')"
ITEMCMD8="$(echo "$(ITEM8)" | sed ':a;N;$!ba;s/\n//g')"
ITEMCMD9="$(echo "$(ITEM9)" | sed ':a;N;$!ba;s/\n//g')"
ITEMCMD10="$(echo "$(ITEM10)" | sed ':a;N;$!ba;s/\n//g')"
ITEMCMD11="$(echo "$(ITEM11)" | sed ':a;N;$!ba;s/\n//g')"
ITEMCMD12="$(echo "$(ITEM12)" | sed ':a;N;$!ba;s/\n//g')"
if [ "$HIDE_SYSTEM_SYSTRAY" = "true" ]; then
if [ "$SYSTRAYRUNNING" != "true" ]; then
PRINT
fi
else
PRINT
fi
}
# RAM usage
ITEM1() {
if [ "$ENABLE_ITEM1" = "true" ]; then
if [ -e "${BINDIR}free" ]; then
echo "$SEP $ITEM1_ICON $(echo $(free -h --giga | awk '/^Mem/ {print $3}')B)"
fi
fi
}
# Time
ITEM2() {
if [ "$ENABLE_ITEM2" = "true" ]; then
if [ -e "${DATEBINDIR}date" ]; then
echo "$SEP $ITEM2_ICON $(date +%H:%M)"
fi
fi
}
# Date
ITEM3() {
if [ "$ENABLE_ITEM3" = "true" ]; then
if [ -e "${DATEBINDIR}date" ]; then
echo "$SEP $ITEM3_ICON $(date +%d/%m/%Y)"
fi
fi
}
# Volume
ITEM4() {
if [ "$ENABLE_ITEM4" = "true" ]; then
if [ -e "${BINDIR}pulsemixer" ]; then
echo "$SEP $ITEM4_ICON $(echo $(pulsemixer --get-volume | awk '{ print $1 }')%)"
test /tmp/speedwm-audioctrl-mutestatus && grep "Not muted" /tmp/speedwm-audioctrl-mutestatus > /dev/null && MUTED=false
test /tmp/speedwm-audioctrl-mutestatus && grep "Not muted" /tmp/speedwm-audioctrl-mutestatus > /dev/null || MUTED=true
test /tmp/speedwm-audioctrl-mutestatus || MUTED=false
else
echo "$SEP $ITEM4_ICON $(echo $(amixer -c 0 get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/")%)"
fi
if [ "$MUTED" != "false" ]; then
printf "\n (Muted)"
fi
fi
}
# Weather
ITEM5() {
if [ "$ENABLE_ITEM5" = "true" ]; then
if [ -e "${BINDIR}curl" ]; then
curl -so /tmp/hacky_internet_test wttr.in && echo "$SEP $ITEM5_ICON $(echo $(curl -s wttr.in/?format="%C"), $(curl -s wttr.in/?format=3 | sed 's/.* //' | sed 's/.*\(.....\)/\1/'))"
rm -f /tmp/hacky_internet_test
fi
fi
}
# Network traffic
ITEM6() {
if [ "$ENABLE_ITEM6" = "true" ]; then
if [ -e "${BINDIR}awk" ]; then
echo "$SEP $ITEM6_ICON $(awk '{$1=$1/1024000; print $1"B";}' /sys/class/net/[ew]*/statistics/tx_bytes | sed 's/.*\(....\)/\1/' | sed "s|B|B/s |")"
fi
fi
}
# Dfmpeg status
ITEM7() {
# Check if we're recording with dfmpeg or not
if [ "$ENABLE_ITEM7" = "true" ]; then
if [ -e "/tmp/dfmpeg-recording" ]; then
echo "$SEP $ITEM7_ICON Recording"
fi
fi
}
# CPU temp
ITEM8() {
if [ "$ENABLE_ITEM8" = "true" ]; then
if [ -e "${BINDIR}sensors" ]; then
echo "$SEP $ITEM8_ICON $(sensors | grep "temp1" | sed 's/(.*//' | sed "s/temp1.//" | sed -r 's/\s+//g' | awk '{ print $1 }')"
fi
fi
}
# mocp/cmus status
ITEM9() {
# Auto set backend if set to auto
if [ "$ITEM9_BACKEND" = "auto" ]; then
if [ -e "${BINDIR}cmus" ]; then
ITEM9_BACKEND="cmus"
elif [ -e "${BINDIR}mocp" ]; then
ITEM9_BACKEND="mocp"
fi
fi
if [ "$ENABLE_ITEM9" = "true" ]; then
if [ "$ITEM9_BACKEND" = "mocp" ]; then
if [ -e "${BINDIR}mocp" ]; then
if [ "$(echo $(mocp -Q %file))" != "" ]; then
# reverse time elapsed (?)
if [ "$ITEM9_TE_REVERSE" = "true" ]; then
TECMD="tl"
else
TECMD="ct"
fi
# filename
if [ "$ITEM9_DISPLAY_FILE" = "true" ]; then
echo "$SEP $ITEM9_ICON $ITEM9_PRE_FILE$(basename "$(mocp -Q %file)" | sed 's|\(.*\)[.].*|\1|')$ITEM9_POST_FILE"
else
# artist
if [ "$ITEM9_DISPLAY_ARTIST" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_ARTIST" = "true" ]; then
if [ "$(mocp -Q %artist | head -n 1)" != "" ]; then
data="$ITEM9_PRE_ARTIST$(printf "$data $(mocp -Q %artist) $ITEM9_SEPARATOR")$ITEM9_POST_ARTIST"
fi
else
data="$ITEM9_PRE_ARTIST$(printf "$data $(mocp -Q %artist) $ITEM9_SEPARATOR")$ITEM9_POST_ARTIST"
fi
fi
# title
if [ "$ITEM9_DISPLAY_TITLE" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_TITLE" = "true" ]; then
if [ "$(mocp -Q %song | head -n 1)" != "" ]; then
data="$ITEM9_PRE_TITLE$(printf "$data $(mocp -Q %song)")$ITEM9_POST_TITLE"
fi
else
data="$ITEM9_PRE_TITLE$(printf "$data $(mocp -Q %song)")$ITEM9_POST_TITLE"
fi
fi
# album
if [ "$ITEM9_DISPLAY_ALBUM" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_ALBUM" = "true" ]; then
if [ "$(mocp -Q %album | head -n 1)" != "" ]; then
data="$(printf "$data $ITEM9_PRE_ALBUM$(mocp -Q %album)$ITEM9_POST_ALBUM")"
fi
else
data="$(printf "$data $ITEM9_PRE_ALBUM$(mocp -Q %album)$ITEM9_POST_ALBUM")"
fi
fi
# time elapsed
if [ "$ITEM9_DISPLAY_TIMEELAPSED" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_TE" = "true" ]; then
if [ "$(mocp -Q %tl | head -n 1)" != "" ]; then
data="$(printf "$data $ITEM9_PRE_TE$(mocp -Q %$TECMD)$ITEM9_POST_TE")"
fi
else
data="$(printf "$data $ITEM9_PRE_TE$(mocp -Q %$TECMD)$ITEM9_POST_TE")"
fi
fi
# total time
if [ "$ITEM9_TT_TE_NO_SPACING" = "false" ]; then
if [ "$ITEM9_DISPLAY_TIMETOTAL" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_TT" = "true" ]; then
if [ "$(mocp -Q %tt | head -n 1)" != "" ]; then
data="$(printf "$data $ITEM9_PRE_TT$(mocp -Q %tt)$ITEM9_POST_TT")"
fi
else
data="$(printf "$data $ITEM9_PRE_TT$(mocp -Q %tt)$ITEM9_POST_TT")"
fi
fi
else
# total time without spacing
if [ "$ITEM9_DISPLAY_TIMETOTAL" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_TT" = "true" ]; then
if [ "$(mocp -Q %tt | head -n 1)" != "" ]; then
data="$(printf "$data $ITEM9_PRE_TT$(mocp -Q %tt)$ITEM9_POST_TT")"
fi
else
data="$(printf "$data$ITEM9_PRE_TT$(mocp -Q %tt)$ITEM9_POST_TT")"
fi
fi
fi
# actually print it
echo "$SEP $ITEM9_ICON $data"
fi
fi
fi
fi
fi
if [ "$ENABLE_ITEM9" = "true" ]; then
if [ -e "${BINDIR}cmus-remote" ]; then
if [ "$(cmus-remote -C status | head -n 1 | awk '{ print $2 }')" = "playing" ]; then
if [ "$ITEM9_DISPLAY_FILE" = "true" ]; then
echo "$SEP $ITEM9_ICON $ITEM9_PRE_FILE$(basename "$(cmus-remote -C status | grep file)"| sed 's|\(.*\)[.].*|\1|')$ITEM9_POST_FILE"
else
# artist
if [ "$ITEM9_DISPLAY_ARTIST" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_ARTIST" = "true" ]; then
if [ "$(cmus-remote -C status | grep "tag artist")" != "" ]; then
data="$(printf "$data $ITEM9_PRE_ARTIST$(cmus-remote -C status | grep "tag artist" | sed "s/tag artist //g")$ITEM9_POST_ARTIST $ITEM9_SEPARATOR")"
fi
else
data="$(printf "$data $ITEM9_PRE_ARTIST$(cmus-remote -C status | grep "tag artist" | sed "s/tag artist //g")$ITEM9_POST_ARTIST $ITEM9_SEPARATOR")"
fi
fi
# title
if [ "$ITEM9_DISPLAY_TITLE" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_TITLE" = "true" ]; then
if [ "$(cmus-remote -C status | grep "tag title")" != "" ]; then
data="$(printf "$data $ITEM9_PRE_TITLE$(cmus-remote -C status | grep "tag title" | sed "s/tag title //g")$ITEM9_POST_TITLE")"
fi
else
data="$(printf "$data $ITEM9_PRE_TITLE$(cmus-remote -C status | grep "tag title" | sed "s/tag title //g")$ITEM9_POST_TITLE")"
fi
fi
# album
if [ "$ITEM9_DISPLAY_ALBUM" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_ALBUM" = "true" ]; then
if [ "$(cmus-remote -C status | grep "tag album")" != "" ]; then
data="$(printf "$data $ITEM9_PRE_ALBUM$(cmus-remote -C status | grep "tag album" | sed "s/tag album //g")$ITEM9_POST_ALBUM")"
fi
else
data="$(printf "$data $ITEM9_PRE_ALBUM$(cmus-remote -C status | grep "tag album" | sed "s/tag album //g")$ITEM9_POST_ALBUM")"
fi
fi
# genre
if [ "$ITEM9_DISPLAY_GENRE" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_GENRE" = "true" ]; then
if [ "$(cmus-remote -C status | grep "tag genre")" != "" ]; then
data="$(printf "$data $ITEM9_PRE_GENRE$(cmus-remote -C status | grep "tag genre" | sed "s/tag genre //g")$ITEM9_POST_GENRE")"
fi
else
data="$(printf "$data $ITEM9_PRE_GENRE$(cmus-remote -C status | grep "tag genre" | sed "s/tag genre //g")$ITEM9_POST_GENRE")"
fi
fi
# time elapsed
if [ "$ITEM9_DISPLAY_TIMEELAPSED" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_TE" = "true" ]; then
if [ "$(cmus-remote -Q | grep position | sed "s/position //g")" != "" ]; then
data="$(printf "$data $ITEM9_PRE_TE$(cmus-remote -Q | grep position | sed "s/position //g" | awk '{printf "%02d:%02d:%02d",$0/3600,$0%3600/60,$0%60}' | sed "s/00://")$ITEM9_POST_TE")"
fi
else
data="$(printf "$data $ITEM9_PRE_TE$(cmus-remote -Q | grep position | sed "s/position //g" | awk '{printf "%02d:%02d:%02d",$0/3600,$0%3600/60,$0%60}' | sed "s/00://")$ITEM9_POST_TE")"
fi
fi
# total time
if [ "$ITEM9_TT_TE_NO_SPACING" = "false" ]; then
if [ "$ITEM9_DISPLAY_TIMETOTAL" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_TT" = "true" ]; then
if [ "$(cmus-remote -Q | grep duration | sed "s/duration //g")" != "" ]; then
data="$(printf "$data $ITEM9_PRE_TT$(cmus-remote -Q | grep duration | sed "s/duration //g" | awk '{printf "%02d:%02d:%02d",$0/3600,$0%3600/60,$0%60}' | sed "s/00://")$ITEM9_POST_TT")"
fi
else
data="$(printf "$data $ITEM9_PRE_TT$(cmus-remote -Q | grep duration | sed "s/duration //g" | awk '{printf "%02d:%02d:%02d",$0/3600,$0%3600/60,$0%60}' | sed "s/00://")$ITEM9_POST_TT")"
fi
fi
else
# total time without spacing
if [ "$ITEM9_DISPLAY_TIMETOTAL" = "true" ]; then
if [ "$ITEM9_HIDE_EMPTY_TT" = "true" ]; then
if [ "$(cmus-remote -Q | grep duration | sed "s/duration //g")" != "" ]; then
data="$(printf "$data$ITEM9_PRE_TT$(cmus-remote -Q | grep duration | sed "s/duration //g" | awk '{printf "%02d:%02d:%02d",$0/3600,$0%3600/60,$0%60}' | sed "s/00://")$ITEM9_POST_TT")"
fi
else
data="$(printf "$data$ITEM9_PRE_TT$(cmus-remote -Q | grep duration | sed "s/duration //g" | awk '{printf "%02d:%02d:%02d",$0/3600,$0%3600/60,$0%60}' | sed "s/00://")$ITEM9_POST_TT")"
fi
fi
fi
# actually print it
if [ "$data" != "" ]; then
echo "$SEP $ITEM9_ICON $data"
fi
fi
fi
fi
fi
}
# Newsboat unreads
ITEM10() {
if [ "$ENABLE_ITEM10" = "true" ]; then
if [ -e "${BINDIR}newsboat" ]; then
pgrep -x newsboat > /dev/null || echo "$SEP $ITEM10_ICON $(newsboat -x print-unread | sed "s| unread articles||") unread!"
fi
fi
}
# Battery percentage/charging status
ITEM11() {
if [ "$ENABLE_ITEM11" = "true" ]; then
if [ -e "/sys/class/power_supply/BAT0/capacity" ]; then
echo "$SEP $ITEM11_ICON $(cat /sys/class/power_supply/BAT0/capacity)%"
fi
if [ -e "${BINDIR}acpi" ]; then
CHARGESTATUS=$(echo ", $(acpi | awk '{ print $3 }' | sed "s|,||g" | sed "s|Discharging|Not charging|g")") && echo $CHARGESTATUS
fi
fi
}
# IRC #ff backlogs
ITEM12() {
if [ "$ENABLE_ITEM12" = "true" ]; then
if [ -e "${BINDIR}curl" ]; then
curl -so /tmp/ff-backlogs https://donut.gq/ff/read.php
if [ -e "/tmp/ff-backlogs" ]; then
echo "$SEP $ITEM12_ICON $(cat /tmp/ff-backlogs | tail -n 1)"
fi
fi
fi
}
BASE() {
# Determine whether or not
if [ "$USEWAL" = "true" ]; then
if [ "$USINGWAL" = "true" ]; then
if [ "$COLOR1" != "$(sed 1,1p $HOME/.cache/wal/colors)" ]; then
SETCOLORS_WAL && SETCOLORS_CMD
fi
fi
fi
# Run once if set to false (useful for maybe a shell)
case "$RUNONCE" in
"false") PRINT_SYSTRAY && sleep $SLEEPTIME ;;
"true") exit 0 ;;
esac
BASE
}
# Set base colors
SETCOLORS
# Use pywal once if possible
USE_PYWAL_COLORS() {
if [ -e "${BINDIR}xsetroot" ]; then
if [ -e "${BINDIR}xrdb" ]; then
if [ "$USEWAL" = "true" ]; then
command -v wal > /dev/null && SETCOLORS_WAL
fi
fi
fi
}
LOADCONFIG
USE_PYWAL_COLORS
SETCOLORS_CMD
PRINT_SYSTRAY
BASE
exit 0