Giter Club home page Giter Club logo

dwm-bar's Introduction

dwm-bar

A modular statusbar for dwm screenshot

Table of Contents

⚠️ While I try to be as active as I can be, it may take me some time to resolve issues as I am much busier these days than when I started this project. I appreciate ALL contributions and will try my best to respond as soon as I am able to. Thank you for understanding :) - @joestandring

Installation

  1. Clone and enter the repository:
git clone https://github.com/joestandring/dwm-bar
cd dwm-bar
  1. (Optional) Install Dependencies from dep/YourDisto.txt. This will install dependencies for ALL functions so consider excluding ones you do not plan to use. These can be found at the top of each bar function.
sudo xbps-install -S $(cat dep/void.txt) # Void
sudo pacman -S $(cat dep/arch.txt)       # Arch
sudo dnf install $(cat dep/fedora.txt)   # Fedora

⚠️ There are no dnf packages for spotifyd, pamixer and cmus. If you want to utilise these packages, please install them manually as shown in the corresponding gihub repos.

  1. (Optional) If you plan to use unicode identifiers, you should install a font which includes these (Nerd Fonts, siji)
  2. Enable/disable desired functions (see Configuration).
  3. Run the script
./dwm_bar.sh

Configuration

dwm-bar will require some setup before it can be used.

Enabling Functions

Functions can be enabled by adding them to the import and upperbar variable in dwm_bar.sh. By default, all available functions will be commented here. If you are using the extrabar patch, functions can also be added to lowerbar to appear on the bottom of the screen. Some more intensive functions are parallelized to prevent the bar freezing. These are imported the same as regular functions but added to the parallelize() function first. These use different names to regular functions and are commented out by default in dwm_bar.sh.

To enable dwm_battery and dwm_backlight on the top bar and dwm_pulse and dwm_weather (parallelized) on the bottom bar, for example, you should use:

# Import the modules
. "$DIR/bar-functions/dwm_battery.sh"
. "$DIR/bar-functions/dwm_backlight.sh"
. "$DIR/bar-functions/dwm_pulse.sh"
. "$DIR/bar-functions/dwm_weather.sh"

parallelize() {
    while true
    do
        printf "Running parallel processes\n"
        dwm_weather &
        sleep 5
    done
}
parallelize &

# Update dwm status bar every second
while true
do
    # Append results of each func one by one to the upperbar string
    upperbar=""
    upperbar="$upperbar$(dwm_battery)"
    upperbar="$upperbar$(dwm_backlight)"
   
    # Append results of each func one by one to the lowerbar string
    lowerbar=""
    lowerbar="$lowerbar$(dwm_pulse)"
    lowerbar="$lowerbar$(__DWM_BAR_WEATHER__)"
    
    #xsetroot -name "$upperbar"
    
    # Uncomment the line below to enable the lowerbar 
    xsetroot -name "$upperbar;$lowerbar"
    sleep 1
done

Refresh rate

If updating the bar every second is an issue, you can change the sleep amount of both regular and parallelized functions in dwm_bar.sh.

Configuring functions

Some functions, such as dwm_weather require additional setup and will be outlined with a comment where this is the case.

Identifiers

Unicode or plaintext identifiers can be used by altering the $IDENTIFIER value in dwm_bar.sh. For example, when set to "unicode", dwm_mail will display:

[📫 0]

Otherwise, when not set it will display:

[MAIL 0]

Current Functions

dwm_alsa

Displays the current master volume of ALSA

[🔉 55%]

Dependencies: alsa-utils

dwm_pulse

Displays the current master volume of PulseAudio

[🔉 55%]

Dependencies: pamixer

dwm_battery

Displays battery level and status

[🔋 100% full]

dwm_countdown

Displays the status of countdown

[⏳ 00:10:00]

Dependencies: countdown.sh

dwm_alarm

Displays upcoming alarms from alarm

[⏰ 22:30:00]

Dependencies: alarm.sh

dwm_keyboard

Displays the current keyboard layout

[⌨ gb]

Dependencies: xorg-setxkbmap

dwm_resources

Displays information regarding memory, CPU temperature, and storage

[🖥 MEM 1.3Gi/15Gi CPU 45C STO 2.3G/200G: 2%]

dwm_cmus

Displays current cmus status, artist, track, position, duration, and shuffle

[▶ The Unicorns - Tuff Ghost 0:43/2:56 🔀]

Dependencies: cmus

dwm_mpc

Displays current mpc status, artist, track, position, duration, and shuffle

[▶ The Unicorns - Tuff Ghost 0:43/2:56 🔀]

