├── LICENSE ├── README.md └── lemonbar.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Sid Williams 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple-Lemonbar 2 | A simple setup for lemonbar. 3 | 4 | ![Lemonbar screenshot](https://i.imgur.com/rPCohVJ.png) 5 | 6 | ## Prerequisites 7 | [xdotool](https://github.com/jordansissel/xdotool) 8 | [Font Awesome](https://github.com/FortAwesome/Font-Awesome) 9 | [alsa-utils](https://github.com/gittup/alsa-utils) 10 | 11 | ## Installation 12 | 1. Move `lemonbar.sh` to a proper directory (for EX. `/usr/local/bin`). 13 | 2. Auto start the script piped into lemon bar when your WM/DM starts. Below is an example of how I call this script in openbox (autostart file at `~/.config/openbox/autostart`) 14 | 2. `( sleep 1s && bash /usr/local/bin/lemonbar/lemonbar.sh | lemonbar -p -F#FFFFFFFF -B#FF222222 -f "DejaVu Sans Mono"-8 -f FontAwesome-8) &` 15 | 3. You need to be sure to give `lemonbar` the arguments `-p -f "Font of your choosing"-8 -f FontAwesome-8`. The first font can be any of your choosing but the second one needs to be FontAwesome. 16 | -------------------------------------------------------------------------------- /lemonbar.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | Clock(){ 4 | TIME=$(date "+%H:%M:%S") 5 | echo -e -n " \uf017 ${TIME}" 6 | } 7 | 8 | Cal() { 9 | DATE=$(date "+%a, %m %B %Y") 10 | echo -e -n "\uf073 ${DATE}" 11 | } 12 | 13 | ActiveWindow(){ 14 | len=$(echo -n "$(xdotool getwindowfocus getwindowname)" | wc -m) 15 | max_len=70 16 | if [ "$len" -gt "$max_len" ];then 17 | echo -n "$(xdotool getwindowfocus getwindowname | cut -c 1-$max_len)..." 18 | else 19 | echo -n "$(xdotool getwindowfocus getwindowname)" 20 | fi 21 | } 22 | 23 | Battery() { 24 | BATTACPI=$(acpi --battery) 25 | BATPERC=$(echo $BATTACPI | cut -d, -f2 | tr -d '[:space:]') 26 | 27 | if [[ $BATTACPI == *"100%"* ]] 28 | then 29 | echo -e -n "\uf00c $BATPERC" 30 | elif [[ $BATTACPI == *"Discharging"* ]] 31 | then 32 | BATPERC=${BATPERC::-1} 33 | if [ $BATPERC -le "10" ] 34 | then 35 | echo -e -n "\uf244" 36 | elif [ $BATPERC -le "25" ] 37 | then 38 | echo -e -n "\uf243" 39 | elif [ $BATPERC -le "50" ] 40 | then 41 | echo -e -n "\uf242" 42 | elif [ $BATPERC -le "75" ] 43 | then 44 | echo -e -n "\uf241" 45 | elif [ $BATPERC -le "100" ] 46 | then 47 | echo -e -n "\uf240" 48 | fi 49 | echo -e " $BATPERC%" 50 | elif [[ $BATTACPI == *"Charging"* && $BATTACPI != *"100%"* ]] 51 | then 52 | echo -e "\uf0e7 $BATPERC" 53 | elif [[ $BATTACPI == *"Unknown"* ]] 54 | then 55 | echo -e "$BATPERC" 56 | fi 57 | } 58 | 59 | Wifi(){ 60 | WIFISTR=$( iwconfig wlp1s0 | grep "Link" | sed 's/ //g' | sed 's/LinkQuality=//g' | sed 's/\/.*//g') 61 | if [ ! -z $WIFISTR ] ; then 62 | WIFISTR=$(( ${WIFISTR} * 100 / 70)) 63 | ESSID=$(iwconfig wlp1s0 | grep ESSID | sed 's/ //g' | sed 's/.*://' | cut -d "\"" -f 2) 64 | if [ $WIFISTR -ge 1 ] ; then 65 | echo -e "\uf1eb ${ESSID} ${WIFISTR}%" 66 | fi 67 | fi 68 | } 69 | 70 | Sound(){ 71 | NOTMUTED=$( amixer sget Master | grep "\[on\]" ) 72 | if [[ ! -z $NOTMUTED ]] ; then 73 | VOL=$(awk -F"[][]" '/dB/ { print $2 }' <(amixer sget Master) | sed 's/%//g') 74 | if [ $VOL -ge 85 ] ; then 75 | echo -e "\uf028 ${VOL}%" 76 | elif [ $VOL -ge 50 ] ; then 77 | echo -e "\uf027 ${VOL}%" 78 | else 79 | echo -e "\uf026 ${VOL}%" 80 | fi 81 | else 82 | echo -e "\uf026 M" 83 | fi 84 | } 85 | 86 | Language(){ 87 | CURRENTLANG=$(head -n 1 /tmp/uim-state) 88 | if [[ $CURRENTLANG == *"English"* ]] ; then 89 | echo -e " \uf0ac ENG" 90 | elif [[ $CURRENTLANG == *"Katakana"* ]] ; then 91 | echo -e " \uf0ac カタカナ" 92 | elif [[ $CURRENTLANG == *"Hiragana"* ]] ; then 93 | echo -e " \uf0ac ひらがな" 94 | else 95 | echo -e " \uf0ac \uf128" 96 | fi 97 | } 98 | 99 | while true; do 100 | echo -e "%{l}$(Language)" "%{c}$(ActiveWindow)" "%{r}$(Wifi) $(Battery) $(Sound) $(Clock) $(Cal)" 101 | sleep 0.1s 102 | done 103 | --------------------------------------------------------------------------------