Improve Polybar config

This commit is contained in:
Thomas Dehaeze 2019-02-03 17:54:54 +01:00
parent c7b065b0e4
commit f9f2af1a3e

View File

@ -53,7 +53,6 @@ margin-bottom = 5
* Top Bar * Top Bar
#+BEGIN_SRC conf #+BEGIN_SRC conf
[bar/top] [bar/top]
# monitor = ${env:MONITOR:eDP1}
enable-ipc = true enable-ipc = true
override-redirect = false override-redirect = false
bottom = false bottom = false
@ -79,13 +78,10 @@ margin-bottom = 5
font-0 = SauceCodePro Nerd Font:style=Medium,Regular:pixelsize=10;1 font-0 = SauceCodePro Nerd Font:style=Medium,Regular:pixelsize=10;1
font-1 = unifont:fontformat=truetype:size=8:antialias=false;0 font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
font-2 = Weather Icons:size=10;1 font-2 = Weather Icons:size=10;1
# font-3 = siji:pixelsize=10;1
# modules-left = mpd pulseaudio
# modules-center = i3 xwindow
modules-left = i3 modules-left = i3
modules-center = xwindow modules-center = xwindow
modules-right = nordvpn unread_mail cpu battery temperature date modules-right = unread_mail cpu battery temperature date
tray-position = right tray-position = right
tray-padding = 2 tray-padding = 2
@ -99,7 +95,6 @@ margin-bottom = 5
* Bottom Bar * Bottom Bar
#+BEGIN_SRC conf #+BEGIN_SRC conf
[bar/bottom] [bar/bottom]
# monitor = ${env:MONITOR:eDP1}
enable-ipc = true enable-ipc = true
override-redirect = false override-redirect = false
bottom = true bottom = true
@ -129,7 +124,7 @@ margin-bottom = 5
modules-left = mpd pulseaudio modules-left = mpd pulseaudio
# modules-center = xwindow # modules-center = xwindow
modules-right = screenshot weather emacs caffeine redshift modules-right = filesystem xkeyboard nordvpn chromecast screenshot weather emacs caffeine redshift
# tray-position = right # tray-position = right
# tray-padding = 2 # tray-padding = 2
@ -147,7 +142,7 @@ margin-bottom = 5
label = %title:0:30:...% label = %title:0:30:...%
#+END_SRC #+END_SRC
* Current Layour of the Keyboard * Current Layout of the Keyboard
#+BEGIN_SRC conf #+BEGIN_SRC conf
[module/xkeyboard] [module/xkeyboard]
type = internal/xkeyboard type = internal/xkeyboard
@ -155,7 +150,6 @@ margin-bottom = 5
# List of indicators to ignore # List of indicators to ignore
blacklist-0 = num lock blacklist-0 = num lock
format = <label-layout> format = <label-layout>
format-prefix = " " format-prefix = " "
format-prefix-foreground = ${colors.foreground} format-prefix-foreground = ${colors.foreground}
@ -175,7 +169,7 @@ margin-bottom = 5
# List of mountpoints to display # List of mountpoints to display
mount-0 = / mount-0 = /
label-mounted = %{F#0a81f5}%mountpoint%%{F-}: %percentage_used%% label-mounted = %{Fcolors.blue}%mountpoint%%{F-}: %percentage_used%%
label-unmounted = %mountpoint% label-unmounted = %mountpoint%
label-unmounted-foreground = ${colors.comments} label-unmounted-foreground = ${colors.comments}
#+END_SRC #+END_SRC
@ -191,12 +185,12 @@ margin-bottom = 5
** TODO - Choose some nice icons ** TODO - Choose some nice icons
#+BEGIN_SRC conf #+BEGIN_SRC conf
ws-icon-default = 
ws-icon-0 = 1; ws-icon-0 = 1;
ws-icon-1 = 2; ws-icon-1 = 2;
ws-icon-2 = 3; ws-icon-2 = 3;
ws-icon-3 = 4; ws-icon-3 = 4;
ws-icon-4 = 5; ws-icon-4 = 5;
ws-icon-default = 
#+END_SRC #+END_SRC
#+BEGIN_SRC conf #+BEGIN_SRC conf
@ -243,7 +237,7 @@ label-urgent-padding = 1
#+BEGIN_SRC conf #+BEGIN_SRC conf
[module/mpd] [module/mpd]
type = internal/mpd type = internal/mpd
format-online = <icon-prev> <toggle> <icon-next> <icon-repeat> <icon-random> <bar-progress> %{A1:termite -e "ncmpcpp" &:}<label-song>%{A} format-online = <icon-prev> <toggle> <icon-next> %{A1:termite -e "ncmpcpp" &:}<label-song>%{A}
format-online-spacing = 0 format-online-spacing = 0
format-online-padding = 0 format-online-padding = 0
@ -330,8 +324,8 @@ type = internal/date
interval = 1 interval = 1
# Open google calendar on left right # Open google calendar on left right
date = %{A1:qutebrowser https\://calendar.google.com/ &:} %d-%m%{A} date = %{A1:$BROWSER https\://calendar.google.com/ &:} %d-%m%{A}
date-alt = "%{A1:qutebrowser https\://calendar.google.com/ &:} %d-%m-%Y%{A}" date-alt = "%{A1:$BROWSER https\://calendar.google.com/ &:} %d-%m-%Y%{A}"
time =  %H:%M time =  %H:%M
time-alt =  %H:%M:%S time-alt =  %H:%M:%S
@ -372,7 +366,6 @@ bar-volume-empty-foreground = ${colors.foreground}
* Battery * Battery
#+BEGIN_SRC conf #+BEGIN_SRC conf
# TODO - open battery manager on click
[module/battery] [module/battery]
type = internal/battery type = internal/battery
@ -380,13 +373,13 @@ battery = BAT0
adapter = ADP1 adapter = ADP1
full-at = 95 full-at = 95
format-charging = <ramp-capacity> <label-charging> format-charging = %{A1:xfce4-power-manager-settings &:}<ramp-capacity> <label-charging>%{A}
format-charging-underline = ${colors.blue} format-charging-underline = ${colors.blue}
format-discharging = <ramp-capacity> <label-discharging> format-discharging = %{A1:xfce4-power-manager-settings &:}<ramp-capacity> <label-discharging>%{A}
format-discharging-underline = ${colors.red} format-discharging-underline = ${colors.red}
format-full-prefix = " " format-full-prefix = %{A1:xfce4-power-manager-settings &:} %{A}
format-full-prefix-foreground = ${colors.foreground} format-full-prefix-foreground = ${colors.foreground}
format-full-underline = ${colors.background} format-full-underline = ${colors.background}
@ -414,9 +407,7 @@ animation-discharging-foreground = ${colors.foreground}
animation-discharging-framerate = 750 animation-discharging-framerate = 750
#+END_SRC #+END_SRC
* TODO Temperature * Temperature
- [ ] Open temperature manager on click
#+BEGIN_SRC conf #+BEGIN_SRC conf
[module/temperature] [module/temperature]
type = internal/temperature type = internal/temperature
@ -427,7 +418,7 @@ animation-discharging-framerate = 750
;; Temperature off one cpu core ;; Temperature off one cpu core
hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon1/temp2_input hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon1/temp2_input
format = <ramp> <label> format = %{A1:termite -e "watch sensors" &:}<ramp> <label>%{A}
format-underline = ${colors.background} format-underline = ${colors.background}
format-warn = <ramp> <label-warn> format-warn = <ramp> <label-warn>
format-warn-underline = ${colors.red} format-warn-underline = ${colors.red}
@ -444,37 +435,6 @@ animation-discharging-framerate = 750
ramp-foreground = ${colors.foreground} ramp-foreground = ${colors.foreground}
#+END_SRC #+END_SRC
* Power Menu
#+BEGIN_SRC conf
[module/powermenu]
type = custom/menu
expand-right = true
format-spacing = 1
label-open = 
label-open-foreground = ${colors.blue}
label-close = cancel
label-close-foreground = ${colors.blue}
label-separator = |
label-separator-foreground = ${colors.foreground}
menu-0-0 = reboot
menu-0-0-exec = menu-open-1
menu-0-1 = power off
menu-0-1-exec = menu-open-2
menu-1-0 = cancel
menu-1-0-exec = menu-open-0
menu-1-1 = reboot
menu-1-1-exec = sudo reboot
menu-2-0 = power off
menu-2-0-exec = sudo poweroff
menu-2-1 = cancel
menu-2-1-exec = menu-open-0
#+END_SRC
* Settings * Settings
#+BEGIN_SRC conf #+BEGIN_SRC conf
[settings] [settings]
@ -485,8 +445,7 @@ screenchange-reload = true
#compositing-border = over #compositing-border = over
#+END_SRC #+END_SRC
* TODO Unread Mails * Unread Mails
- [ ] Add custom color when having new email
#+BEGIN_SRC conf #+BEGIN_SRC conf
[module/unread_mail] [module/unread_mail]
@ -500,6 +459,22 @@ exec = ~/.config/polybar/scripts/unread_mails.sh
interval = 1 interval = 1
#+END_SRC #+END_SRC
** Unread Mail Scripts
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/unread_mails.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
mails=$(du -a ~/.mail/*/Inbox/new/* 2>/dev/null | sed -n '$=')
if [[ -z "$mails" ]]; then
echo ""
else
echo "%{F#859900}%{F-}"
fi
#+end_src
* Redshift * Redshift
#+BEGIN_SRC conf #+BEGIN_SRC conf
[module/redshift] [module/redshift]
@ -513,30 +488,47 @@ exec = ~/.config/polybar/scripts/redshift.sh
interval = 1 interval = 1
#+END_SRC #+END_SRC
* TODO Calendar ** Redshift Scripts
#+begin_src conf :PROPERTIES:
[module/popup-calendar] :header-args: :tangle ~/.config/polybar/scripts/redshift.sh
type = custom/script :header-args+: :comments both :mkdirp yes
exec = ~/scripts/popup-calendar.sh :header-args+: :shebang "#!/usr/bin/env bash"
interval = 5 :END:
click-left = ~/scripts/popup-calendar.sh --popup #+begin_src bash
if pgrep -x "redshift" >/dev/null; then
echo "盛";
else
echo "";
fi
if [ "$1" = "toggle" ]; then
if pgrep -x "redshift" >/dev/null; then
killall redshift;
else
nohup redshift > /dev/null 2>&1 &
fi
fi
#+end_src #+end_src
* TODO Emacs Server
* TODO [#A] Emacs Server
- [ ] Emacsclient script is not working
#+begin_src conf #+begin_src conf
[module/emacs] [module/emacs]
type = custom/script type = custom/script
label-font = 2 label-font = 2
format-underline = ${colors.background} format-underline = ${colors.background}
click-left = ~/scripts/emacsclient.sh & click-left = ~/.config/polybar/scripts/emacsclient.sh &
click-right = emacs &
format = <label> format = <label>
exec = ~/.config/polybar/scripts/emacs.sh exec = ~/.config/polybar/scripts/emacsserver.sh
interval = 1 interval = 5
#+end_src #+end_src
** Emacs Server Scripts ** Emacs Server Scripts
:PROPERTIES: :PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/emacs.sh :header-args: :tangle ~/.config/polybar/scripts/emacsserver.sh
:header-args+: :comments both :mkdirp yes :header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash" :header-args+: :shebang "#!/usr/bin/env bash"
:END: :END:
@ -549,8 +541,18 @@ else
fi fi
#+END_SRC #+END_SRC
* NordVPN ** Emacs Client Script
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/emacsclient.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+BEGIN_SRC bash
emacsclient -create-frame --alternate-editor=""
#+END_SRC
* NordVPN
#+BEGIN_SRC conf #+BEGIN_SRC conf
[module/nordvpn] [module/nordvpn]
type = custom/script type = custom/script
@ -609,50 +611,145 @@ exec = echo -e "\uf0f4"
interval = 1 interval = 1
#+END_SRC #+END_SRC
* Side panel config * Weather
#+BEGIN_SRC conf
# [bar/panel]
# monitor = ${env:MONITOR:eDP1}
# enable-ipc = true
# override-redirect = true
# bottom = false
#
# width = 30%
# height = 600 # 1080p - bar height - 2*border width
# offset-x = 70%
# offset-y = 27
# fixed-center = true
# spacing = 1
# module-margin-left = 2
# module-margin-right = 2
#
# border-size = 2
# border-color = ${colors.turquoise}
#
# background = ${colors.background}
# foreground = ${colors.foreground}
#
# font-0 = SauceCodePro Nerd Font:style=Medium,Regular:pixelsize=10;1
# font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
# font-2 = siji:pixelsize=10;1
#
# modules-center = lock logout hibernate reboot shutdown screenshot
#+END_SRC
* TODO Weather
https://github.com/x70b1/polybar-scripts/tree/master/polybar-scripts/openweathermap-fullfeatured https://github.com/x70b1/polybar-scripts/tree/master/polybar-scripts/openweathermap-fullfeatured
#+begin_src conf #+begin_src conf
[module/weather] [module/weather]
type = custom/script type = custom/script
exec = ~/.config/polybar/scripts/weather.sh exec = ~/.config/polybar/scripts/weather.sh
click-left = ~/.config/polybar/scripts/weatheropen.sh
interval = 600 interval = 600
label-font = 3 label-font = 3
#+end_src #+end_src
** TODO Add action when cliking on it => open webpage with meteo ** Emacs Server Scripts
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/weather.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
* TODO Network #+BEGIN_SRC bash
get_icon() {
case $1 in
01d) icon="";;
01n) icon="";;
02d) icon="";;
02n) icon="";;
03*) icon="";;
04*) icon="";;
09d) icon="";;
09n) icon="";;
10d) icon="";;
10n) icon="";;
11d) icon="";;
11n) icon="";;
13d) icon="";;
13n) icon="";;
50d) icon="";;
50n) icon="";;
,*) icon="";
esac
echo $icon
}
get_duration() {
osname=$(uname -s)
case $osname in
,*BSD) date -r "$1" -u +%H:%M;;
,*) date --date="@$1" -u +%H:%M;;
esac
}
KEY="a705adc4ce0e271801051b9460ecb1cd"
CITY=""
UNITS="metric"
SYMBOL="°"
API="https://api.openweathermap.org/data/2.5"
if [ -n "$CITY" ]; then
if [ "$CITY" -eq "$CITY" ] 2>/dev/null; then
CITY_PARAM="id=$CITY"
else
CITY_PARAM="q=$CITY"
fi
current=$(curl -sf "$API/weather?appid=$KEY&$CITY_PARAM&units=$UNITS")
forecast=$(curl -sf "$API/forecast?appid=$KEY&$CITY_PARAM&units=$UNITS&cnt=1")
else
location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue)
if [ -n "$location" ]; then
location_lat="$(echo "$location" | jq '.location.lat')"
location_lon="$(echo "$location" | jq '.location.lng')"
current=$(curl -sf "$API/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS")
forecast=$(curl -sf "$API/forecast?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS&cnt=1")
fi
fi
if [ -n "$current" ] && [ -n "$forecast" ]; then
current_temp=$(echo "$current" | jq ".main.temp" | cut -d "." -f 1)
current_icon=$(echo "$current" | jq -r ".weather[0].icon")
forecast_temp=$(echo "$forecast" | jq ".list[].main.temp" | cut -d "." -f 1)
forecast_icon=$(echo "$forecast" | jq -r ".list[].weather[0].icon")
if [ "$current_temp" -gt "$forecast_temp" ]; then
trend="" #
elif [ "$forecast_temp" -gt "$current_temp" ]; then
trend="" #
else
trend="" #
fi
sun_rise=$(echo "$current" | jq ".sys.sunrise")
sun_set=$(echo "$current" | jq ".sys.sunset")
now=$(date +%s)
if [ "$sun_rise" -gt "$now" ]; then
daytime=" $(get_duration "$((sun_rise-now))")"
elif [ "$sun_set" -gt "$now" ]; then
daytime=" $(get_duration "$((sun_set-now))")"
else
daytime=" $(get_duration "$((sun_rise-now))")"
fi
echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL $daytime"
fi
#+END_SRC
** TODO Open Weather Webpage
:PROPERTIES:
:header-args: :tangle ~/.config/polybar/scripts/weatheropen.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
- [ ] Find a way to open a web page with detailed forecast with the current location
#+BEGIN_SRC bash
# location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue)
# if [ -n "$location" ]; then
# location_lat="$(echo "$location" | jq '.location.lat')"
# location_lon="$(echo "$location" | jq '.location.lng')"
# else
# fi
$BROWSER https://www.yahoo.com/news/weather/france/grenoble/grenoble-593720
#+END_SRC
* TODO [#A] Network
#+begin_src conf #+begin_src conf
[module/network] [module/network]
type = internal/network type = internal/network
@ -746,16 +843,6 @@ https://github.com/x70b1/polybar-scripts/tree/master/polybar-scripts/openweather
; animation-packetloss-framerate = 500 ; animation-packetloss-framerate = 500
#+end_src #+end_src
* Option Menu
#+BEGIN_SRC conf
[module/option_menu]
type = custom/ipc
hook-0 = ~/.i3/scripts/polybar_wrapper.sh options_icon
initial = 1
click-left = ~/.i3/scripts/polybar_wrapper.sh options
#+END_SRC
* Logout * Logout
#+BEGIN_SRC conf #+BEGIN_SRC conf
[module/logout] [module/logout]
@ -796,8 +883,9 @@ content = ""
click-left = blurlock click-left = blurlock
#+END_SRC #+END_SRC
* TODO Screenshot * TODO [#B] Screenshot
First it blocking the polybar, then the right click is not working - [ ] the right click is not working
#+BEGIN_SRC conf #+BEGIN_SRC conf
[module/screenshot] [module/screenshot]
type = custom/text type = custom/text
@ -805,3 +893,12 @@ First it blocking the polybar, then the right click is not working
click-left = scrot -e 'feh $f -x' --delay 1 click-left = scrot -e 'feh $f -x' --delay 1
click-right = scrot -s -e 'feh $f -x' click-right = scrot -s -e 'feh $f -x'
#+END_SRC #+END_SRC
* ChromeCast Play/Pause
#+BEGIN_SRC conf
[module/chromecast]
type = custom/script
content = "懶"
click-left = catt play
click-right = catt pause
#+END_SRC