Dependencies: mpc

dwm_spotify

Displays current Spotify status, artist, track, and duration

Either the official Spotify client or spotifyd can be used. Unfortunately, only spotifyd can provide track position and shuffle status

[▶ The Unicorns - Tuff Ghost 0:43/2:56 🔀]

Dependencies: spotify/spotifyd, playerctl

dwm_date

Displays the current date and time

[🕰 Mon 06-05-19 21:31:58]

dwm_mail

Displays the current number of emails in an inbox

[📫 2]

dwm_weather

Displays the current weather provided by wttr.in

Please remember wttr.in has a limited number of requests, so this module may occasionally not be able to recieve weather information when experiencing high traffic.

[☀ +20°C]

dwm_networkmanager

Displays the current network connection, private IP, and public IP using NetworkManager

[🌐 enp7s0: 192.168.0.1/24 | 185.199.109.153]

Dependencies: NetworkManager, curl

dwm_wpa

Displays the current network connection and private IP using wpa_cli

[襤 My-Wifi 192.168.0.3]

Dependencies: wpa_cli

dwm_vpn

Displays the current VPN connections with OpenVPN or Wireguard

[🔒 Sweden - Stockholm]

Dependencies: NetworkManager, NetworkManager-openvpn (for OpenVPN connections)

dwm_ccurse

Displays the next appointment from calcurse

[💡 18/04/19 19:00 20:00 Upload dwm_ccurse]

Dependencies: calcurse

dwm_transmission

Displays the current status of a torrent with transmission-remote

[⏬ archlinux-2019.06.01... | 92% 1min ⬆3.4 ⬇1.5]

Dependencies: transmission-remote

dwm_backlight

Displays the current backlight level with xbacklight

[☀ 80]

Dependencies: xbacklight

dwm_connman

Shows network information IP, SSID, WLan strength (if connected to WLan) using connman.

[🌐 192.169.189.12 HomeNetworkName 53%]

Dependencies: connman

dwm_loadavg

Displays the average system load

[⏱ 0.14 0.17 0.18]

dwm_solar_panel

Displays how much power is being produced from your solar panels

[💡 3.012 W ]

dwm_currency

Displays the current rate of your currency in comparison to the USD provided by rate.sx

[💡 1.225 ]

Dependencies: curl

dwm_network_speed

Displays the speed of download and upload.

[李 0KB/s 0KB/s]

Contributing

See CONTRIBUTING.md before contributing.

Acknowledgements

Code for some functions was modified from:

dwm-bar's People

Contributors

0x14307 avatar bdealbuquerque avatar franexmo81 avatar friendlyneighborhoodshane avatar joestandring avatar jvcanavarro avatar lquenti avatar luchianmihai avatar merothh avatar mvezer avatar ntrp avatar oxzi avatar seriousm4x avatar tuxinal avatar vincenzo-petrolo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dwm-bar's Issues

Big CPU consumption

Including some modules, like dwm_data.sh or dwm_battery.sh results in big CPU consumption(stable 20%) leading to fast battery discharging. Maybe something wrong with my setup.

OS: Gentoo/Linux

/etc/X11/Sessions/dwm (managed by Gentoo)

DIR=${HOME}/.dwm
if [ -f "${DIR}"/dwmrc ]; then
	/bin/sh "${DIR}"/dwmrc &
else
	while true; do
		xsetroot -name "`date`"
		sleep 1
	done &
fi
exec /usr/bin/dwm

It's crucial here, that default Gentoo's script(which is used while there's no ~/.dwm/dwmrc) uses same command date and doesn't consume CPU).
~/.dwm/dwmrc is symlink to ~/Projects/dwm-bar/dwm-bar.sh and its content:
Just default dwm-bar.sh with enabled dwm-alsa.sh and dwm-keyboard.sh and commented parallelize function. As was mentioned above, enabling some essential modules like dwm_data.sh results in big CPU consumption.

#!/bin/sh

# A modular status bar for dwm
# Joe Standring <[email protected]>
# GNU GPLv3

# Dependencies: xorg-xsetroot

# Import functions with "$include /route/to/module"
# It is recommended that you place functions in the subdirectory ./bar-functions and use: . "$DIR/bar-functions/dwm_example.sh"

# Store the directory the script is running from
LOC=$(readlink -f "$0")
DIR=$(dirname "$LOC")

echo $LOC
echo $DIR

# Change the appearance of the module identifier. if this is set to "unicode", then symbols will be used as identifiers instead of text. E.g. [📪 0] instead of [MAIL 0].
# Requires a font with adequate unicode character support
export IDENTIFIER="unicode"

