#!/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 can be changed there. Otherwise, carefully edit the file and recompile speedwm! # General settings REFRESHDELAY=1 # How long delay in seconds between each reload (num) DATEBINDIR="/bin/" # Directory where your 'date' binary is. Default should be fine for most people SETMETHOD="speedwm -s" # Method used to set the status bar SEPARATOR="❰" # Separator to use. Alternative separators: "❰", "<", "|" COLORFG=true # Color foreground (true/false) COLORBG=false # Color background (true/false) CHARLIMIT=auto # Limit characters to CHARLIMIT. Enter false to not have a limit. Enter auto to use xdpyinfo. (num/auto/false) ITEM_ORDER="@2 @3 @11 @4 @1 @6 @8 @5 @9 @7 @10" # Item order. @1 means item 1, @6 means item 6 and so on. (text) # 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 (%) (true/false) ENABLE_ITEM5=true # Enable Weather (true/false) ENABLE_ITEM6=true # Enable Network Traffic (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) 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 # RAM format # Format to display the RAM status in # # @u - Used RAM # @t - Total RAM # # Example: @u/@t ITEM1_FORMAT="@u/@t" # Time format # Format to display the time in # # @h - Hour # @m - Minute # @s - Second # # Example: @h:@m ITEM2_FORMAT="@h:@m" # Date format # Format to display the date in # # @d - Day # @m - Month # @y - Year # # Example: @d/@m/@y ITEM3_FORMAT="@d/@m/@y" ITEM4_SHOW_MUTE="true" # Show mute status (true/false) ITEM4_MUTE_TEXT="(Muted)" # Text to display when muted (text) ITEM7_RECORDING_TEXT="Recording" # Text to display when recording (text) ITEM8_FORMAT_CELSIUS="true" # Format temperature in Celsius (true/false) ITEM9_BACKEND="auto" # Backend for the music status (cmus/mocp/auto) ITEM9_DISPLAY_ARTIST="true" # Display artist or not (true/false) ITEM9_DISPLAY_TITLE="true" # Display title or not (true/false) ITEM9_DISPLAY_ALBUM="true" # Display album or not (true/false) ITEM9_DISPLAY_GENRE="true" # Display genre or not (true/false) ITEM9_DISPLAY_TIMEELAPSED="true" # Display time elapsed or not. If you use this, you will probably want the delay set pretty low. (true/false) ITEM9_DISPLAY_TIMETOTAL="true" # Display total time or not (true/false_ ITEM9_DISPLAY_FILE="false" # Display filename or not. This option will disable everything else. Path and file extension will be cut. (true/false) # Music format # Format to display the music status in # # @a - Artist # @t - Title # @g - Genre # @ab - Album # @tt - Total time # @te - Time elapsed # # Example: @a - @t from @ab (@g) [@te/@tt] ITEM9_FORMAT="@a - @t from @ab (@g) [@te/@tt]" ITEM10_TEXT="unread articles!" # Text to display next to unread article count (text) ITEM11_SHOW_CHARGING_STATUS=true # Show 'Charging', 'Not charging' or 'Fully charged' status after the percentage. (true/false) ITEM11_DISCHARGING_TEXT="Not charging" # Text when not charging (text) ITEM11_CHARGING_TEXT="Charging" # Text when charging (text) ITEM11_FULL_TEXT="Fully charged" # Text when fully charged (text) ######################################################################### PRINT() { $SETMETHOD "$(printf "$ITEMS_TEXT")" } SETCOLORS_CMD() { 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 } # Set bindir case "$BINDIR" in "") BINDIR=$(cat /usr/share/speedwm-bindir) ;; esac rm -f /tmp/itest rm -f /tmp/wstatus rm -f /tmp/iscelsius pkill "$(pgrep -x status | sed "s/$$//g")" # Prevent duplicates mkdir -p $HOME/.config/speedwm-de/status printf "Loaded speedwm status 0.3\n---\n" # 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 "# speedwm status configuration file\n" >> $HOME/.config/speedwm-de/status/config printf "\n# Print options\nREFRESHDELAY=$REFRESHDELAY # How long delay in seconds between each reload (num)" >> $HOME/.config/speedwm-de/status/config printf "\nSEPARATOR='$SEPARATOR' # Separator to use. Example separators: '❰', '<', '|'" >> $HOME/.config/speedwm-de/status/config printf "\nITEM_ORDER='$ITEM_ORDER' # Item order. @1 means item 1, @6 means item 6 and so on. (text)" >> $HOME/.config/speedwm-de/status/config printf "\nCHARLIMIT=$CHARLIMIT # Limit characters to CHARLIMIT. Enter false to not have a limit. Enter auto to use xdpyinfo. (num/auto/false)" >> $HOME/.config/speedwm-de/status/config printf "\n\n# Enable/Disable items\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 () (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 (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 "\n\n# Icon/Label options for items\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 "\n\n# RAM format\n# Format to display the RAM status in\n#\n# @u - Used RAM\n# @t - Total RAM\n#\n# Example: @u/@t\nITEM1_FORMAT='$ITEM1_FORMAT'" >> $HOME/.config/speedwm-de/status/config printf "\n\n# Time format\n# Format to display the time in\n#\n# @h - Hour\n# @m - Minute\n# @s - Second\n#\n# Example: @h:@m:@s\nITEM2_FORMAT='$ITEM2_FORMAT'" >> $HOME/.config/speedwm-de/status/config printf "\n\n# Date format\n# Format to display the date in\n#\n# @d - Day\n# @m - Month\n# @y - Year\n#\n# Example: @d/@m/@y\nITEM3_FORMAT='$ITEM3_FORMAT'" >> $HOME/.config/speedwm-de/status/config printf "\n\n# Volume item options\nITEM4_SHOW_MUTE=$ITEM4_SHOW_MUTE # Show mute status (true/false)" >> $HOME/.config/speedwm-de/status/config printf "\nITEM4_MUTE_TEXT='$ITEM4_MUTE_TEXT' # Text to display when muted (text)" >> $HOME/.config/speedwm-de/status/config printf "\n# dfmpeg status options\nITEM7_RECORDING_TEXT='$ITEM7_RECORDING_TEXT' # Text to display when recording (text)" >> $HOME/.config/speedwm-de/status/config printf "\n\n# CPU temperature options\nITEM8_FORMAT_CELSIUS=$ITEM8_FORMAT_CELSIUS # Format temperature in Celsius (true/false)" >> $HOME/.config/speedwm-de/status/config printf "\n\n# Music status options\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 "\n\n# Music format\n# Format to display the music status in\n#\n# @a - Artist\n# @t - Title\n# @g - Genre\n# @ab - Album\n# @tt - Total time\n# @te - Time elapsed\n#\n# Example: @a - @t from @ab (@g) [@te/@tt]\nITEM9_FORMAT='$ITEM9_FORMAT'" >> $HOME/.config/speedwm-de/status/config printf "\n\n# Newsboat item options\nITEM10_TEXT='$ITEM10_TEXT' # Text to display next to unread article count (text)" >> $HOME/.config/speedwm-de/status/config printf "\n\n# Battery item options\nITEM11_SHOW_CHARGING_STATUS=$ITEM11_SHOW_CHARGING_STATUS # Show 'Charging', 'Not charging' or 'Fully charged' status after the percentage. (true/false)" >> $HOME/.config/speedwm-de/status/config printf "\nITEM11_CHARGING_TEXT='$ITEM11_CHARGING_TEXT' # Text when charging (text)" >> $HOME/.config/speedwm-de/status/config printf "\nITEM11_DISCHARGING_TEXT='$ITEM11_DISCHARGING_TEXT' # Text when not charging (text)" >> $HOME/.config/speedwm-de/status/config printf "\nITEM11_FULL_TEXT='$ITEM11_FULL_TEXT' # Text when fully charged (text)" >> $HOME/.config/speedwm-de/status/config printf "\n\n# Color options\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 "\n\n# End of configuration file." >> $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="$(dirname $(command -v status))/" ;; esac # Systray stuff PRINT_TEXT() { # 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')" # Add colors to them ITEMCMD1="$FSETCOLORCMD7$BSETCOLORCMD7$ITEMCMD1" ITEMCMD2="$FSETCOLORCMD11$BSETCOLORCMD11$ITEMCMD2" ITEMCMD3="$FSETCOLORCMD10$BSETCOLORCMD10$ITEMCMD3" ITEMCMD4="$FSETCOLORCMD8$BSETCOLORCMD8$ITEMCMD4" ITEMCMD5="$FSETCOLORCMD3$BSETCOLORCMD3$ITEMCMD5" ITEMCMD6="$FSETCOLORCMD6$BSETCOLORCMD6$ITEMCMD6" ITEMCMD7="$FSETCOLORCMD5$BSETCOLORCMD5$ITEMCMD7" ITEMCMD8="$FSETCOLORCMD4$BSETCOLORCMD4$ITEMCMD8" ITEMCMD9="$FSETCOLORCMD2$BSETCOLORCMD2$ITEMCMD9" ITEMCMD10="$FSETCOLORCMD9$BSETCOLORCMD9$ITEMCMD10" ITEMCMD11="$FSETCOLORCMD8$BSETCOLORCMD8$ITEMCMD11" ITEMS_TEXT="$(echo "$ITEM_ORDER" | sed "s|@10|\x10$ITEMCMD10|; s|@11|\x11$ITEMCMD11|; s|@1|\x01$ITEMCMD1|; s|@2|\x02$ITEMCMD2|; s|@3|\x03$ITEMCMD3|; s|@4|\x04$ITEMCMD4|; s|@5|\x05$ITEMCMD5|; s|@6|\x06$ITEMCMD6|; s|@7|\x07$ITEMCMD7|; s|@8|\x08$ITEMCMD8|; s|@9|\x09$ITEMCMD9|; s|%|%%|g")" # Auto-get character limit based on screen resolution # This is pretty hacky, but it works as a default. # Setting this to "false" is recommended if you've got a big monitor # I think the first three numbers of your screen resolution times 1.5 is a good max. # I've got a 1366x768 12 inch ThinkPad so I decided to implement this. # If anyone has a better method, please PR. if [ "$CHARLIMIT" = "auto" ]; then command -v xdpyinfo > /dev/null && \ RES="$(xdpyinfo | awk '/dimensions/ {print $2}' | sed 's/.x....*//g; s/[^0-9]*//g')" CHARS="$(expr "$RES" "*" "2")" if [ "$CHARS" = "" ]; then CHARS=false fi elif [ "$CHARLIMIT" != "false" ]; then CHARS=$CHARLIMIT else CHARS=false fi if [ "$CHARS" != "false" ]; then # Truncate item 11 if [ "$(printf $ITEMCMD1$ITEMCMD2$ITEMCMD3$ITEMCMD4$ITEMCMD5$ITEMCMD6$ITEMCMD7$ITEMCMD8$ITEMCMD9$ITEMCMD10$ITEMCMD11 | wc -c)" -gt "$CHARS" ]; then ITEMCMD11="" # Truncate item 10 if [ "$(printf $ITEMCMD1$ITEMCMD2$ITEMCMD3$ITEMCMD4$ITEMCMD5$ITEMCMD6$ITEMCMD7$ITEMCMD8$ITEMCMD9$ITEMCMD10$ITEMCMD11 | wc -c)" -gt "$CHARS" ]; then ITEMCMD10="" # Truncate item 9 if [ "$(printf $ITEMCMD1$ITEMCMD2$ITEMCMD3$ITEMCMD4$ITEMCMD5$ITEMCMD6$ITEMCMD7$ITEMCMD8$ITEMCMD9$ITEMCMD10$ITEMCMD11 | wc -c)" -gt "$CHARS" ]; then ITEMCMD9="" # Truncate item 8 if [ "$(printf $ITEMCMD1$ITEMCMD2$ITEMCMD3$ITEMCMD4$ITEMCMD5$ITEMCMD6$ITEMCMD7$ITEMCMD8$ITEMCMD9$ITEMCMD10$ITEMCMD11 | wc -c)" -gt "$CHARS" ]; then ITEMCMD8="" # Truncate item 7 if [ "$(printf $ITEMCMD1$ITEMCMD2$ITEMCMD3$ITEMCMD4$ITEMCMD5$ITEMCMD6$ITEMCMD7$ITEMCMD8$ITEMCMD9$ITEMCMD10$ITEMCMD11 | wc -c)" -gt "$CHARS" ]; then ITEMCMD7="" # Truncate item 6 if [ "$(printf $ITEMCMD1$ITEMCMD2$ITEMCMD3$ITEMCMD4$ITEMCMD5$ITEMCMD6$ITEMCMD7$ITEMCMD8$ITEMCMD9$ITEMCMD10$ITEMCMD11 | wc -c)" -gt "$CHARS" ]; then ITEMCMD6="" # Truncate item 5 if [ "$(printf $ITEMCMD1$ITEMCMD2$ITEMCMD3$ITEMCMD4$ITEMCMD5$ITEMCMD6$ITEMCMD7$ITEMCMD8$ITEMCMD9$ITEMCMD10$ITEMCMD11 | wc -c)" -gt "$CHARS" ]; then ITEMCMD5="" # Truncate item 4 if [ "$(printf $ITEMCMD1$ITEMCMD2$ITEMCMD3$ITEMCMD4$ITEMCMD5$ITEMCMD6$ITEMCMD7$ITEMCMD8$ITEMCMD9$ITEMCMD10$ITEMCMD11 | wc -c)" -gt "$CHARS" ]; then ITEMCMD4="" # Truncate item 3 if [ "$(printf $ITEMCMD1$ITEMCMD2$ITEMCMD3$ITEMCMD4$ITEMCMD5$ITEMCMD6$ITEMCMD7$ITEMCMD8$ITEMCMD9$ITEMCMD10$ITEMCMD11 | wc -c)" -gt "$CHARS" ]; then ITEMCMD3="" # Truncate item 2 if [ "$(printf $ITEMCMD1$ITEMCMD2$ITEMCMD3$ITEMCMD4$ITEMCMD5$ITEMCMD6$ITEMCMD7$ITEMCMD8$ITEMCMD9$ITEMCMD10$ITEMCMD11 | wc -c)" -gt "$CHARS" ]; then ITEMCMD2="" # Truncate item 1 if [ "$(printf $ITEMCMD1$ITEMCMD2$ITEMCMD3$ITEMCMD4$ITEMCMD5$ITEMCMD6$ITEMCMD7$ITEMCMD8$ITEMCMD9$ITEMCMD10$ITEMCMD11 | wc -c)" -gt "$CHARS" ]; then ITEMCMD1="" fi fi fi fi fi fi fi fi fi fi fi fi PRINT pgrep -x speedwm > /dev/null || exit 1 } # RAM usage ITEM1() { if [ "$ENABLE_ITEM1" = "true" ]; then # Used RAM if [ -e "${BINDIR}free" ]; then USEDRAM="$(echo "$(free -h --giga | awk '/^Mem/ {print $3}')B")" fi # Total RAM if [ -e "${BINDIR}free" ]; then TOTALRAM="$(echo "$(free -h --giga | awk '/^Mem/ {print $2}')B")" fi echo "$SEPARATOR $ITEM1_ICON $ITEM1_FORMAT" | sed "s|@u|$USEDRAM|; s|@t|$TOTALRAM|" fi } # Time ITEM2() { if [ "$ENABLE_ITEM2" = "true" ]; then if [ -e "${DATEBINDIR}date" ]; then HOURS="$(date +%H)" MINUTES="$(date +%M)" SECONDS="$(date +%S)" echo "$SEPARATOR $ITEM2_ICON $ITEM2_FORMAT" | sed "s|@h|$HOURS|; s|@m|$MINUTES|; s|@s|$SECONDS|" fi fi } # Date ITEM3() { if [ "$ENABLE_ITEM3" = "true" ]; then if [ -e "${DATEBINDIR}date" ]; then DAY="$(date +%d)" MONTH="$(date +%m)" YEAR="$(date +%Y)" echo "$SEPARATOR $ITEM3_ICON $ITEM3_FORMAT" | sed "s|@d|$DAY|; s|@m|$MONTH|; s|@y|$YEAR|" fi fi } # Volume ITEM4() { if [ "$ENABLE_ITEM4" = "true" ]; then if [ -e "${BINDIR}pactl" ]; then echo "$SEPARATOR $ITEM4_ICON $(echo $(pactl get-sink-volume 0 | awk '{print $5;exit}'))" else echo "$SEPARATOR $ITEM4_ICON $(echo $(amixer -c 0 get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/")%)" fi fi # get mute if [ "$ITEM4_SHOW_MUTE" = "true" ]; then if [ -e "${BINDIR}pactl" ]; then pactl get-sink-mute 0 | grep -q yes && echo " $ITEM4_MUTE_TEXT" fi fi } # Weather ITEM5() { if [ "$ENABLE_ITEM5" = "true" ]; then if [ -e "${BINDIR}curl" ]; then if [ -e "/tmp/itest" ]; then if [ -e "/tmp/wstatus" ]; then grep -q "" /tmp/wstatus || echo "$SEPARATOR $ITEM5_ICON $(cat /tmp/wstatus)" else echo "$(curl -s wttr.in/?format="%C"), $(curl -s wttr.in/?format=3 | sed 's/.* //; s/.*\(.....\)/\1/')" > /tmp/wstatus echo "$SEPARATOR $ITEM5_ICON $(cat /tmp/wstatus)" fi else curl -so /tmp/itest wttr.in && hasinternet=true if [ "$hasinternet" != "true" ]; then rm -f /tmp/itest rm -f /tmp/wstatus ITEMCMD5="" fi fi fi fi } # Network traffic ITEM6() { if [ "$ENABLE_ITEM6" = "true" ]; then if [ -e "${BINDIR}awk" ]; then echo "$SEPARATOR $ITEM6_ICON $(awk '{$1=$1/1024000; print $1"B";}' /sys/class/net/[ew]*/statistics/tx_bytes | sed "s/.*\(....\)/\1/; s|B|B/s |; s/[.]/0./")" 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 "$SEPARATOR $ITEM7_ICON $ITEM7_RECORDING_TEXT" fi fi } # CPU temp ITEM8() { if [ "$ENABLE_ITEM8" = "true" ]; then if [ -e "${BINDIR}sensors" ]; then if [ "$ITEM8_FORMAT_CELSIUS" = "true" ]; then echo "$SEPARATOR $ITEM8_ICON $(sensors | grep temp1 | awk '{ print $2 }')" touch /tmp/iscelsius else echo "$SEPARATOR $ITEM8_ICON $(sensors -f | grep temp1 | awk '{ print $2 }')" fi 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 # filename if [ "$ITEM9_DISPLAY_FILE" = "true" ]; then if [ "$(mocp -Q %file | head -n 1)" != "" ]; then echo "$SEPARATOR $ITEM9_ICON $ITEM9_PRE_FILE$(basename "$(mocp -Q %file)" | sed 's|\(.*\)[.].*|\1|')$ITEM9_POST_FILE" fi else # artist if [ "$ITEM9_DISPLAY_ARTIST" = "true" ]; then if [ "$(mocp -Q %artist | head -n 1)" != "" ]; then MUSIC_ARTIST="$(mocp -Q %artist)" fi fi # title if [ "$ITEM9_DISPLAY_TITLE" = "true" ]; then if [ "$(mocp -Q %song | head -n 1)" != "" ]; then MUSIC_SONG="$(mocp -Q %song)" fi fi # album if [ "$ITEM9_DISPLAY_ALBUM" = "true" ]; then if [ "$(mocp -Q %album | head -n 1)" != "" ]; then MUSIC_ALBUM="$(mocp -Q %album)" fi fi # time elapsed if [ "$ITEM9_DISPLAY_TIMEELAPSED" = "true" ]; then if [ "$(mocp -Q %tl | head -n 1)" != "" ]; then MUSIC_TIMEELAPSED="$(mocp -Q %ct)" fi fi # total time if [ "$ITEM9_DISPLAY_TIMETOTAL" = "true" ]; then if [ "$(mocp -Q %tt | head -n 1)" != "" ]; then MUSIC_TIMETOTAL="$(mocp -Q %tt)" fi fi data="$(printf "$ITEM9_FORMAT" | sed "s|@ab|$MUSIC_ALBUM|; s|@t|$MUSIC_SONG|; s|@g||; s|@a|$MUSIC_ARTIST|; s|@tt|$MUSIC_TIMETOTAL|; s|@te|$MUSIC_TIMEELAPSED|; s| ||g")" # actually print it echo "$SEPARATOR $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 "$SEPARATOR $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 [ "$(cmus-remote -C status | grep "tag artist")" != "" ]; then MUSIC_ARTIST="$(cmus-remote -C status | grep "tag artist" | sed "s/tag artist //g")" fi fi # title if [ "$ITEM9_DISPLAY_TITLE" = "true" ]; then if [ "$(cmus-remote -C status | grep "tag title")" != "" ]; then MUSIC_SONG="$(cmus-remote -C status | grep "tag title" | sed "s/tag title //g")" fi fi # album if [ "$ITEM9_DISPLAY_ALBUM" = "true" ]; then if [ "$(cmus-remote -C status | grep "tag album")" != "" ]; then MUSIC_ALBUM="$(cmus-remote -C status | grep "tag album" | head -n 1 | sed "s/tag album //g")" fi fi # genre if [ "$ITEM9_DISPLAY_GENRE" = "true" ]; then if [ "$(cmus-remote -C status | grep "tag genre")" != "" ]; then MUSIC_GENRE="$(cmus-remote -C status | grep "tag genre" | sed "s/tag genre //g")" fi fi # time elapsed if [ "$ITEM9_DISPLAY_TIMEELAPSED" = "true" ]; then if [ "$(cmus-remote -Q | grep position | sed "s/position //g")" != "" ]; then MUSIC_TIMEELAPSED="$(cmus-remote -Q | grep position | sed "s/position //g" | awk '{printf "%02d:%02d:%02d",$0/3600,$0%3600/60,$0%60}' | sed "s/00://")" fi fi # total time if [ "$ITEM9_DISPLAY_TIMETOTAL" = "true" ]; then if [ "$(cmus-remote -Q | grep duration | sed "s/duration //g")" != "" ]; then MUSIC_TIMETOTAL="$(cmus-remote -Q | grep duration | sed "s/duration //g" | awk '{printf "%02d:%02d:%02d",$0/3600,$0%3600/60,$0%60}' | sed "s/00://")" fi fi data="$(printf "$ITEM9_FORMAT" | sed "s|@ab|$MUSIC_ALBUM|; s|@t|$MUSIC_SONG|; s|@g|$MUSIC_GENRE|; s|@a|$MUSIC_ARTIST|; s|@tt|$MUSIC_TIMETOTAL|; s|@te|$MUSIC_TIMEELAPSED|; s| ||g")" # actually print it if [ "$data" != "" ]; then echo "$SEPARATOR $ITEM9_ICON $data" fi fi fi fi fi } # Newsboat unreads ITEM10() { if [ "$ENABLE_ITEM10" = "true" ]; then if [ -e "${BINDIR}newsboat" ]; then NEWSCOUNT="$(newsboat -x print-unread | awk '{ print $1 }')" if [ "$NEWSCOUNT" != "Error:" ]; then echo "$SEPARATOR $ITEM10_ICON $NEWSCOUNT $ITEM10_TEXT" fi fi fi } # Battery percentage/charging status ITEM11() { if [ "$ENABLE_ITEM11" = "true" ]; then # print capacity if [ -e "/sys/class/power_supply/BAT0/capacity" ]; then echo "$SEPARATOR $ITEM11_ICON $(cat /sys/class/power_supply/BAT0/capacity)%" fi # print capacity for second battery if it exists if [ -e "/sys/class/power_supply/BAT1/capacity" ]; then echo "$SEPARATOR $ITEM11_ICON $(cat /sys/class/power_supply/BAT1/capacity)%" fi # show charging status if [ -e "${BINDIR}acpi" ]; then if [ "$ITEM11_SHOW_CHARGING_STATUS" = "true" ]; then CHARGESTATUS=$(echo ", $(acpi | awk '{ print $3 }' | sed "s|,||g" | sed "s|Discharging|$ITEM11_DISCHARGING_TEXT|g; s|Charging|$ITEM11_CHARGING_TEXT|g; s|Fully charged|$ITEM11_FULL_TEXT|g")") && echo $CHARGESTATUS fi fi fi } # base BASE() { PRINT_TEXT sleep $REFRESHDELAY BASE } LOADCONFIG SETCOLORS_CMD PRINT_TEXT BASE echo "status: Stopped printing." exit 0