#!/bin/sh # stellar - 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/status/config instead though # All settings can be changed there. Otherwise, carefully edit the file and recompile speedwm! cat < ~/.config/speedwm/statusrc.t # stellar configuration # # This shell script which acts as a configuration file should be configured in /bin/sh compatible syntax. For best compatibility, I suggest that you only use POSIX compliant shell. No bash, no fish and no zsh. Of course if /bin/sh is Bash then you don't strictly NEED to keep it POSIX compliant. # # You can however use if statements, case, variables, shell commands, cat << EOF, etc. # General settings REFRESHDELAY=0.4 # 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. speedwm -s will set the status so only change this if you use this status bar with dwm or awesome. SEPARATOR="❰" # Separator to use. Alternative separators: "❰", "<", "|" CLICKABLE=true # Enable clickability (Requires dwm with statuscmd or speedwm) (true/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) # Color options BUILTINFG=true # Use built in colors for foreground (true/false) BUILTINBG=true # Use built in colors for background (true/false) COLORFG=true # Color foreground (true/false) COLORBG=false # Color background (true/false) # HTML color values # These will be used if BUILTINFG/BUILTINBG is disabled. # # Foreground FCOLOR1="#131210" # Foreground color #1 FCOLOR2="#bf616a" # Foreground color #2 FCOLOR3="#A16F9D" # Foreground color #3 FCOLOR4="#68ABAA" # Foreground color #4 FCOLOR5="#A89F93" # Foreground color #5 FCOLOR6="#D3A99B" # Foreground color #6 FCOLOR7="#AFC9AC" # Foreground color #7 FCOLOR8="#eae1cb" # Foreground color #8 FCOLOR9="#a39d8e" # Foreground color #9 FCOLOR10="#6D5E8E" # Foreground color #10 FCOLOR11="#A16F9D" # Foreground color #11 FCOLOR12="#D3A99B" # Foreground color #12 FCOLOR13="#AFC9AC" # Foreground color #13 FCOLOR14="#eae1cb" # Foreground color #14 FCOLOR15="#6D5E8E" # Foreground color #15 FCOLOR16="#ffffff" # Foreground color #16 # Background BCOLOR1="#eeeeee" # Background color #1 BCOLOR2="\$BCOLOR1" # Background color #2 BCOLOR3="\$BCOLOR1" # Background color #3 BCOLOR4="\$BCOLOR1" # Background color #4 BCOLOR5="\$BCOLOR1" # Background color #5 BCOLOR6="\$BCOLOR1" # Background color #6 BCOLOR7="\$BCOLOR1" # Background color #7 BCOLOR8="\$BCOLOR1" # Background color #8 BCOLOR9="\$BCOLOR1" # Background color #9 BCOLOR10="\$BCOLOR1" # Background color #10 BCOLOR11="\$BCOLOR1" # Background color #11 BCOLOR12="\$BCOLOR1" # Background color #12 BCOLOR13="\$BCOLOR1" # Background color #13 BCOLOR14="\$BCOLOR1" # Background color #14 BCOLOR15="\$BCOLOR1" # Background color #15 BCOLOR16="\$BCOLOR1" # Background color #16 # 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 ( kb/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) # Status bar module icons # Make sure dwm supports this icon/glyph. 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 # Status bar module separators ITEM1_SEPARATOR="\$SEPARATOR" # Separator for ITEM1 ITEM2_SEPARATOR="\$SEPARATOR" # Separator for ITEM2 ITEM3_SEPARATOR="\$SEPARATOR" # Separator for ITEM3 ITEM4_SEPARATOR="\$SEPARATOR" # Separator for ITEM4 ITEM5_SEPARATOR="\$SEPARATOR" # Separator for ITEM5 ITEM6_SEPARATOR="\$SEPARATOR" # Separator for ITEM6 ITEM7_SEPARATOR="\$SEPARATOR" # Separator for ITEM7 ITEM8_SEPARATOR="\$SEPARATOR" # Separator for ITEM8 ITEM9_SEPARATOR="\$SEPARATOR" # Separator for ITEM9 ITEM10_SEPARATOR="\$SEPARATOR" # Separator for ITEM10 ITEM11_SEPARATOR="\$SEPARATOR" # Separator for ITEM11 # Status bar module append # You can append extra text here, such as pango markup, status2d text or simply the output of a command. # It will be added to the end of the item. ITEM1_APPEND="" # Append for ITEM1 ITEM2_APPEND="" # Append for ITEM2 ITEM3_APPEND="" # Append for ITEM3 ITEM4_APPEND="" # Append for ITEM4 ITEM5_APPEND="" # Append for ITEM5 ITEM6_APPEND="" # Append for ITEM6 ITEM7_APPEND="" # Append for ITEM7 ITEM8_APPEND="" # Append for ITEM8 ITEM9_APPEND="" # Append for ITEM9 ITEM10_APPEND="" # Append for ITEM10 ITEM11_APPEND="" # Append 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) # Net format # Format to display the transmitted/received bytes in # # @t - Transmitted # @r - Received # # Example: @t kb/s ITEM6_FORMAT="@t kb/s" 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) CONFIG . "$HOME/.config/speedwm/statusrc.t" if [ ! -e "$HOME/.config/speedwm/statusrc" ]; then mv $HOME/.config/speedwm/statusrc.t $HOME/.config/speedwm/statusrc . $HOME/.config/speedwm/statusrc && echo "Created configuration file" else . $HOME/.config/speedwm/statusrc && echo "Loaded configuration file" fi rm -f "$HOME/.config/speedwm/statusrc.t" ######################################################################### # set version if [ -e "/usr/share/speedwm/speedwm-version" ]; then VER="$(cat /usr/share/speedwm/speedwm-version)" else VER="1.3" fi # set status setstatus() { pgrep -x speedwm > /dev/null || return $SETMETHOD "$@" return } # set loading status setloading() { $SETMETHOD "Loading" return } # print data print() { setstatus "$(printf "$ITEMS_TEXT" | sed "s/stellar_amp/\&/g")" } # set status2d compatible colors setcolors2d() { if [ "$COLORFG" = "true" ] && [ "$BUILTINFG" = "true" ]; then FSETCOLORCMD1="^C0^" FSETCOLORCMD2="^C1^" FSETCOLORCMD3="^C2^" FSETCOLORCMD4="^C3^" FSETCOLORCMD5="^C4^" FSETCOLORCMD6="^C5^" FSETCOLORCMD7="^C6^" FSETCOLORCMD8="^C7^" FSETCOLORCMD9="^C8^" FSETCOLORCMD10="^C9^" FSETCOLORCMD11="^C10^" FSETCOLORCMD12="^C11^" FSETCOLORCMD13="^C12^" FSETCOLORCMD14="^C13^" FSETCOLORCMD15="^C14^" FSETCOLORCMD16="^C15^" fi if [ "$COLORBG" = "true" ] && [ "$BUILTINBG" = "true" ]; then BSETCOLORCMD1="^B0^" BSETCOLORCMD2="^B1^" BSETCOLORCMD3="^B2^" BSETCOLORCMD4="^B3^" BSETCOLORCMD5="^B4^" BSETCOLORCMD6="^B5^" BSETCOLORCMD7="^B6^" BSETCOLORCMD8="^B7^" BSETCOLORCMD9="^B8^" BSETCOLORCMD10="^B9^" BSETCOLORCMD11="^B10^" BSETCOLORCMD12="^B11^" BSETCOLORCMD13="^B12^" BSETCOLORCMD14="^B13^" BSETCOLORCMD15="^B14^" BSETCOLORCMD16="^B15^" fi if [ "$COLORFG" = "true" ] && [ "$BUILTINFG" = "false" ]; then FSETCOLORCMD1="^c${FCOLOR1}^" FSETCOLORCMD2="^c${FCOLOR2}^" FSETCOLORCMD3="^c${FCOLOR3}^" FSETCOLORCMD4="^c${FCOLOR4}^" FSETCOLORCMD5="^c${FCOLOR5}^" FSETCOLORCMD6="^c${FCOLOR6}^" FSETCOLORCMD7="^c${FCOLOR7}^" FSETCOLORCMD8="^c${FCOLOR8}^" FSETCOLORCMD9="^c${FCOLOR9}^" FSETCOLORCMD10="^c${FCOLOR10}^" FSETCOLORCMD11="^c${FCOLOR11}^" FSETCOLORCMD12="^c${FCOLOR12}^" FSETCOLORCMD13="^c${FCOLOR13}^" FSETCOLORCMD14="^c${FCOLOR14}^" FSETCOLORCMD15="^c${FCOLOR15}^" FSETCOLORCMD16="^c${FCOLOR16}^" fi if [ "$COLORBG" = "true" ] && [ "$BUILTINBG" = "false" ]; then BSETCOLORCMD1="^b${BCOLOR1}^" BSETCOLORCMD2="^b${BCOLOR2}^" BSETCOLORCMD3="^b${BCOLOR3}^" BSETCOLORCMD4="^b${BCOLOR4}^" BSETCOLORCMD5="^b${BCOLOR5}^" BSETCOLORCMD6="^b${BCOLOR6}^" BSETCOLORCMD7="^b${BCOLOR7}^" BSETCOLORCMD8="^b${BCOLOR8}^" BSETCOLORCMD9="^b${BCOLOR9}^" BSETCOLORCMD10="^b${BCOLOR10}^" BSETCOLORCMD11="^b${BCOLOR11}^" BSETCOLORCMD12="^b${BCOLOR12}^" BSETCOLORCMD13="^b${BCOLOR13}^" BSETCOLORCMD14="^b${BCOLOR14}^" BSETCOLORCMD15="^b${BCOLOR15}^" BSETCOLORCMD16="^b${BCOLOR16}^" fi } # remove old data rm -f /tmp/itest rm -f /tmp/wstatus rm -f /tmp/iscelsius mkdir -p $HOME/.config/speedwm printf "Loaded $0 $VER\n---\n" # 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 speedwm_status))/" ;; esac # RAM usage ITEM1() { module_ram --print if [ -e "/tmp/module_ram" ]; then cat /tmp/module_ram fi } # Time ITEM2() { module_time --print if [ -e "/tmp/module_time" ]; then cat /tmp/module_time fi } # Date ITEM3() { module_date --print if [ -e "/tmp/module_date" ]; then cat /tmp/module_date fi } # Volume ITEM4() { module_vol --print if [ -e "/tmp/module_vol" ]; then cat /tmp/module_vol fi } # Weather ITEM5() { module_weather --print if [ -e "/tmp/module_weather" ]; then cat /tmp/module_weather fi } # Network traffic ITEM6() { module_net --print if [ -e "/tmp/module_net" ]; then cat /tmp/module_net fi } # Dfmpeg status ITEM7() { module_dfmpeg --print if [ -e "/tmp/module_dfmpeg" ]; then cat /tmp/module_dfmpeg fi } # CPU temp ITEM8() { module_temp --print if [ -e "/tmp/module_temp" ]; then cat /tmp/module_temp fi } # mocp/cmus status ITEM9() { module_music --print if [ -e "/tmp/module_music" ]; then cat /tmp/module_music fi } # Newsboat unreads ITEM10() { module_news --print if [ -e "/tmp/module_news" ]; then cat /tmp/module_news fi } # Battery percentage/charging status ITEM11() { module_bat --print if [ -e "/tmp/module_bat" ]; then cat /tmp/module_bat fi } # Set text variables that we can print later ptext() { # Output of commands # We're doing this so we can manipulate them easily for various reasons. if [ "$ENABLE_ITEM1" = "true" ]; then if [ "$(ITEM1)" != "" ]; then itemcmd1="$(echo "$(ITEM1)" | sed ':a;N;$!ba;s/\n//g')" itemcmd1="$FSETCOLORCMD7$BSETCOLORCMD7 $itemcmd1" else itemcmd1="" fi fi if [ "$ENABLE_ITEM2" = "true" ]; then if [ "$(ITEM2)" != "" ]; then itemcmd2="$(echo "$(ITEM2)" | sed ':a;N;$!ba;s/\n//g')" itemcmd2="$FSETCOLORCMD11$BSETCOLORCMD11 $itemcmd2" else itemcmd2="" fi fi if [ "$ENABLE_ITEM3" = "true" ]; then if [ "$(ITEM3)" != "" ]; then itemcmd3="$(echo "$(ITEM3)" | sed ':a;N;$!ba;s/\n//g')" itemcmd3="$FSETCOLORCMD10$BSETCOLORCMD10 $itemcmd3" else itemcmd3="" fi fi if [ "$ENABLE_ITEM4" = "true" ]; then if [ "$(ITEM4)" != "" ]; then itemcmd4="$(echo "$(ITEM4)" | sed ':a;N;$!ba;s/\n//g')" itemcmd4="$FSETCOLORCMD8$BSETCOLORCMD8 $itemcmd4" else itemcmd4="" fi fi if [ "$ENABLE_ITEM5" = "true" ]; then if [ "$(ITEM5)" != "" ]; then itemcmd5="$(echo "$(ITEM5)" | sed ':a;N;$!ba;s/\n//g')" itemcmd5="$FSETCOLORCMD3$BSETCOLORCMD3 $itemcmd5" else itemcmd5="" fi fi if [ "$ENABLE_ITEM6" = "true" ]; then if [ "$(ITEM6)" != "" ]; then itemcmd6="$(echo "$(ITEM6)" | sed ':a;N;$!ba;s/\n//g')" itemcmd6="$FSETCOLORCMD6$BSETCOLORCMD6 $itemcmd6" else itemcmd6="" fi fi if [ "$ENABLE_ITEM7" = "true" ]; then if [ "$(ITEM7)" != "" ]; then itemcmd7="$(echo "$(ITEM7)" | sed ':a;N;$!ba;s/\n//g')" itemcmd7="$FSETCOLORCMD5$BSETCOLORCMD5 $itemcmd7" else itemcmd7="" fi fi if [ "$ENABLE_ITEM8" = "true" ]; then if [ "$(ITEM8)" != "" ]; then itemcmd8="$(echo "$(ITEM8)" | sed ':a;N;$!ba;s/\n//g')" itemcmd8="$FSETCOLORCMD4$BSETCOLORCMD4 $itemcmd8" else itemcmd8="" fi fi if [ "$ENABLE_ITEM9" = "true" ]; then if [ "$(ITEM9)" != "" ]; then itemcmd9="$(echo "$(ITEM9)" | sed ':a;N;$!ba;s/\n//g')" itemcmd9="$FSETCOLORCMD2$BSETCOLORCMD2 $itemcmd9" else itemcmd9="" fi fi if [ "$ENABLE_ITEM10" = "true" ]; then if [ "$(ITEM10)" != "" ]; then itemcmd10="$(echo "$(ITEM10)" | sed ':a;N;$!ba;s/\n//g')" itemcmd10="$FSETCOLORCMD9$BSETCOLORCMD9 $itemcmd10" else itemcmd10="" fi fi if [ "$ENABLE_ITEM11" = "true" ]; then if [ "$(ITEM11)" != "" ]; then itemcmd11="$(echo "$(ITEM11)" | sed ':a;N;$!ba;s/\n//g')" itemcmd11="$FSETCOLORCMD8$BSETCOLORCMD8 $itemcmd11" else itemcmd11="" fi fi # Clickability if [ "$CLICKABLE" = "true" ]; then ITEMS_TEXT="$(echo "$ITEM_ORDER" | sed "s/^[[:space:]]*//g; 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")" else ITEMS_TEXT="$(echo "$ITEM_ORDER" | sed "s/^[[:space:]]*//g; s|@10|$itemcmd10|; s|@11|$itemcmd11|; s|@1|$itemcmd1|; s|@2|$itemcmd2|; s|@3|$itemcmd3|; s|@4|$itemcmd4|; s|@5|$itemcmd5|; s|@6|$itemcmd6|; s|@7|$itemcmd7|; s|@8|$itemcmd8|; s|@9|$itemcmd9|; s|%|%%|g")" fi print } # base base() { ptext sleep $REFRESHDELAY base } setloading setcolors2d ptext base printf "$0: Stopped printing." exit 0