# Change the charachter(s) used to seperate modules. If two are used, they will be placed at the start and end.
export SEP1="["
export SEP2="]"

# Import the modules
#. "$DIR/bar-functions/dwm_alarm.sh"
. "$DIR/bar-functions/dwm_alsa.sh"
#. "$DIR/bar-functions/dwm_backlight.sh"
#. "$DIR/bar-functions/dwm_battery.sh"
#. "$DIR/bar-functions/dwm_ccurse.sh"
#. "$DIR/bar-functions/dwm_cmus.sh"
#. "$DIR/bar-functions/dwm_connman.sh"
#. "$DIR/bar-functions/dwm_countdown.sh"
#. "$DIR/bar-functions/dwm_currency.sh"
#. "$DIR/bar-functions/dwm_date.sh"
. "$DIR/bar-functions/dwm_keyboard.sh"
#. "$DIR/bar-functions/dwm_loadavg.sh"
#. "$DIR/bar-functions/dwm_mail.sh"
#. "$DIR/bar-functions/dwm_mpc.sh"
#. "$DIR/bar-functions/dwm_networkmanager.sh"
#. "$DIR/bar-functions/dwm_pulse.sh"
#. "$DIR/bar-functions/dwm_resources.sh"
#. "$DIR/bar-functions/dwm_spotify.sh"
#. "$DIR/bar-functions/dwm_transmission.sh"
#. "$DIR/bar-functions/dwm_vpn.sh"
#. "$DIR/bar-functions/dwm_weather.sh"

# parallelize() {
#     while true
#     do
#         printf "Running parallel processes\n"
#         #dwm_networkmanager &
#         #dwm_weather &
#         sleep 5
#     done
# }
# parallelize &

# Update dwm status bar every second
while true
do
    # Append results of each func one by one to the upperbar string
    upperbar=""
    #upperbar="$upperbar$(dwm_alarm)"
    upperbar="$upperbar$(dwm_alsa)"
    #upperbar="$upperbar$(dwm_backlight)"
    #upperbar="$upperbar$(dwm_battery)"
    #upperbar="$upperbar$(dwm_ccurse)"
    #upperbar="$upperbar$(dwm_cmus)"
    #upperbar="$upperbar$(dwm_connman)"
    #upperbar="$upperbar$(dwm_countdown)"
    #upperbar="$upperbar$(dwm_currency)"
    #upperbar="$upperbar$(dwm_date)"
    upperbar="$upperbar$(dwm_keyboard)"
    #upperbar="$upperbar$(dwm_loadavg)"
    #upperbar="$upperbar$(dwm_mail)"
    #upperbar="$upperbar$(dwm_mpc)"
    #upperbar="$upperbar$(dwm_pulse)"
    #upperbar="$upperbar$(dwm_resources)"
    #upperbar="$upperbar$(dwm_spotify)"
    #upperbar="$upperbar$(dwm_transmission)"
    #upperbar="$upperbar$(dwm_vpn)"
    #upperbar="$upperbar${__DWM_BAR_NETWORKMANAGER__}"
    #upperbar="$upperbar${__DWM_BAR_WEATHER__}"
   
    # Append results of each func one by one to the lowerbar string
    lowerbar=""
    
    xsetroot -name "$upperbar"
    # Uncomment the line below to enable the lowerbar 
    #xsetroot -name "$upperbar;$lowerbar"
    sleep 1
done

Missing network traffic and sensors features

Hello, thank you for the work on this.
I have been searching for a module available about network traffics (download/upload) but cannot find it also how can I show CPU temperature (like from libsensors).

weird text error in cmus plugin

this only happens on specific artists for some reason, but it shows the word "tag artistsort", the artists name twice, then the title track and everything else.

Screenshot from 2021-04-24 11-03-19

binclock script

I am trying to add binclock script to dwm-bar.

`#!/usr/bin/python3

'''
binclock
binclock outputs the current time in binary clock format using unicode braille
characters.
Created Aug 2015 by cbarox
'''

import datetime

_BRAILLE_ZERO = 0x2800

maps bit to the value for braille

_BRAILLE_MAP1 = [0x40, 0x04, 0x02, 0x01]
_BRAILLE_MAP2 = [0x80, 0x20, 0x10, 0x08]

converts a 2 digit number to binary clock form

def num2clock(num):
d1, d2 = int(num / 10), int(num % 10)
brl = _BRAILLE_ZERO
for i in range(4):
if (d1 & (2i)):
brl |= _BRAILLE_MAP1[i]
if (d2 & (2
i)):
brl |= _BRAILLE_MAP2[i]
return brl

result = ""
now = datetime.datetime.now()
t = [now.hour, now.minute, now.second]
for i in t:
result += chr(num2clock(i))
print(result)`

