Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Bspwm tutorial
- By [**Chrysostomus**](https://classicforum.manjaro.org/index.php?action=profile;u=4519) From [classicforum.manjaro.org](https://classicforum.manjaro.org/index.php?topic=18970.0) 21/12/2014
- ## **Table of contents**
- [TOC]
- ------
- ## **What is it?**
- Bspwm (binary space partitioning window manager) is fairly young window manager, and in active development. Like openbox, it can be used with desktop environment like xfce or lxqt, or on its own. It is particularly suited for people who don't have workflow set in stone.
- It may not be the lightest nor the most stable window manager out there, but it makes up for it with ease of use and powerful features. That is not to say that it is heavy or unstable. I think it is lighter than openbox, just not as tiny and minimalistic as dwm or monsterwm or as unshakable as xmonad.
- Bspwm is easy to configure, but tricky to setup if you don't know what you are doing. To remedy this, I wrote this little guide to help.
- ### **Features:**
- Watch this screencast to understand:
- 
- Like herbstluftwm, bspwm is driven with terminal commands that can be bound to hotkeys. Also like herbstluftwm, the configuration file is just autostart file that runs commands for setting rules.
- Bspwm is a tiling window manager like dwm, awesome, i3 or xmonad. This means that windows do not usually overlap with each other. Instead, all the available space on screen is automatically divided between them. This saves time and ensures that screen real-estate is used efficiently. Bspwm can also float windows. Unlike dwm or xmonad, you can move windows with mouse without making them floating. Unlike awesome wm, you can have tiled and floating windows in same workspace. Otherwise mouse controls are quite close to awesome wm.
- Bspwm features a combination of automatic tiling (like awesome, dwm and xmonad) and manual tiling (like herbstluftwm, musca and i3). When you open a new window, one of the existing windows is divided in half (or whatever splitting ratio you have set) to make room for the new window. There are no predefined layouts. Open more windows, and they form a spiral. However, you can manually choose where the new window is created, or split existing window and move another window to the split.
- Tiling window managers require you to use workspaces or tags actively, since everything is usually visible and not minimized. Moving things between them is usually easier than in most stacking wms. You can add and delete workspaces and give them names. You can also make windows 'sticky', which means they are visible in all workspaces.
- Bspwm also has option to have gaps between the windows, which can be adjusted on the fly. It also has pseudo-floating windows, which are placed like tiling windows, but can have any size.
- ### **Who should use bspwm?**
- Many tiling wm users like to have very specific workflow. Browser always goes to "web" workspace and so on. While this is also possible with bspwm, its combination of manual and automatic tiling make it suited for unplanned or irregular workflow. Windows just go to a reasonable place, and adjusting things is intuitive, if something feels weird.
- Tiling wms are good match for small screens, because all screen real-estate is used efficiently and managing maximized windows is simple.
- They are also suited for big screens, because they save time you would otherwise use moving windows around.
- In particular bspwm is suited for people who like tweak and tinker with stuff. You won't be getting out of the bix experience, but you'll be making things work just the way you like them.
- Also, it is quite light. It works very smoothly even on older hardware, and won't cause suicidal feelings if you run it on raspberry pi. I think.
- ### **Who should steer clear of bspwm?**
- \- The learning curve can be harsh if you are only used to running a full desktop environment. So if you dislike learning new stuff, bspwm probably is not for you.
- \- Bspwm sometimes crashes, if you have too many floating dialog windows open (for example, when editing colors of lxterminal or searching stuff with geany or extracting .tar files with fileroller). This can be a deal breaker for some people if you save your open text files rarely.
- \- Plugging in additional monitors or projectors requires some manual intervention or scripting. So if you are giving lectures often on varying locations, be aware that it can br more cumbersome with bspwm (requires two commands from commandline, or preconfigured script).
- \- If you dislike building stuff yourself and want things to just work, bspwm might not be your cup of tea.
- ## **How to install bspwm:**
- Manjaro devs have made this very easy for us.
- ```bash
- sudo pacman -Syu bspwm
- ```
- Bspwm does not provide panel or hotkeys by it self. For hotkeys you can use xbindkeys, but sxhkd is recommended instead. Following command installs some commonly used utilities:
- ```bash
- sudo pacman -S sxhkd bar dmenu xdo xdotool xtitle sutils
- ```
- This includes sxhkd for hotkeys and dmenu for starting apps. The rest is for the example bar and some sxhkd functions.
- If you wish to use latest version of bspwm, run instead
- ```bash
- sudo yaourt -S bspwm-git
- ```
- This can give you access to new features like mouse_follows_focus.
- Bspwm does not automatically create desktop or session files that could be run from display manager (graphical login screen). These if you want to use dm, you need to manually copy them from
- https://github.com/baskerville/bspwm/tree/master/contrib/lightdm to
- ```bash
- /usr/bin/bspwm-session
- ```
- and
- ```bash
- /usr/share/xsessions/bspwm.desktop
- ```
- . Copying to this location requires sudo rights. After this, bspwm should be available as option in your login screen.
- Alternatively, you can run bspwm from console with command startx. For that you need to create/configure
- ```bash
- ~/.xinitrc
- ```
- (script that is run when you isse command startx) to start bspwm (and any other programs you wish to run, such as nitrogen for bacground, xfsettingsd to make xfce4-settings-manager work and so on). An extremely minimal .xinitrc would contain just:
- ```bash
- sxhkd &
- exec bspwm
- ```
- Make sure everything is placed before exec bspwm and had & after it like sxhkd does in the example.
- Now you can launch bspwm (maybe), but it is really not usable yet. Copy
- https://github.com/baskerville/bspwm/blob/master/examples/bspwmrc to
- ```bash
- ~/.config/bspwm/bspwmrc
- ```
- and run
- ```bash
- chmod +x ~/.config/bspwm/bspwmrc
- ```
- This gives you the default configuration file of bspwm, and marks it executable.
- Also copy https://github.com/baskerville/bspwm/blob/master/examples/sxhkdrc to
- ```bash
- ~/.config/sxhkd/sxhkdrc
- ```
- to get default key bindings of bspwm. You can check the binds from here, and edit them as you wish. Syntax is really simple, just follow the pattern of the file.
- ------
- ## **How to use bspwm:**
- \- mouse controls
- If you have
- `bspc config focus_follows_pointer true`
- In your bspwmrc, you can move focus by moving your mouse over them.
- Otherwise your mouse controls depend on your sxhkdrc. If you have there
- ```bash
- ~button1
- bspc pointer -g focus
- ```
- You can focus windows by clicking them. A must have if you don't use focus_follows_pointer
- You can focus windows by clicking them. A must have if you don't use focus_follows_pointer
- Since you copied the default config, your sxhkdrc also has:
- ```bash
- super + button{1-3}
- bspc pointer -g {move,resize_side,resize_corner}
- super + !button{1-3}
- bspc pointer -t %i %i
- super + @button{1-3}
- bspc pointer -u
- ```
- This means that when you hold the super key, you can move windows with left mouse drag and resize them by dragging with other mouse buttons. Dragging tiled window over another switches their places, and floating windows just float like usual.
- I personally use mygtkmenu to toggle window properties (tiled, floating, pseudo-floating, fullscreen, monocle) with mouse. My sxhkdrc something like
- Mod5 + !button1
- mytgkmenu /path/to/menu/file/
- So that when I hold alt_gr and click with mouse, a nice pops up. My menufile can be found from xxxxx
- Keyboard controls:
- These are largely up to you and configs you copy. Most keybindings start wth super key. Default directions are h j k l, but I like to change them to w a s d or arrow keys. Super + direction moves focus between windows, super + number moves focus between desktops. If you also press shift, you move focused window instead of just focus. In default config super + alt (+shift) + direction resizes windows.
- Super + x closes window,
- Super + space opens dmenu so you can run applications,
- Super + s toggles floating
- Super + f toggles fullscreen
- Those are probably the most important things. The rest can be found in your sxhkdrc.
- ------
- Converting existing manjaro installation with desktop environment may produce usable and visually appealing results. In that case, you can skip creating bspwm-session file and use session of the desktop environment instead.
- Bspwm integrates nicely with xfce, lxqt, lxde and probably kde. At least xfce and lxqt have nice session manager, that lets you configure what is autostarted. Remove openbox/xfwm4 from there and replace it with bspwm. Also add sxhkd to autostart list, so that you have your keybindings and mousebindings.
- Desktops often come with a panel, so you should have in your bspwmrc
- ```bash
- bspc config top_padding x
- ```
- Replace top with bottom, left or right depending where you put your panel, and x with size of your panel in pixels.
- ### **Some things to consider with xfce:**
- \- whiskermenu and xfdesktop are not clickable if you use
- ```bash
- bspc config focus_follows_pointer true
- ```
- If you like them, you should remove this from your bspwmrc
- \- xfdesktop and xfce4-panel have significant delay starting if you do not disable their window manager check. Try to modify their autostart commands to
- ```bash
- xfce4-panel -d
- ```
- and
- ```bash
- xfdesktop -D
- ```
- ### **Some things to consider with lxqt:**
- \- by default, bspwm tiles the desktop created by lxqt-desktop. You probably don't want that.
- ```bash
- bspc rule -a lxqt-desktop border=off manage=off
- ```
- Might help. Check the window name with xprop.
- ------
- The lightest way to run bspwm is to run it as standalone window manager. This uses the least ram and boots the fastest.
- ## **Settings daemon**
- One of the decisions you need to make is whether or not to use settings-daemon. This blurs the line between using bspwm alone or with desktop environment. I recommend using this, especially for beginners, because it makes things much easier and adds only about 5mb ram usage. For me the benefits are:
- \- I can use xfce-settings-manager to configure screen, themes, printers and so on
- \- the touchpad on my laptop works better. Right click is easier to make, mouse is not too sensitive and wont go crazy. Palm detections works.
- Options for settings daemon include:
- \- xfsettingsd
- \- gsettingsd
- \- whatever lxqt uses
- \- kde probably has one too
- My advice: don't use gnome settings daemon. Sure, gnome control center is great and it will fix your mouse, but it will mess other things up and is a pain to configure. Also, many depencies. Worst, it uses much cpu, so it will drain your battery quickly.
- xfsettingsd work well in my experience. I like the xfce4-settings-manager the least, but it is good enough and works. Haven't tried others so much. Anyway, to use it, install xfce4-settings and add
- ```bash
- xfsettingsd &
- ```
- to your autostart file (~/.config/bspwm/autostart if you are using the bspwm-session, ~/.xinitrc if you are using startx)
- ## **Appearance**
- If you don't use settings daemon, use lxappearance to configure appearance of your apps. This does not use extra ram.
- ### **Pulseaudio**
- If you want to use pulseaudio without DE, add
- ```bash
- /usr/bin/start-pulseaudio-x11 &
- ```
- your autostart file. You can install pulseaudio with
- ```bash
- sudo pacman -S manjaro-pulse pavucontrol
- ```
- I also recommend pulseaudio-ctl and pnmixer for managing volume from system tray and sxhkd.
- ### **System tray**
- If you use xfce4-panel, lxqt-panel, bmpanel2 or tint2, you have system tray by default. However, if you use bspwms default panel, it wont have one. You can add it with trayer, stalonetray or something like that. I use stalonetray, with same background color as my panel, so it looks like part of the panel. Configure ̃/.stalontrayrc to place the tray where you want it and add
- ```bash
- stalonetray &
- ```
- to your autostart.
- ------
- If you want to access bspwms functions with mouse, there are some options
- \- mygtkmenu
- \- 9menu
- \- gnome-pie
- ### **Gnome-pie**
- This is the heaviest option with most eyecandy. It is also easy to configure with gui. I like to bind one piemenu with window manager options to long pressing right click.
- One thing to consider: If you want to toggle window properties with gnome-pie, you need rule
- ```bash
- bspc rule -a gnome-pie border=off manage=off
- ```
- Otherwise any commands apply only to the pie menu itself, which is then closed instantly. However, this prevents you from editing settings from the gnome-pie system tray icon. So you might want to have pie item or hotkey to toggle this setting.
- You can install gnome-pie with
- ```bash
- sudo pacman -S gnome-pie
- ```
- ### **9menu**
- 9menu is light, does not run on background and is very configurable. However, it does not handle submenus very well. Also, I know no way of making autoupdating appmenu with it. It can be good for desktop level menus, but I really don't recommend it, because mygtkmenu does same things better. If you are still interested and want to have some starting point, you can dig my configs from here: http://sourceforge.net/projects/manjarobspwmrespin/files/manjaroiso%20build/ (http://sourceforge.net/projects/manjarobspwmrespin/files/manjaroiso%20build/)
- ### **Mygtkmenu**
- It requires installing stuff from AUR and it has more depencies than 9menu, but it is very nice and my preferred choice. Unlike gnome-pie, it does not run on background, so it does not use resources if you are not using it.
- To install it:
- ```bash
- yaourt -S mygtkmenu
- ```
- and for some additional functions
- ```bash
- yaourt -S menumaker-compiz
- ```
- My menufiles can be found from here:
- ```
- https://sourceforge.net/projects/manjarobspwmrespin/files/config%20files/Mygtkmenu/?
- ```
- To use my menufiles, copy MouseLaunch and update_menu.sh to your scripts folder and everything else to ~/.config/GTKmenu . Then add things mentioned below to your sxhkdrc
- There is desktop level menu, which is called by my panel with command
- ```bash
- mygtkmenu ~/.config/GTKmenu/BspwmDesktopMenu
- ```
- There is window level menu, which is called sxhkd with alt + left click
- ```bash
- mod1 + @button1
- mygtkmenu ~/.config/GTKmenu/BspwmWindowMenu
- ```
- Finally, there is app menu that automatically tiles the next window where the menu was opened. This is the thing that requires menumaker-compiz to generate the menufile. I open the menu with alt_gr + left click. My sxhkd has
- ```bash
- mod5 + @button1
- MouseLaunch
- ```
- I use termite as terminal, so you should either install that or edit update_menu.sh to have something else instead of termite. You should also probably add update_menu.sh to your autostart file.
- ## **Useful scripts**
- By default, you can't move or resize tiled, floating and pseudo-floating with same keybindings, because bspwm uses different commands for them. These scripts determine which type of window is in question, and apply the right command for it. I found one of these scripts from https://github.com/windelicato/dotfiles/blob/master/scripts/window_move.sh and edited it to have these two scripts:
- bspwm_move.sh:
- ```bash
- #!/bin/bash
- # Sample sxhkd usage:
- #
- # alt + {a,f}
- # /home/sunn/scripts/bspwm_resize {-p,-n} -x -s 20
- #
- # alt + {s,d}
- # /home/sunn/scripts/bspwm_resize {-p,-n} -y -s 20
- POSITIVE=false
- HORIZONTAL=false
- SIZE='20'
- err() {
- echo "$1"
- exit 1
- }
- usage() {
- echo "usage: bspwm_resize [direction]"
- echo
- echo "Options:"
- echo " -p, --positive - resize in positively"
- echo " -n, --negative - resize in negatively"
- echo " -x, --xdir - resize in x direction"
- echo " -y, --ydir - resize in y dir"
- echo " -s, - number of pixels to resize or move"
- echo " -h, --help - display this"
- exit
- }
- if [[ $# -eq 0 ]] ; then
- usage
- exit
- fi
- for i in "$@"; do
- case $i in
- '-p'|'--positive')
- POSITIVE=true
- ;;
- '-n'|'--negative')
- POSITIVE=false
- ;;
- '-x'|'--xdir')
- HORIZONTAL=true
- ;;
- '-y'|'--ydir')
- HORIZONTAL=false
- ;;
- '-s')
- SIZE=$(echo $@ | sed 's/.*-s \([0-9]*\).*/\1/')
- [[ "$SIZE" == "$@" ]] && err "Must specify number of pixels"
- ;;
- ''|'-h'|'--help')
- usage
- exit
- ;;
- *)
- ;;
- esac
- done
- # Find current window mode
- WINDOW_STATUS="$(bspc query -T -w | awk '/^.* [a-zA-Z\-]{8} \*$/{print $8}')"
- FLAGS="$(echo $WINDOW_STATUS | sed 's/-//g')";
- # If the window is floating, move it
- if [[ "$FLAGS" =~ ^.*f.*$ ]]; then
- $HORIZONTAL && switch="-x" || switch="-y"
- $POSITIVE && sign="+" || sign="-"
- xdo move ${switch} ${sign}${SIZE}
- # Otherwise, window is tiled change split ratio
- else
- $HORIZONTAL && switch=('left' 'right') || switch=('up' 'down')
- $POSITIVE && sign="+" || sign="-"
- bspc window -s ${switch[0]} || bspc window -s ${switch[1]}
- fi
- ```
- bspwm_resize.sh:
- ```bash
- #!/bin/bash
- # Sample sxhkd usage:
- #
- # alt + {a,f}
- # /home/sunn/scripts/bspwm_resize {-p,-n} -x -s 20
- #
- # alt + {s,d}
- # /home/sunn/scripts/bspwm_resize {-p,-n} -y -s 20
- POSITIVE=false
- HORIZONTAL=false
- SIZE='20'
- err() {
- echo "$1"
- exit 1
- }
- usage() {
- echo "usage: bspwm_resize [direction]"
- echo
- echo "Options:"
- echo " -p, --positive - resize in positively"
- echo " -n, --negative - resize in negatively"
- echo " -x, --xdir - resize in x direction"
- echo " -y, --ydir - resize in y dir"
- echo " -s, - number of pixels to resize or move"
- echo " -h, --help - display this"
- exit
- }
- if [[ $# -eq 0 ]] ; then
- usage
- exit
- fi
- for i in "$@"; do
- case $i in
- '-p'|'--positive')
- POSITIVE=true
- ;;
- '-n'|'--negative')
- POSITIVE=false
- ;;
- '-x'|'--xdir')
- HORIZONTAL=true
- ;;
- '-y'|'--ydir')
- HORIZONTAL=false
- ;;
- '-s')
- SIZE=$(echo $@ | sed 's/.*-s \([0-9]*\).*/\1/')
- [[ "$SIZE" == "$@" ]] && err "Must specify number of pixels"
- ;;
- ''|'-h'|'--help')
- usage
- exit
- ;;
- *)
- ;;
- esac
- done
- # Find current window mode
- WINDOW_STATUS="$(bspc query -T -w | awk '/^.* [a-zA-Z\-]{8} \*$/{print $8}')"
- FLAGS="$(echo $WINDOW_STATUS | sed 's/-//g')";
- # If the window is floating, move it
- if [[ "$FLAGS" =~ ^.*f.*$ ]]; then
- $HORIZONTAL && switch="-w" || switch="-h"
- $POSITIVE && sign="+" || sign="-"
- xdo resize ${switch} ${sign}${SIZE}
- # If the window is pseudotiled, resize it
- elif [[ "$FLAGS" =~ ^.*d.*$ ]]; then
- $HORIZONTAL && switch="-w" || switch="-h"
- $POSITIVE && sign="+" || sign="-"
- xdo resize ${switch} ${sign}${SIZE}
- # Otherwise, window is tiled change split ratio
- else
- $HORIZONTAL && switch=('left' 'right') || switch=('down' 'up')
- $POSITIVE && sign="+" || sign="-"
- bspc window -e ${switch[0]} ${sign}${SIZE} || bspc window -e ${switch[1]} ${sign}${SIZE}
- fi
- ```
- Copy them to your scripts folder and mark them as executable with
- ```bash
- chmod +x ~/scripts/bspwm_move.sh
- ```
- Then, put in your sxhkdrc
- ```
- #move windows
- super + shift + {d,a}
- $HOME/scripts/bspwm_move.sh {-p,-n} -x -s 20
- super + shift + {s,w}
- $HOME/scripts/bspwm_move.sh {-p,-n} -y -s 20
- #multitool resize
- super + ctrl + {d,a}
- $HOME/scripts/bspwm_resize.sh {-p,-n} -x -s 20
- super + ctrl + {s,w}
- $HOME/scripts/bspwm_resize.sh {-p,-n} -y -s 20
- #multitool resize
- super + {Right,Left}
- $HOME/scripts/bspwm_resize.sh {-p,-n} -x -s 20
- super + {Down,Up}
- $HOME/scripts/bspwm_resize.sh {-p,-n} -y -s 20
- ```
- You can now move and resize all types of windows with same keybindings.
- ------
- You probably want to have some sort of panel with bspwm. The following stuff just works:
- \- xfce4-panel
- \- bmpanel2
- \- tint2
- \- lxqt-panel
- You can add name of your panel to your bspwmrc with & in the end, and make a gap for the panel with
- bspc config top/bottom/left/right_padding x, where x is the soze of gap in pixels.
- If you want more authentic and lightweight bswm experience, there is example bar script.
- If you wish to also use panel (that we actually already installed previously) with bspwm, you need to edit your ~/.profile or ~/.zprofile if you use zsh. Add in there
- export PANEL_FIFO="/tmp/panel-fifo"
- export PATH=$PATH:/path/to/panel/scripts
- PANEL_HEIGHT=24
- PANEL_FONT_FAMILY="-*-terminus-medium-r-normal-*-12-*-*-*-c-*-*-1"
- export PANEL_FIFO PANEL_HEIGHT PANEL_FONT_FAMILY
- ( /path/to/panel/scripts is a folder where you can place scripts which are recognized as terminal commands because they are in your path. I recommend ~/.bin or ~/scripts , but it is really up to you)
- Copy the example scripts (panel, panel_bar and panel_colors) from https://github.com/baskerville/bspwm/tree/master/examples/panel to your path folder and run chmod +x panel && chmod +x panel_bar. You can now put to the end of your bspwmrc
- panel &
- Panel should then appear when you launch bspwm.
- ### **Clickable panel**
- There are scripts with clickable workspaces and other functions available. For example this is the next panel script for manjaro bspwm respin. It also requires custom font benis-uushi and pipes conky to bar to display system information.
- Panel:
- ```bash
- #! /bin/sh
- if [ $(pgrep -cx panel) -gt 1 ] ; then
- printf "%s\n" "The panel is already running." >&2
- exit 1
- fi
- trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
- flavor=${1:-bar}
- [ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
- mkfifo "$PANEL_FIFO"
- bspc config top_padding $PANEL_HEIGHT
- # Colorscheme for mocha
- #BLUE="%{F#FF8AB3B5}"
- #RED="%{F#FFCB6077}"
- #YELLOW="%{F#FFF4BC87}"
- #ORANGE="%{F#FFD28B71}"
- #MAGENTA="%{F#FFA89BB9}"
- #TEAL="%{F#FF7BBdA4}"
- #LIGHTGREY="%{F#FFb8AfAD}"
- #DARKGREY="%{F#FF7E705A}"
- #GREEN="%{F#FF90A950}"
- #PURPLE="%{F#FF9547C9}"
- #BG="%{F#FF3B3228}"
- # Colorscheme for default-dark
- BLUE="%{F#FF6A9FB5}"
- RED="%{F#FFAC4142}"
- YELLOW="%{F#FFFF4BF75}"
- ORANGE="%{F#FFD28B71}"
- MAGENTA="%{F#FFAA759F}"
- TEAL="%{F#FF75B5AA}"
- LIGHTGREY="%{F#FFB0B0B0}"
- DARKGREY="%{F#FF505050}"
- GREEN="%{F#FF99CC99}"
- PURPLE="%{F#FF9547C9}"
- BG="%{F#FF151515}"
- INDIANRED="%{F#FFEE6363}"
- bspc control --subscribe > "$PANEL_FIFO" &
- xtitle -sf 'T%s' > "$PANEL_FIFO" &
- conky -c ~/.config/bspwm/panel/conkyrc > "$PANEL_FIFO" &
- panel_temperature()
- {
- temp=$((`sensors | grep "Physical id 0" | cut -d'+' -f2 | head -c2`))
- echo $GREEN " Temp" $temp°C;
- }
- panel_memused()
- {
- read t f <<< `grep -E 'Mem(Total|Free)' /proc/meminfo |awk '{print $2}'`
- bc <<< "scale=2; 100 - $f / $t * 100" | cut -d. -f1
- }
- panel_mem()
- {
- echo $GREEN " MEM:" $(panel_memused)%%
- }
- panel_cpuload()
- {
- LINE=`ps -eo pcpu |grep -vE '^\s*(0.0|%CPU)' |sed -n '1h;$!H;$g;s/\n/ +/gp'`
- bc <<< $LINE
- }
- panel_cpu()
- {
- echo $GREEN " CPU:" $(panel_cpuload)%%
- }
- panel_volicon()
- {
- volStatus=$(pulseaudio-ctl | grep "muted" | less | cut -c 36-37)
- volLevel=$(pulseaudio-ctl | grep "Volume level" | less | cut -c 36-38)
- if [ "$volStatus" == "no" ]
- then echo $GREEN " ⮞ ${volLevel}"
- elif [ "$volStatus" == "ye" ]
- then echo $RED " ⮝ ${volLevel}"
- else echo " ⮞"
- fi
- }
- panel_sigStrength()
- {
- signalStrength=$(cat /proc/net/wireless | awk 'NR==3 { print $3}' | sed 's/\.//')
- if [ "$signalStrength" -gt 64 ]
- then
- echo ""$GREEN " ‗▬▪▮"
- elif [ "$signalStrength" -lt 65 ] && [ "$signalStrength" -gt 39 ]
- then
- echo ""$GREEN " ‗▬▪"$DARKGREY"▮"$ORANGE
- elif [ "$signalStrength" -lt 40 ]
- then
- echo ""$GREEN " ‗▬"$DARKGREY"▪▮"$ORANGE
- else
- echo ""$DARKGREY " ‗▬▪▮ Not connected"
- fi
- }
- panel_essid()
- {
- echo $GREEN $(panel_sigStrength) $GREEN $(iwgetid -r)
- }
- panel_battery()
- {
- batStats=$(cat /sys/class/power_supply/BAT0/status)
- if [ "$batStats" == "" ]
- then
- echo $LIGHTGREY " ⮎ AC"
- elif [ "$batStats" == "Charging" ]
- then
- echo $GREEN" ⮒" $(cat /sys/class/power_supply/BAT0/capacity)"+"
- elif [ "$batStats" == "Discharging" ]
- then
- echo $RED " ⮑" $(cat /sys/class/power_supply/BAT0/capacity)"-"
- elif [ "$batStats" == "Unknown" ]
- then
- echo $GREEN" ⮒" $(cat /sys/class/power_supply/BAT0/capacity)
- else echo $GREEN" ⮒" $(cat /sys/class/power_supply/BAT0/capacity)
- fi
- }
- panel_clock()
- {
- echo $GREEN " ⭧ " $(clock -f '%a %d %I: %M')
- }
- # Loop to check time, battery and volume statuses
- while true; do
- echo "S" $(panel_battery)%{A:nmcli_dmenu:}$(panel_essid)%{A} > "$PANEL_FIFO" &
- sleep 1s
- done &
- . panel_colors
- case "$flavor" in
- bar)
- FONT_FAMILY='-benis-uushi-medium-r-normal--11-90-75-75-p-58-iso10646-1'
- FONT_FAMILY2='-*-terminus-medium-r-normal-*-12-*-*-*-c-*-*-1'
- cat "$PANEL_FIFO" | panel_bar | bar -p -g x20 -f "$FONT_FAMILY2","$FONT_FAMILY" -u 2 -F "$BG" -B "$BG" | sh
- ;;
- dzen2)
- FONT_FAMILY='DejaVu Sans'
- FONT_SIZE=11
- cat "$PANEL_FIFO" | panel_dzen2 -f "$FONT_FAMILY" -s "$FONT_SIZE" | dzen2 -h $PANEL_HEIGHT -dock -ta l -title-name panel -fn "${FONT_FAMILY}:pixelsize=${FONT_SIZE}" -fg "$COLOR_FOREGROUND" -bg "$COLOR_BACKGROUND" &
- ;;
- esac
- wait
- ```
- panel_bar
- ```bash
- #! /bin/sh
- CBR='%{B-}'
- CB1='%{B#FF99CC99}'
- CB2='%{B#FF4E4E4E}'
- CFR='%{F-}'
- CF1='%{F#FF000000}'
- CF2='%{F#FF99CC99}'
- CF3='%{F#FFD75F5F}'
- CF4='%{F#FF4E4E4E}'
- LA='%{l}'
- RA='%{r}'
- AC='%{A:'
- AB=':}'
- AE='%{A}'
- logo="${CB1}${CF1}${AC}dmenu_recent -l 10&disown${AB} $(hostname -s) %{B#FF000000}${CF2}${AE}"
- menu="${CF2}${AC}mygtkmenu ~/.config/GTKmenu/BspwmDesktopMenu${AB} menu ${AE}%{B#FF000000}${CF4}"
- while read -r line ; do
- case $line in
- S*)
- sys_infos="${RA}${line#?}"
- ;;
- C*)
- conky_infos="%{F#FF99CC99} ${line#?} "
- ;;
- T*)
- title="${CFR} ${AC}bspc desktop -l next${AB}${line#?}${AE} "
- ;;
- W*)
- wm_infos="%{B#FF000000}"
- IFS=':'
- set -- ${line#?}
- while [ $# -gt 0 ] ; do
- item=$1
- name=${item#?}
- case $item in
- [OFU]*)
- # active desktop
- wm_infos="${wm_infos}${CF2}${AC}bspc desktop -f ${name}${AB} • ${AE}${CFR}"
- ;;
- o*)
- # inactive but occupied desktop
- wm_infos="${wm_infos}${AC}bspc desktop -f ${name}${AB} • ${AE}"
- ;;
- f*)
- # inactive desktop
- wm_infos="${wm_infos}${AC}bspc desktop -f ${name}${AB} ○ ${AE}"
- ;;
- u*)
- # urgent desktop
- wm_infos="${wm_infos}${CF3}${AC}bspc desktop -f ${name}${AB} • ${AE}${CFR}"
- ;;
- L*)
- # layout
- case $name in
- t*)
- layout="T"
- ;;
- m*)
- layout="M"
- ;;
- esac
- wm_infos="${wm_infos} ${AC}bspc desktop -l next${AB}${layout}${AE} %{B#FF000000}${CF4}"
- ;;
- esac
- shift
- done
- ;;
- esac
- printf "%s\n" "$logo $wm_infos $menu %{c}$title $sys_infos ${conky_infos}"
- done
- ```
- ~/.config/bspwm/panel/conkyrc:
- ```bash
- background no
- out_to_console yes
- out_to_x no
- update_interval 5
- total_run_times 0
- short_units yes
- pad_percents 2
- override_utf8_locale yes
- times_in_seconds true
- #use_spacer left
- #~${fs_used /} \
- #s.${fs_used /data} \
- # ${mem} \
- #@ ${cpu}%
- #$if_mpd_playing ♪ ${if_match ${execi 5 expr length "`mpc --format %title% | head -n 1`"} >= 30}${scroll 30 3 ${mpd_title}}${else}${mpd_title}${endif} - ${if_match ${execi 5 expr length "`mpc --format %artist% | head -n 1`"} >= 30}${scroll 30 3 ${mpd_artist}}${else}${mpd_artist}${endif} |$endif \
- #Vol: ${exec amixer get Master | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p'| uniq}% | \
- #${battery_short BAT0} | \
- TEXT
- ${exec sleep 1}
- C RAM:${memperc}%% CPU:$cpu%% TEMP:$alignr${hwmon temp 1}°C | ⭧ ${time %H:%M}
- # ⮂ ⮀
- ```
- #### For something more simple, you could try:
- panel
- ```bash
- #! /bin/sh
- if [ $(pgrep -cx panel) -gt 1 ] ; then
- printf "%s\n" "The panel is already running." >&2
- exit 1
- fi
- trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
- [ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
- mkfifo "$PANEL_FIFO"
- bspc config top_padding $PANEL_HEIGHT
- bspc control --subscribe > "$PANEL_FIFO" &
- xtitle -sf 'T%s' > "$PANEL_FIFO" &
- conky -c ~/.config/bspwm/panel/conkyrc > "$PANEL_FIFO" &
- #panel_battery()
- #{
- # BATC=/sys/class/power_supply/BAT0/capacity
- # BATS=/sys/class/power_supply/BAT0/status
- #
- # test "`cat $BATS`" = "Charging" && echo -n '+' || echo -n '-'
- #
- # sed -n p $BATC
- #}
- #panel_temperature()
- #{
- # temp=$((`sensors | grep "Physical id 0" | cut -d'+' -f2 | head -c2`))
- # echo $temp°C;
- #}
- #
- #panel_cpuload()
- #{
- # LINE=`ps -eo pcpu |grep -vE '^\s*(0.0|%CPU)' |sed -n '1h;$!H;$g;s/\n/ +/gp'`
- # bc <<< $LINE
- #}
- #
- #panel_memused()
- #{
- # read t f <<< `grep -E 'Mem(Total|Free)' /proc/meminfo |awk '{print $2}'`
- # bc <<< "scale=2; 100 - $f / $t * 100" | cut -d. -f1
- #}
- #panel_clock()
- #{
- # echo $(clock -f '%a %H:%M')
- #}
- #
- # Loop to check time, battery and stuff
- #while true; do
- # echo "S" "TEMP:" $(panel_temperature) "BAT":$(panel_battery) "CPU:" $(panel_cpuload) "MEM:"$(panel_memused) $(panel_clock)%{A} > "$PANEL_FIFO" &
- # sleep 1s
- #done &
- . panel_colors
- cat "$PANEL_FIFO" | panel_barc | bar -g x$PANEL_HEIGHT -f "$PANEL_FONT_FAMILY" -F "$COLOR_FOREGROUND" -B "$COLOR_BACKGROUND" | sh &
- wait
- ```
- panel_bar
- ```bash
- #! /bin/sh
- #
- # Example panel for LemonBoy's bar
- . panel_colors
- num_mon=$(bspc query -M | wc -l)
- while read -r line ; do
- case $line in
- C*)
- conky_infos="${line#?} %{B-}%{F-}"
- ;;
- T*)
- # xtitle output
- title="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG} ${line#?} %{B-}%{F-}"
- ;;
- W*)
- # bspwm internal state
- wm_infos=""
- IFS=':'
- set -- ${line#?}
- while [ $# -gt 0 ] ; do
- item=$1
- name=${item#?}
- case $item in
- M*)
- # active monitor
- if [ $num_mon -gt 1 ] ; then
- wm_infos="$wm_infos %{F$COLOR_ACTIVE_MONITOR_FG}%{B$COLOR_ACTIVE_MONITOR_BG}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-} "
- fi
- ;;
- m*)
- # inactive monitor
- if [ $num_mon -gt 1 ] ; then
- wm_infos="$wm_infos %{F$COLOR_INACTIVE_MONITOR_FG}%{B$COLOR_INACTIVE_MONITOR_BG}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-} "
- fi
- ;;
- O*)
- # focused occupied desktop
- wm_infos="${wm_infos}%{F$COLOR_FOCUSED_OCCUPIED_FG}%{B$COLOR_FOCUSED_OCCUPIED_BG}%{U$COLOR_FOREGROUND}%{+u}%{A:bspc desktop -f ${name}:} ${name} %{A}%{-u}%{B-}%{F-}"
- ;;
- F*)
- # focused free desktop
- wm_infos="${wm_infos}%{F$COLOR_FOCUSED_FREE_FG}%{B$COLOR_FOCUSED_FREE_BG}%{U$COLOR_FOREGROUND}%{+u}%{A:bspc desktop -f ${name}:} ${name} %{A}%{-u}%{B-}%{F-}"
- ;;
- U*)
- # focused urgent desktop
- wm_infos="${wm_infos}%{F$COLOR_FOCUSED_URGENT_FG}%{B$COLOR_FOCUSED_URGENT_BG}%{U$COLOR_FOREGROUND}%{+u}%{A:bspc desktop -f ${name}:} ${name} %{A}%{-u}%{B-}%{F-}"
- ;;
- o*)
- # occupied desktop
- wm_infos="${wm_infos}%{F$COLOR_OCCUPIED_FG}%{B$COLOR_OCCUPIED_BG}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-}"
- ;;
- f*)
- # free desktop
- wm_infos="${wm_infos}%{F$COLOR_FREE_FG}%{B$COLOR_FREE_BG}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-}"
- ;;
- u*)
- # urgent desktop
- wm_infos="${wm_infos}%{F$COLOR_URGENT_FG}%{B$COLOR_URGENT_BG}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-}"
- ;;
- L*)
- # layout
- wm_infos="$wm_infos %{F$COLOR_LAYOUT_FG}%{B$COLOR_LAYOUT_BG}%{A:bspc desktop -l next ${name}:} ${name} %{A}%{B-}%{F-}"
- ;;
- esac
- shift
- done
- ;;
- esac
- printf "%s\n" "%{l}${wm_infos}%{c}${title}%{r}${conky_infos}%"
- done
- ```
- This is basically the same as default panel, with clickable conky and clickable workspaces.
Add Comment
Please, Sign In to add comment