I get an error about BRAILLE.

Any tips most welcome.

status bar is not showing

after applying the dwm barpadding patch status has been hidden but dwm-bar.sh is running but showing on the bar

dwm-bar

Typo

In the CONTRIBUTING.md file, it says prokect instead of project.

Network (using networkmanager function) doesn't update after changing wifi networks

#!/bin/sh

# A modular status bar for dwm
# Joe Standring <[email protected]>
# GNU GPLv3

# Dependencies: xorg-xsetroot

# Import functions with "$include /route/to/module"
# It is recommended that you place functions in the subdirectory ./bar-functions and use: . "$DIR/bar-functions/dwm_example.sh"

# Store the directory the script is running from
LOC=$(readlink -f "$0")
DIR=$(dirname "$LOC")

# Change the appearance of the module identifier. if this is set to "unicode", then symbols will be used as identifiers instead of text. E.g. [📪 0] instead of [MAIL 0].
# Requires a font with adequate unicode character support
export IDENTIFIER="unicode"

# Change the charachter(s) used to seperate modules. If two are used, they will be placed at the start and end.
export SEP1=" | "
# export SEP2="]"

# Import the modules
. "$DIR/bar-functions/dwm_countdown.sh"
. "$DIR/bar-functions/dwm_alarm.sh"
. "$DIR/bar-functions/dwm_transmission.sh"
. "$DIR/bar-functions/dwm_cmus.sh"
. "$DIR/bar-functions/dwm_mpc.sh"
. "$DIR/bar-functions/dwm_spotify.sh"
. "$DIR/bar-functions/dwm_resources.sh"
. "$DIR/bar-functions/dwm_battery.sh"
. "$DIR/bar-functions/dwm_mail.sh"
. "$DIR/bar-functions/dwm_backlight.sh"
. "$DIR/bar-functions/dwm_alsa.sh"
. "$DIR/bar-functions/dwm_pulse.sh"
. "$DIR/bar-functions/dwm_weather.sh"
. "$DIR/bar-functions/dwm_vpn.sh"
. "$DIR/bar-functions/dwm_networkmanager.sh"
. "$DIR/bar-functions/dwm_keyboard.sh"
. "$DIR/bar-functions/dwm_ccurse.sh"
. "$DIR/bar-functions/dwm_date.sh"
. "$DIR/bar-functions/dwm_connman.sh"
. "$DIR/bar-functions/dwm_loadavg.sh"
. "$DIR/bar-functions/dwm_currency.sh"

parallelize() {
    while true
    do
        printf "Running parallel processes\n"
        # dwm_weather &
        dwm_networkmanager 
        sleep 10
    done
}
parallelize &

# Update dwm status bar every second
while true
do
    # Append results of each func one by one to the upperbar string
    upperbar=""
    # upperbar="$upperbar$(dwm_connman)"
    # upperbar="$upperbar$(dwm_countdown)"
    # upperbar="$upperbar$(dwm_alarm)"
    # upperbar="$upperbar$(dwm_transmission)"
    # upperbar="$upperbar$(dwm_cmus)"
    # upperbar="$upperbar$(dwm_mpc)"
    # upperbar="$upperbar$(dwm_spotify)"
    # upperbar="$upperbar$(dwm_resources)"
    upperbar="$upperbar$(dwm_battery)"
    # upperbar="$upperbar$(dwm_mail)"
    upperbar="$upperbar$(dwm_backlight)"
    # upperbar="$upperbar$(dwm_alsa)"
    upperbar="$upperbar$(dwm_pulse)"
    # upperbar="$upperbar${__DWM_BAR_WEATHER__}"
    # upperbar="$upperbar$(dwm_vpn)"
    upperbar="$upperbar${__DWM_BAR_NETWORKMANAGER__}"
    # upperbar="$upperbar$(dwm_keyboard)"
    # upperbar="$upperbar$(dwm_ccurse)"
    upperbar="$upperbar$(dwm_date)"
    # upperbar="$upperbar$(dwm_loadavg)"
    # upperbar="$upperbar$(dwm_currency)"
   
    # Append results of each func one by one to the lowerbar string
    lowerbar=""

    
    xsetroot -name "$upperbar"
    
    # Uncomment the line below to enable the lowerbar 
#    xsetroot -name "$upperbar;$lowerbar"
    sleep 0.3
done

That's my current dwm-bar configuration. My problem is the bar displays the network the system was connected to at boot, and if at any point the network changes, dwm-bar does not show that and has to be restarted to show the change.
Currently on Arch-Linux, zen kernel, using dwm 6.2.

Specify the refresh frequency for each plugin

I think some plugins like the resources weather plugins don't need to be updated every second. So I'm writing to request a new feature that sets the refresh rate for each plugin and THANK you for sharing this great job.

Weather service wttr.in ran out of requests ...

The weather service wttr.in ran out of requests just now (for today).

Sorry, we processed more than 1M requests today and we ran out of our datasource capacity.
We hope to solve the problem as soon as possible, so you can enjoy
your favourite weather service 24x365 even if it rains or snows.

We will solve the problem as soon as possible.
follow @igor_chubin for the updates. 

You might want to remind people to slow down requests a bit, or add some reminds in README, if they meet unexpected problems on the weather module.

Crash in Ubuntu20.04

Hi! I'm new to dwm and have a problem in running dwm-bar. What I did:

  1. Install dwm using apt
  2. log out gnome and log in dwm
  3. run ./dwm_bar.sh

Then, it just crashed and took me back to the login screen. How to solve it? Cheers!

dwm bar not showing

when i attempt to start the stock shell script, it doesnt show up on the upperbar. output in the terminal is just "Running parallel processes"

how do I show dwm-bar on all my monitors?

Hey there! Great job, btw!

Is there any way I can show dwm-bar on all my monitors, not just the active one?
If I switch static const int statusmon = 'A' to -1, it doesn't show at all...

Thanks a bunch!

Parallelizing non-local processes

Parallelizing internet related tasks

I'm opening this issue because i wanted to make a pull request, with some change to the code, in order to improve this bar that is amazing.

Why an issue

Well, if you don't have a powerful connection, that's my case, you might have noticed that when getting weather forecast, as an example, the bar stops working, and all the real time data,such as battery percentage or time, that i need become useless.

How to solve this

I solved it on my machine, by creating a separation in modules:

  • Local modules : All that modules that work in your local area network, such as date, battery, solar panels,backlight,audio,resources...
  • Non-local modules : All that modules that make use of the world area network, such as weather forecast, external ip...

As a solution i would not use local variable for non-local modules, but environment variables named as follows: __DWM_BAR_XXXXX_MODULE__

And here is the weather module code: (Note that 2 lines only has changed:

      LOCATION=Modica

      printf "%s" "$SEP1"
      if [ "$IDENTIFIER" = "unicode" ]; then
>>        export __DWM_BAR_WEATHER_MODULE__="${SEP1} $(curl -s wttr.in/$LOCAT
  ION?format=1) ${SEP2}"
      #   printf "%s" "$(curl -s wttr.in/$LOCATION?format=1)"
      else
>>        export __DWM_BAR_WEATHER_MODULE__="${SEP1}WEA $(curl -s wttr.in/$LO
  CATION?format=1 | grep -o "[0-9].*") ${SEP2}"
      #   printf "WEA %s" "$(curl -s wttr.in/$LOCATION?format=1 | grep -o "[0
  -9].*")"
      fi
  }

  dwm_weather

While in the dwm_bar.sh i would add a function named parallelize() that calls the non-local modules, note that this runs on background so it doesn't stops the other local modules which are running.
Now i describe its behaviour, at the first time, if the DWM_BAR_WEATHER_MODULE has not been set, it simply returns an error and doesn't add it to the bar, but when it finishes fetching it, then it will update the environment variable and the next second it will show up in the bar.

parallelize() {
        while true
        do
                dwm_weather
        done
}

# call to parallelize
parallelize &


# Update dwm status bar every second
while true
do

    # Append results of each func one by one to a string
    dispstr=""
    dispstr="$dispstr$(dwm_resources)"
    dispstr="$dispstr$(dwm_battery)"
    dispstr="$dispstr$(dwm_backlight)"
    dispstr="$dispstr$(dwm_pulse)"
    dispstr="$dispstr${__DWM_BAR_WEATHER_MODULE__}"
    dispstr="$dispstr$(dwm_date)"

    xsetroot -name "$dispstr"
    sleep 1

done

Conclusion

By applying this to all modules we can achieve real-time status bar without stopping it in case of slow internet connection speed.

Read/write disk speed functions

It would be cool if there was a dwm_disk_io function from /sys/class/block/*/stat. In the form of disk read/write speed. Read is the third and write is the seventh columns.

I tried to write myself, but it didn't work (

dwm_mpd? :)

not a pro at shell scripting :) but I am eager for the dwm_mpd function, any chance it will come out anytime soon?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.