Added links and polybar.

This commit is contained in:
Joachim Nielandt 2020-07-14 15:19:48 +02:00
parent 1ff60bdaa6
commit 9279e041fa
169 changed files with 4389 additions and 0 deletions

604
dot_dotfiles/polybar/config Normal file
View File

@ -0,0 +1,604 @@
;=====================================================
;
; To learn more about how to configure Polybar
; go to https://github.com/jaagr/polybar
;
; The README contains alot of information
;
;=====================================================
[colors]
background = ${xrdb:color0:#222}
foreground = ${xrdb:color7:#222}
background-alt = ${xrdb:color10:#222}
foreground-alt = ${xrdb:color4:#222}
icon-color = ${xrdb:color4:#FF2}
primary = ${xrdb:color1:#222}
alert = ${xrdb:color10:#222}
secondary = ${xrdb:color10:#222}
; let's get some colors from xrdb (pywal)
col0 = ${xrdb:color0:#222}
col1 = ${xrdb:color1:#222}
col2 = ${xrdb:color2:#222}
col3 = ${xrdb:color3:#222}
col4 = ${xrdb:color4:#222}
col5 = ${xrdb:color5:#222}
col6 = ${xrdb:color6:#222}
col7 = ${xrdb:color7:#222}
col8 = ${xrdb:color8:#222}
col9 = ${xrdb:color9:#222}
col10 = ${xrdb:color10:#222}
col11 = ${xrdb:color11:#222}
col12 = ${xrdb:color12:#222}
col13 = ${xrdb:color13:#222}
gruvbg = ${xrdb:background:#222}
gruvbghard = ${xrdb:backgroundhard:#222}
gruvbgsoft = ${xrdb:backgroundsoft:#222}
gruvfg = ${xrdb:foreground:#222}
; control some of the later elements from here, nice and tidy
underline-cpu = ${xrdb:color2:#222}
underline-memory = ${xrdb:color3:#222}
underline-date = ${xrdb:color4:#222}
underline-battery = ${xrdb:color5:#222}
underline-temperature = ${xrdb:color6:#222}
underline-keyboard = ${xrdb:color7:#222}
underline-i3-focused = ${xrdb:color10:#222}
underline-i3-unfocused = ${xrdb:color8:#222}
[bar/general]
width = 100%
; spaces before/after each module
module-margin-left = 1
module-margin-right = 1
height = 27
fixed-center = true
line-size = 3
line-color = #f00
; rounded corners of the bar
radius = 0.0
;this makes sure that i3 doesn't reposition everything when polybar becomes active... is shit
override-redirect = false
wm-restack = i3
; all the bar colors
background = ${colors.background}
foreground = ${colors.foreground}
border-color = ${colors.background}
; spaces on begin/end of bar
padding-left = 2
padding-right = 2
; set the bar fonts
;font-0 = fixed:pixelsize=10;1
;font-0 = "Wuncon Siji:pixelsize=15;1"
;font-1 = unifont:fontformat=truetype:size=8:antialias=false;0
;font-2 = "Inconsolata\ For\ Powerline:pixelsize=10;1"
font-0 = FuraCode Nerd Font:pixelsize=11;1
; override pointers
cursor-click = pointer
cursor-scroll = pointer
[bar/example]
inherit = bar/general
monitor = ${env:MONITOR:eDP-1}
;offset-x = 2%
;offset-y = 1%
;i'm faking the left and right margins with a fat border. i'm helpless
;border-size = 20
;border-left-size = 16
;border-right-size = 16
;unused modules - mpd xbacklight backlight-acpi alsa
modules-left = i3
modules-center = temperature battery xkeyboard memory cpu filesystem updates-arch reboot-check xbacklight top-process
modules-right = net1 wifi0 vpn powermenu
; TRAY MANAGEMENT
;tray-position = right
tray-position = ${env:TRAY_POSITION:none}
;tray-transparent = true
tray-detached = false
tray-maxsize = 16
;tray-background = ${colors.background-alt}
;this makes sure that the tray doesn't run off to the right of the monitor - only enable this when the bar's width is a bit off
tray-offset-x = 0
tray-offset-y = 27
tray-padding = 2
tray-scale = 1.0
scroll-up = i3wm-wsnext
scroll-down = i3wm-wsprev
cursor-click = pointer
;cursor-scroll = ns-resize
cursor-scroll = pointer
[bar/secondary]
inherit = bar/general
monitor = ${env:MONITOR:eDP-1}
;offset-x = 2%
;offset-y = 1%
;unused modules - mpd xbacklight backlight-acpi alsa
modules-right = pulseaudio
modules-center = player-mpris-tail
modules-left = date info-hackspeed
[module/player-mpris-tail]
type = custom/script
exec = ~/.config/polybar/polybar-scripts/polybar-scripts/player-mpris-tail/player-mpris-tail.py -f '{icon} {artist} - {title}' --icon-playing  --icon-paused  --icon-stopped  --icon-none ﱙ
tail = true
label = %output%
[module/info-hackspeed]
type = custom/script
format-prefix = " "
format-prefix-foreground = ${colors.icon-color}
exec = ~/.config/polybar/polybar-scripts/polybar-scripts/info-hackspeed/info-hackspeed.sh
tail = true
[module/top-process]
type = custom/script
format-prefix = " "
format-prefix-foreground = ${colors.icon-color}
format-underline = ${colors.alert}
interval = 5
exec = ~/.dotfiles/scripts/top.process.sh
tail = true
[module/xwindow]
type = internal/xwindow
label = %title:0:30:...%
[module/xkeyboard]
type = internal/xkeyboard
blacklist-0 = num lock
format-prefix = " "
format-prefix-foreground = ${colors.icon-color}
format-prefix-underline = ${colors.underline-keyboard}
; layout, number, name
label-layout = %layout%
label-layout-underline = ${colors.underline-keyboard}
label-indicator-padding = 2
label-indicator-margin = 1
label-indicator-background = ${colors.secondary}
label-indicator-underline = ${colors.underline-keyboard}
cursor-click = pointer
[module/vpn]
type = custom/script
exec = nmcli | grep "VPN connection" | sed -e "s/VPN connection//g"
exec-if = pgrep -x openvpn
interval = 5
format-underline = #268bd2
format-prefix = " "
format-prefix-foreground = ${colors.col1}
[module/filesystem]
type = internal/fs
interval = 25
mount-0 = /
mount-1 = /mnt/ext4
label-mounted = %{F#0a81f5}%mountpoint%%{F-} %percentage_used%%
label-unmounted = %mountpoint% not mounted
label-unmounted-foreground = ${colors.foreground-alt}
[module/bspwm]
type = internal/bspwm
label-focused = %index%
label-focused-background = ${colors.background-alt}
label-focused-underline= ${colors.primary}
label-focused-padding = 2
label-occupied = %index%
label-occupied-padding = 2
label-urgent = %index%!
label-urgent-background = ${colors.alert}
label-urgent-padding = 2
label-empty = %index%
label-empty-foreground = ${colors.foreground-alt}
label-empty-padding = 2
; Separator in between workspaces
; label-separator = |
[module/i3]
type = internal/i3
format = <label-state> <label-mode>
index-sort = true
wrapping-scroll = false
; Only show workspaces on the same output as the bar
pin-workspaces = true
; This will split the workspace name on ':'
; Default: false
strip-wsnumbers = true
; using siji icons... see view.sh for codes
; not using siji anymore, check out nerdfonts.com!
;  
ws-icon-0 = 1:1;
ws-icon-1 = 2:2;
ws-icon-2 = 3:3;
ws-icon-3 = 4:4;
ws-icon-4 = 5:5;
ws-icon-5 = 6:6;
ws-icon-6 = 7:7;
ws-icon-7 = 8:8;
ws-icon-8 = 9:9;﬐
ws-icon-9 = 10:10;
ws-icon-10 = 11:;
ws-icon-11 = 12:;
ws-icon-default = 
; Whenever the 'move' changes... like 'resize', ...
label-mode-padding = 2
label-mode-foreground = ${colors.gruvfg}
;label-mode-background = ${colors.primary}
label-mode-background = ${colors.col4}
label-mode-underline = ${colors.col12}
; focused = Active workspace on focused monitor
label-focused = %icon% %name%
;label-focused = %index%
;label-focused-background = ${module/bspwm.label-focused-background}
;label-focused-underline = ${module/bspwm.label-focused-underline}
;label-focused-padding = ${module/bspwm.label-focused-padding}
label-focused-background = ${colors.col2}
label-focused-foreground = ${colors.gruvbghard}
label-focused-underline = ${colors.underline-i3-focused}
label-focused-padding = 2
; unfocused = Inactive workspace on any monitor
;label-unfocused = %index%
label-unfocused = %icon% %name%
label-unfocused-underline = ${colors.underline-i3-unfocused}
;label-unfocused-padding = ${module/bspwm.label-occupied-padding}
label-unfocused-padding = 2
; visible = Active workspace on unfocused monitor
; label-visible = %index%
label-visible = %icon% %name%
;label-visible-background = ${self.label-focused-background}
;label-visible-underline = ${self.label-focused-underline}
;label-visible-padding = ${self.label-focused-padding}
label-visible-background = ${colors.col12}
label-visible-foreground = ${colors.gruvbghard}
label-visible-underline = #FFFFFF
label-visible-padding = 2
; urgent = Workspace with urgency hint set
label-urgent = %icon% %name%
; label-urgent-background = ${module/bspwm.label-urgent-background}
label-urgent-background = ${colors.col1}
label-urgent-foreground = ${colors.col9}
label-urgent-underline = ${colors.col9}
label-urgent-padding = 2
; Separator in between workspaces
; label-separator = |
[module/mpd]
type = internal/mpd
format-online = <label-song> <icon-prev> <icon-stop> <toggle> <icon-next>
icon-prev = 玲
icon-stop = 
icon-play = 
icon-pause = 
icon-next = 怜
label-song-maxlen = 25
label-song-ellipsis = true
[module/xbacklight]
type = internal/xbacklight
format = <label> <bar>
label = 
; format-underline = ${colors.foreground-alt}
format-underline = ${colors.col6}
format-prefix-foreground = ${colors.underline-cpu}
bar-width = 10
bar-indicator = |
bar-indicator-foreground = #ff
bar-indicator-font = 2
bar-fill = ─
bar-fill-font = 2
bar-fill-foreground = ${colors.col6}
bar-empty = ─
bar-empty-font = 2
bar-empty-foreground = ${colors.col7}
[module/backlight-acpi]
inherit = module/xbacklight
type = internal/backlight
;card = intel_backlight
card = acpi_video0
[module/cpu]
type = internal/cpu
interval = 2
;format-prefix = " "
;format = <label> <ramp-coreload>
format = <ramp-coreload>
ramp-coreload-spacing = 0.5
ramp-coreload-0 = ▁
ramp-coreload-1 = ▂
ramp-coreload-2 = ▃
ramp-coreload-3 = ▄
ramp-coreload-4 = ▅
ramp-coreload-5 = ▆
ramp-coreload-6 = ▇
ramp-coreload-7 = █
format-prefix = " "
format-prefix-foreground = ${colors.underline-cpu}
;format-underline = #f90000
format-underline = ${colors.underline-cpu}
label = %percentage-cores%
[module/memory]
type = internal/memory
interval = 2
format-prefix = " "
format-prefix-foreground = ${colors.icon-color}
;format-underline = #4bffdc
format-underline = ${colors.underline-memory}
label = %percentage_used%%
[module/updates-arch]
type = custom/script
exec = ~/.config/polybar/polybar-scripts/polybar-scripts/updates-arch/updates-arch.sh
format-prefix = " "
format-prefix-foreground = ${colors.icon-color}
format-underline = ${colors.col13}
interval = 600
label = "%output%"
[module/reboot-check]
type = custom/script
exec = ~/bin/reboot.check
format-underline = ${colors.col1}
format-foreground = ${colors.col1}
interval = 30
label = ""
[module/wifi0]
type = internal/network
interface = wifi0
interval = 3.0
format-connected = <ramp-signal> <label-connected>
format-connected-underline = ${colors.icon-color}
;label-connected = %{A1:networkmanager_dmenu:}%essid%%{A}
;  
label-connected = "%{A1:networkmanager_dmenu:}%essid%%{A} %downspeed:3% %upspeed:3%"
format-disconnected =
;format-disconnected = <label-disconnected>
;format-disconnected-underline = ${self.format-connected-underline}
;label-disconnected = %ifname% disconnected
;label-disconnected-foreground = ${colors.foreground-alt}
ramp-signal-0 = 
ramp-signal-1 = 
ramp-signal-2 = 
ramp-signal-3 = 
ramp-signal-4 = 
ramp-signal-foreground = ${colors.foreground-alt}
[module/net1]
type = internal/network
interface = net1
interval = 3.0
format-connected-underline = #55aa55
format-connected-prefix = " "
format-connected-prefix-foreground = ${colors.icon-color}
;label-connected = %local_ip%
label-connected = "%downspeed:3% %upspeed:3%"
label-connected-foreground = ${colors.foreground}
format-disconnected =
;format-disconnected = <label-disconnected>
;format-disconnected-underline = ${self.format-connected-underline}
;label-disconnected = %ifname% disconnected
;label-disconnected-foreground = ${colors.foreground-alt}
[module/date]
type = internal/date
interval = 5
date = " %Y-%m-%d"
date-alt =
time = %H:%M:%S
time-alt = %H:%M
format-prefix = ""
format-prefix-foreground = ${colors.foreground-alt}
;format-underline = #0a6cf5
;format-underline = ${colors.underline-date}
label = "%date% %time%"
[module/pulseaudio]
type = internal/pulseaudio
format-volume = <label-volume> <bar-volume>
label-volume =  %percentage%%
label-volume-foreground = ${root.foreground}
; the muted symbol comes from siji font (check the 'view.sh' script for altcodes)
label-muted =  muted
;label-muted-foreground = #66
label-muted-foreground = ${colors.alert}
bar-volume-width = 10
bar-volume-foreground-0 = #55aa55
bar-volume-foreground-1 = #55aa55
bar-volume-foreground-2 = #55aa55
bar-volume-foreground-3 = #55aa55
bar-volume-foreground-4 = #55aa55
bar-volume-foreground-5 = #f5a70a
bar-volume-foreground-6 = #ff5555
bar-volume-gradient = false
bar-volume-indicator = |
bar-volume-indicator-font = 2
bar-volume-fill = ─
bar-volume-fill-font = 2
bar-volume-empty = ─
bar-volume-empty-font = 2
bar-volume-empty-foreground = ${colors.foreground-alt}
[module/alsa]
type = internal/alsa
format-volume = <label-volume> <bar-volume>
label-volume = VOL
label-volume-foreground = ${root.foreground}
format-muted-prefix = " "
format-muted-foreground = ${colors.foreground-alt}
label-muted = sound muted
bar-volume-width = 10
bar-volume-foreground-0 = #55aa55
bar-volume-foreground-1 = #55aa55
bar-volume-foreground-2 = #55aa55
bar-volume-foreground-3 = #55aa55
bar-volume-foreground-4 = #55aa55
bar-volume-foreground-5 = #f5a70a
bar-volume-foreground-6 = #ff5555
bar-volume-gradient = false
bar-volume-indicator = |
bar-volume-indicator-font = 2
bar-volume-fill = ─
bar-volume-fill-font = 2
bar-volume-empty = ─
bar-volume-empty-font = 2
bar-volume-empty-foreground = ${colors.foreground-alt}
[module/battery]
type = internal/battery
battery = BAT0
adapter = AC
full-at = 98
time-format = %H:%M
label-charging =  %time% %percentage%%
format-charging = <animation-charging> <label-charging>
;format-charging-underline = #ffb52a
format-charging-underline = ${colors.underline-battery}
label-discharging =  %time% %percentage%%
format-discharging = <ramp-capacity> <label-discharging>
format-discharging-underline = ${self.format-charging-underline}
format-full-prefix = " "
format-full-prefix-foreground = ${colors.foreground-alt}
format-full-underline = ${self.format-charging-underline}
ramp-capacity-0 = 
ramp-capacity-1 = 
ramp-capacity-2 = 
ramp-capacity-3 = 
ramp-capacity-4 = 
ramp-capacity-foreground = ${colors.foreground-alt}
animation-charging-0 = 
animation-charging-1 = 
animation-charging-2 = 
animation-charging-3 = 
animation-charging-4 = 
animation-charging-foreground = ${colors.foreground-alt}
animation-charging-framerate = 750
[module/temperature]
type = internal/temperature
thermal-zone = 0
warn-temperature = 60
format = <ramp> <label>
;format-underline = #f50a4d
format-underline = ${colors.underline-temperature}
format-warn = <ramp> <label-warn>
format-warn-underline = ${self.format-underline}
label = %temperature-c%
label-warn = %temperature-c%
label-warn-foreground = ${colors.secondary}
;found this with following command
; for i in /sys/class/hwmon/hwmon*/temp*_input; do echo "$(<$(dirname $i)/name): $(cat ${i%_*}_label 2>/dev/null || echo $(basename ${i%_*})) $(readlink -f $i)"; done
;hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon0/temp2_input
;hwmon-path = ${env:HWMON_PATH:/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp1_input}
; different approach: add to .xinitrc a line that sets up an env variable
; > CPU_TEMP_PATH=$(ls /sys/devices/platform/coretemp*/hwmon/hwmon*/temp*_input | grep -m 1 '')
hwmon-path = ${env:CPU_TEMP_PATH:/sys/devices/platform/coretemp.0/hwmon/hwmon5/temp5_input}
;hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp2_input
ramp-0 = 
ramp-1 = 
ramp-2 = 
ramp-foreground = ${colors.foreground-alt}
[module/powermenu]
type = custom/menu
expand-right = true
format-spacing = 1
label-open = ⏻
label-open-foreground = ${colors.secondary}
label-close = " back"
label-close-foreground = ${colors.secondary}
label-separator = |
label-separator-foreground = ${colors.foreground-alt}
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 = systemctl reboot
menu-2-0 = power off
menu-2-0-exec = systemctl poweroff
menu-2-1 = cancel
menu-2-1-exec = menu-open-0
[settings]
screenchange-reload = true
;compositing-background = xor
;compositing-background = screen
;compositing-foreground = source
;compositing-border = over
[global/wm]
;margin-top = 5
;margin-bottom = 5
; vim:ft=dosini

View File

@ -0,0 +1,29 @@
#!/bin/zsh
# Terminate already running bar instances
killall -q polybar
# Wait until the processes have been shut down
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
# started tray...
started_tray=false
# set some global variables to be passed to polybar
export HWMON_PATH=$(ls /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp*_input | head -n 1)
# launch polybar on all connected monitors
for m in $(polybar --list-monitors | cut -d":" -f1); do
echo "Launching polybar on monitor $m"
MONITOR=$m TRAY_POSITION=none polybar --reload secondary &
if [ "$started_tray" = false ]; then
MONITOR=$m TRAY_POSITION=right polybar --reload example &
started_tray=true
echo "launching $m with tray"
else
MONITOR=$m TRAY_POSITION=none polybar --reload example &
echo "launching $m without tray"
fi
done
echo "Done launching."

View File

@ -0,0 +1,12 @@
#!/bin/bash
# Terminate already running bar instances
killall -q polybar
# Wait until the processes have been shut down
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
# Launch Polybar, using default config location ~/.config/polybar/config
polybar example &
echo "Polybar launched..."

View File

@ -0,0 +1,14 @@
# Contributing to polybar-scripts
Thank you for your interest in improving polybar-scripts.
Some things that have become standard:
* The [skeleton](skeleton/). This is an example of how each script is organized to create a common file structure.
* Use `#` or `#1`, `#2` .. as icon replacement in your scripts. Everyone use another icon font. So let the user decide which icon he wants to use.
* Remove your colors unless they have a special function. This way scripts remain customizable.
## check your code
* Use `shellcheck` to check your shell scripts for possible errors. Otherwise, Travis CI will do it for you. A good start to try [ShellCheck](https://www.shellcheck.net/) is their website.

View File

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>

View File

@ -0,0 +1,79 @@
# polybar-scripts
[![Build Status](https://travis-ci.org/x70b1/polybar-scripts.svg?branch=master)](https://travis-ci.org/x70b1/polybar-scripts)
[![GitHub contributors](https://img.shields.io/github/contributors/x70b1/polybar-scripts.svg)](https://github.com/x70b1/polybar-scripts/graphs/contributors)
[![license](https://img.shields.io/github/license/x70b1/polybar-scripts.svg)](https://github.com/x70b1/polybar-scripts/blob/master/LICENSE)
This is a community project. We write and collect scripts for Polybar!
To find out how to write and use your own scripts, read [Polybars wiki](https://github.com/jaagr/polybar/wiki).
This repository is not an exact blueprint. I guess every script has to be customized to make your Polybar unique. We cannot guarantee that all scripts will work because many scripts are written for very specific purposes. But we're trying.
Your script isn't here yet? You have ideas to extend the scripts or descriptions? Send us your pull request or join us on freenode's `#polybar`.
## Hall of Fame
Is this your first time here? You should definitely take a look at these scripts:
* [battery-combined-udev](polybar-scripts/battery-combined-udev)
* [openweathermap-fullfeatured](polybar-scripts/openweathermap-fullfeatured)
* [player-mpris-tail](polybar-scripts/player-mpris-tail)
* [pulseaudio-tail](polybar-scripts/pulseaudio-tail)
* [system-usb-udev](polybar-scripts/system-usb-udev)
* [updates-arch-combined](polybar-scripts/updates-arch-combined)
* [info-hackspeed](polybar-scripts/info-hackspeed)
## all colors are beautiful
[![updates-arch-combined](polybar-scripts/updates-arch-combined/screenshots/1.png)](polybar-scripts/updates-arch-combined/)
[![system-cpu-temppercore](polybar-scripts/system-cpu-temppercore/screenshots/1.png)](polybar-scripts/system-cpu-temppercore/)
[![notification-chess](polybar-scripts/notification-chess/screenshots/1.png)](polybar-scripts/notification-chess/)
[![inbox-reddit](polybar-scripts/inbox-reddit/screenshots/1.png)](polybar-scripts/inbox-reddit/)
[![openvpn-isrunning](polybar-scripts/openvpn-isrunning/screenshots/1.png)](polybar-scripts/openvpn-isrunning/)
[![inbox-imap-python](polybar-scripts/inbox-imap-python/screenshots/1.png)](polybar-scripts/inbox-imap-python/)
[![openweathermap-fullfeatured](polybar-scripts/openweathermap-fullfeatured/screenshots/1.png)](polybar-scripts/openweathermap-fullfeatured/)
[![ticker-btceur](polybar-scripts/ticker-btceur/screenshots/1.png)](polybar-scripts/ticker-btceur/)
[![player-mpris-simple](polybar-scripts/player-mpris-simple/screenshots/1.png)](polybar-scripts/player-mpris-simple/)
[![battery-combined-tlp](polybar-scripts/battery-combined-tlp/screenshots/1.png)](polybar-scripts/battery-combined-tlp/)
[![info-projecthamster](polybar-scripts/info-projecthamster/screenshots/1.png)](polybar-scripts/info-projecthamster/)
[![system-usb-udev](polybar-scripts/system-usb-udev/screenshots/1.png)](polybar-scripts/system-usb-udev/)
[![system-usb-udev](polybar-scripts/system-usb-udev/screenshots/2.png)](polybar-scripts/system-usb-udev/)
[![openweathermap-simple](polybar-scripts/openweathermap-simple/screenshots/1.png)](polybar-scripts/openweathermap-simple/)
[![info-pingrtt](polybar-scripts/info-pingrtt/screenshots/3.png)](polybar-scripts/info-pingrtt/)
[![info-ssh-sessions](polybar-scripts/info-ssh-sessions/screenshots/1.png)](polybar-scripts/info-ssh-sessions/)
[![openweathermap-detailed](polybar-scripts/openweathermap-detailed/screenshots/1.png)](polybar-scripts/openweathermap-detailed/)
[![info-hackspeed](polybar-scripts/info-hackspeed/screenshots/1.png)](polybar-scripts/info-hackspeed/)
[![info-xampp](polybar-scripts/info-xampp/screenshots/1.png)](polybar-scripts/info-xampp/)
[![player-mpris-tail](polybar-scripts/player-mpris-tail/screenshots/1.png)](polybar-scripts/player-mpris-tail/)
[![info-redshift-temp](polybar-scripts/info-redshift-temp/screenshots/1.png)](polybar-scripts/info-redshift-temp/)
[![info-trash](polybar-scripts/info-trash/screenshots/1.png)](polybar-scripts/info-trash/)
[![pulseaudio-rofi](polybar-scripts/pulseaudio-rofi/screenshots/1.png)](polybar-scripts/pulseaudio-rofi/)
[![pulseaudio-rofi](polybar-scripts/info-softwarecounter/screenshots/1.png)](polybar-scripts/info-softwarecounter/)
[![info-twitch-countdown](polybar-scripts/info-twitch-countdown/screenshots/1.png)](polybar-scripts/info-twitch-countdown/)
[![info-twitch-countdown](polybar-scripts/info-twitch-countdown/screenshots/2.png)](polybar-scripts/info-twitch-countdown/)
[![info-todotxt](polybar-scripts/info-todotxt/screenshots/1.png)](polybar-scripts/info-todotxt/)
[![info-wifionice](polybar-scripts/info-wifionice/screenshots/1.png)](polybar-scripts/info-wifionice/)
## See also these other user repositories:
* [vyachkonovalov/polybar-gmail](https://github.com/vyachkonovalov/polybar-gmail): A Polybar module to show unread messages from Gmail
* [0nse/now_playing](https://github.com/0nse/now_playing): Output the currently scrobbling song
* [dakuten/taskwarrior-polybar](https://github.com/dakuten/taskwarrior-polybar): merely just a script showing the most urgent task and allowing it to be marked done
* [quelotic/polybarModules](https://github.com/quelotic/polybarModules): scripts for mail and caffeine
* [vyp/scripts](https://github.com/vyp/scripts): A script to show focused, occupied, free and urgent herbstluftwm tags in polybar
* [willHol/polybar-crypto](https://github.com/willHol/polybar-crypto): A polybar script that displays the price of crypto-currencies
* [DanaruDev/UnseenMail](https://framagit.org/DanaruDev/UnseenMail): Polybar Python script for viewing unread email from multi accounts
* [drdeimos/polybar_another_battery](https://github.com/drdeimos/polybar_another_battery): Simple battery charge level watcher with notifications (libnotify)
* [zemmsoares/polynews](https://github.com/zemmsoares/polynews): read news on your polybar
## Setup
* Save the script of your choice somewhere at `~/.config/polybar/`.
* Don't forget to make the script executable: `chmod +x ~/.config/polybar/script.sh`.
* Copy the module settings into your configuration file.
* Replace the appropriate icon strings in the script (e.g. replace `#1` with `🎉`).

View File

@ -0,0 +1,26 @@
#!/bin/sh
error_count=0
scripts="polybar-scripts/*/*.sh"
for file in $scripts; do
# Exceptions
if [ "$file" = "polybar-scripts/info-hackspeed/info-hackspeed.sh" ]; then
shellcheck --exclude=SC2016,SC2059 "$file"
if [ $? -ne 0 ]; then
error_count=$((error_count+1))
fi
else
shellcheck "$file"
if [ $? -ne 0 ]; then
error_count=$((error_count+1))
fi
fi
done
if [ $error_count -eq 0 ]; then
exit 0
else
exit 1
fi

View File

@ -0,0 +1,13 @@
language: c
install:
- scversion="stable"
- wget "https://storage.googleapis.com/shellcheck/shellcheck-$scversion.linux.x86_64.tar.xz"
- tar --xz -xvf "shellcheck-$scversion.linux.x86_64.tar.xz"
- shellcheck() { "shellcheck-$scversion/shellcheck" "$@"; }
before_script:
- shellcheck --version
script:
- source ${TRAVIS_BUILD_DIR}/build.sh

View File

@ -0,0 +1,15 @@
# Script: battery-combined-shell
A shell script that shows the battery status.
It supports two rechargeable batteries and changing icons. It works even if only one battery is used.
## Module
```ini
[module/battery-combined-shell]
type = custom/script
exec = ~/polybar-scripts/battery-combined-shell.sh
interval = 10
```

View File

@ -0,0 +1,61 @@
#!/bin/sh
path_ac="/sys/class/power_supply/AC"
path_battery_0="/sys/class/power_supply/BAT0"
path_battery_1="/sys/class/power_supply/BAT1"
ac=0
battery_level_0=0
battery_level_1=0
battery_max_0=0
battery_max_1=0
if [ -f "$path_ac/online" ]; then
ac=$(cat "$path_ac/online")
fi
if [ -f "$path_battery_0/energy_now" ]; then
battery_level_0=$(cat "$path_battery_0/energy_now")
fi
if [ -f "$path_battery_0/energy_full" ]; then
battery_max_0=$(cat "$path_battery_0/energy_full")
fi
if [ -f "$path_battery_1/energy_now" ]; then
battery_level_1=$(cat "$path_battery_1/energy_now")
fi
if [ -f "$path_battery_1/energy_full" ]; then
battery_max_1=$(cat "$path_battery_1/energy_full")
fi
battery_level=$(("$battery_level_0 + $battery_level_1"))
battery_max=$(("$battery_max_0 + $battery_max_1"))
battery_percent=$(("$battery_level * 100"))
battery_percent=$(("$battery_percent / $battery_max"))
if [ "$ac" -eq 1 ]; then
icon="#1"
if [ "$battery_percent" -gt 97 ]; then
echo "$icon"
else
echo "$icon $battery_percent %"
fi
else
if [ "$battery_percent" -gt 85 ]; then
icon="#21"
elif [ "$battery_percent" -gt 60 ]; then
icon="#22"
elif [ "$battery_percent" -gt 35 ]; then
icon="#23"
elif [ "$battery_percent" -gt 10 ]; then
icon="#24"
else
icon="#25"
fi
echo "$icon $battery_percent %"
fi

View File

@ -0,0 +1,31 @@
# Script: battery-combined-tlp
A shell script that shows the battery status.
It uses TLP and requires root privileges. Note that the icon doesn't change.
![battery-combined-tlp](screenshots/1.png)
## Dependencies
* `tlp`
## Configuration
You may need to add `tlp-stat` command to the `/etc/sudoers` NOPASSWD of your user:
```ini
user ALL=(ALL) NOPASSWD: /usr/bin/tlp-stat
```
## Module
```ini
[module/battery-combined-tlp]
type = custom/script
exec = ~/polybar-scripts/battery-combined-tlp.sh
interval = 10
```

View File

@ -0,0 +1,5 @@
#!/bin/sh
battery=$(sudo tlp-stat -b | tail -2 | head -n 1 | tr -d -c "[:digit:],.")
echo "# $battery %"

Binary file not shown.

After

Width:  |  Height:  |  Size: 841 B

View File

@ -0,0 +1,4 @@
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", \
RUN+="/home/user/.config/polybar/battery-combined-udev.sh --update"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", \
RUN+="/home/user/.config/polybar/battery-combined-udev.sh --update"

View File

@ -0,0 +1,24 @@
# Script: battery-combined-udev
A shell script that shows the battery status. This is an extended version of [battery-combined-shell](../battery-combined-shell).
It supports two rechargeable batteries and changing icons. It works even if only one battery is used.
This script is able to display power supply changes in real time. For this udev is being used.
## Configuration
Copy `95-battery.rules` to `/etc/udev/rules.d/95-battery.rules`. Make sure that the paths in the file have been modified properly.
Also change the file path in line `#65`.
## Module
```ini
[module/battery-combined-udev]
type = custom/script
exec = ~/polybar-scripts/battery-combined-udev.sh
tail = true
```

View File

@ -0,0 +1,88 @@
#!/bin/sh
battery_print() {
path_ac="/sys/class/power_supply/AC"
path_battery_0="/sys/class/power_supply/BAT0"
path_battery_1="/sys/class/power_supply/BAT1"
ac=0
battery_level_0=0
battery_level_1=0
battery_max_0=0
battery_max_1=0
if [ -f "$path_ac/online" ]; then
ac=$(cat "$path_ac/online")
fi
if [ -f "$path_battery_0/energy_now" ]; then
battery_level_0=$(cat "$path_battery_0/energy_now")
fi
if [ -f "$path_battery_0/energy_full" ]; then
battery_max_0=$(cat "$path_battery_0/energy_full")
fi
if [ -f "$path_battery_1/energy_now" ]; then
battery_level_1=$(cat "$path_battery_1/energy_now")
fi
if [ -f "$path_battery_1/energy_full" ]; then
battery_max_1=$(cat "$path_battery_1/energy_full")
fi
battery_level=$(("$battery_level_0 + $battery_level_1"))
battery_max=$(("$battery_max_0 + $battery_max_1"))
battery_percent=$(("$battery_level * 100"))
battery_percent=$(("$battery_percent / $battery_max"))
if [ "$ac" -eq 1 ]; then
icon="#1"
if [ "$battery_percent" -gt 97 ]; then
echo "$icon"
else
echo "$icon $battery_percent %"
fi
else
if [ "$battery_percent" -gt 85 ]; then
icon="#21"
elif [ "$battery_percent" -gt 60 ]; then
icon="#22"
elif [ "$battery_percent" -gt 35 ]; then
icon="#23"
elif [ "$battery_percent" -gt 10 ]; then
icon="#24"
else
icon="#25"
fi
echo "$icon $battery_percent %"
fi
}
path_pid="/home/user/.config/polybar/battery-combined-udev.pid"
case "$1" in
--update)
pid=$(cat $path_pid)
if [ "$pid" != "" ]; then
kill -10 "$pid"
fi
;;
*)
echo $$ > $path_pid
trap exit INT
trap "echo" USR1
while true; do
battery_print
sleep 30 &
wait
done
;;
esac

View File

@ -0,0 +1,25 @@
# Script: battery-cyberpower
A shell script that shows the battery status for CyberPower UPS devices.
This script is able to display power supply changes in real time.
## Dependencies
* `pwrstat` from CyberPower's website
## Configuration
It requires access to run `pwrstat` as root, so you may need to adjust your system to allow this (for example `sudo`).
## Module
```ini
[module/battery-cyberpower]
type = custom/script
exec = ~/polybar-scripts/battery-cyberpower.sh
tail = true
```

View File

@ -0,0 +1,56 @@
#!/bin/sh
ICON_AC="#1"
ICON_BATTERY_FULL="#21"
ICON_BATTERY_GOOD="#22"
ICON_BATTERY_LOW="#23"
ICON_BATTERY_CAUTION="#24"
ICON_BATTERY_EMPTY="#25"
SHOW_ESTIMATION=1
battery_print() {
battery_info="$(sudo pwrstat -status)"
battery_capacity="$(echo "$battery_info" | awk '/Capacity/{print $3}')"
battery_ac="$(echo "$battery_info" | awk '/Power Supply by/{print $4,$5}')"
battery_load="$(echo "$battery_info" | grep "Load" | cut -d \( -f 2 | tr -d ' %)')"
battery_remaining="$(echo "$battery_info" | awk '/Remaining Runtime/{print $3}')"
output=""
if [ "$battery_ac" = "Utility Power" ]; then
if [ "$battery_capacity" -gt 97 ]; then
output="$ICON_AC"
else
output="$ICON_AC $battery_capacity %"
fi
else
if [ "$battery_capacity" -gt 85 ]; then
output="$ICON_BATTERY_FULL $battery_capacity %"
elif [ "$battery_capacity" -gt 60 ]; then
output="$ICON_BATTERY_GOOD $battery_capacity %"
elif [ "$battery_capacity" -gt 35 ]; then
output="$ICON_BATTERY_LOW $battery_capacity %"
elif [ "$battery_capacity" -gt 10 ]; then
output="$ICON_BATTERY_CAUTION $battery_capacity %"
else
output="$ICON_BATTERY_EMPTY $battery_capacity %"
fi
fi
if [ "$SHOW_ESTIMATION" -eq 1 ]; then
output="$output ($battery_load % / $battery_remaining min)"
fi
echo "$output"
}
trap exit INT
trap "echo" USR1
while true; do
battery_print "$@"
sleep 30 &
wait
done

View File

@ -0,0 +1,20 @@
# Script: inbox-imap-python
A script that shows if there are unread mails in your IMAPs inbox.
![inbox-imap-python](screenshots/1.png)
## Configuration
For Gmail, you must allow [less secure apps](https://myaccount.google.com/security#connectedapps).
## Module
```ini
[module/inbox-imap-python]
type = custom/script
exec = ~/polybar-scripts/inbox-imap-python.py
interval = 60
```

View File

@ -0,0 +1,9 @@
#!/usr/bin/python
import imaplib
obj = imaplib.IMAP4_SSL('imap.mail.net', 993)
obj.login('userlogin', 'pass123')
obj.select()
print(len(obj.search(None, 'unseen')[1][0].split()))

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

View File

@ -0,0 +1,27 @@
# Script: inbox-imap-shellnetrc
A script that shows if there are unread mails in your IMAP inbox.
This script actually use IMAPs. `curl` can also handle unencrypted IMAP. You only need to change the protocol in the command.
The login data is stored in a `.netrc`. This is more secure because the password is not visible in the process list.
## Dependencies
* `curl`
## Configuration
For Gmail, you must allow [less secure apps](https://myaccount.google.com/security#connectedapps).
## Module
```ini
[module/inbox-imap-shellnetrc]
type = custom/script
exec = ~/polybar-scripts/inbox-imap-shellnetrc.sh
interval = 60
```

View File

@ -0,0 +1,3 @@
machine mail.server.tld
login username
password supersecretpw

View File

@ -0,0 +1,12 @@
#!/bin/sh
SERVER=""
NETRC=".netrc"
inbox=$(curl -sf --netrc-file "$NETRC" -X "STATUS INBOX (UNSEEN)" imaps://"$SERVER"/INBOX | tr -d -c "[:digit:]")
if [ "$inbox" ] && [ "$inbox" -gt 0 ]; then
echo "# $inbox"
else
echo ""
fi

View File

@ -0,0 +1,22 @@
# Script: inbox-pop3-shellnetrc
A script that shows if there are unread mails in your POP3 inbox.
This script actually use POP3s. `curl` can also handle unencrypted POP3. You only need to change the protocol in the command.
The login data is stored in a `.netrc`. This is more secure because the password is not visible in the process list.
## Dependencies
* `curl`
## Module
```ini
[module/inbox-pop3-shellnetrc]
type = custom/script
exec = ~/polybar-scripts/inbox-pop3-shellnetrc.sh
interval = 60
```

View File

@ -0,0 +1,3 @@
machine mail.server.tld
login username
password supersecretpw

View File

@ -0,0 +1,12 @@
#!/bin/sh
SERVER=""
NETRC=".netrc"
inbox=$(curl -sf --netrc-file "$NETRC" pop3s://"$SERVER" | wc -l)
if [ "$inbox" -gt 0 ]; then
echo "# $inbox"
else
echo ""
fi

View File

@ -0,0 +1,23 @@
# Script: inbox-reddit
A script that shows if there are unread mails in your Reddit inbox.
Type Reddit JSON URL from [reddit.com/prefs/feeds/](https://www.reddit.com/prefs/feeds/). Click `your inbox` > `unread messages` > `JSON` and copy the link.
![inbox-reddit](screenshots/1.png)
## Dependencies
* `curl`
* `jq`
## Module
```ini
[module/inbox-reddit]
type = custom/script
exec = ~/polybar-scripts/inbox-reddit.sh
interval = 60
```

View File

@ -0,0 +1,15 @@
#!/bin/sh
url="your url here"
unread=$(curl -sf "$url" | jq '.["data"]["children"] | length')
case "$unread" in
''|*[!0-9]*)
unread=0
esac;
if [ "$unread" -gt 0 ]; then
echo "#1 $unread"
else
echo "#2"
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,33 @@
# Script: info-hackspeed
A small script that shows your typing speed. Happy Hacking!
![info-hackspeed](screenshots/1.png)
## Dependencies
* `xorg-xinput`
* `awk`
* coreutils (`rm`, `stdbuf`, `mktemp`, `stat`, you probably have this)
## Configuration
* `KEYBOARD_ID`: name of your keyboard. See Setup above. Default: `AT Translated Set 2 keyboard`
* `METRIC`: either `cpm` (characters per minute) of `wpm` ([words per minute, 1 word = 5 characters](https://en.wikipedia.org/wiki/Words_per_minute)). Default: `cpm`
* `FORMAT`: format string according to which the metric will be output. Default: `# %d $METRIC`
* `INTERVAL`: amount of seconds to gather data. Default: 20
* `LAYOUT`: keyboard layout, to be able to only count letters and numbers. Currently supported are `qwerty` and `azerty`. If you have a different layout, please contribute a condition for it! See the script's source code. Use the special value `dontcare` to count all keys, not just letters and numbers. Default: `qwerty`
If after 20 seconds the value stays at 0 even though you're typing, you may have to configure the name of your keyboard. Change the setting `KEYBOARD_ID` (see Configuration below) in the script. You can find your keyboard description with `xinput list --short`.
## Module
```ini
[module/info-hackspeed]
type = custom/script
exec = ~/polybar-scripts/info-hackspeed.sh
tail = true
```

View File

@ -0,0 +1,61 @@
#!/bin/sh
KEYBOARD_ID="AT Translated Set 2 keyboard"
# cpm: characters per minute
# wpm: words per minute (1 word = 5 characters)
METRIC=cpm
FORMAT="%d $METRIC"
INTERVAL=20
# If you have a keyboard layout that is not listed here yet, create a condition
# yourself. $3 is the key index. Use `xinput test "AT Translated Set 2 keyboard"`
# to see key codes in real time. Be sure to open a pull request for your
# layout's condition!
LAYOUT=qwerty
case "$LAYOUT" in
qwerty) CONDITION='($3 >= 10 && $3 <= 19) || ($3 >= 24 && $3 <= 33) || ($3 >= 37 && $3 <= 53) || ($3 >= 52 && $3 <= 58)'; ;;
azerty) CONDITION='($3 >= 10 && $3 <= 19) || ($3 >= 24 && $3 <= 33) || ($3 >= 37 && $3 <= 54) || ($3 >= 52 && $3 <= 57)'; ;;
dontcare) CONDITION='1'; ;; # Just register all key presses, not only letters and numbers
*) echo "Unsupported layout \"$LAYOUT\""; exit 1; ;;
esac
# We have to account for the fact we're not listening a whole minute
multiply_by=60
divide_by=$INTERVAL
case "$METRIC" in
wpm) divide_by=$((divide_by * 5)); ;;
cpm) ;;
*) echo "Unsupported metric \"$METRIC\""; exit 1; ;;
esac
hackspeed_cache="$(mktemp -p '' hackspeed_cache.XXXXX)"
trap 'rm "$hackspeed_cache"' EXIT
# Write a dot to our cache for each key press
printf '' > "$hackspeed_cache"
xinput test "$KEYBOARD_ID" | \
stdbuf -o0 awk '$1 == "key" && $2 == "press" && ('"$CONDITION"') {printf "."}' >> "$hackspeed_cache" &
while true; do
# Ask the kernel how big the file is with the command `stat`. The number we
# get is the file size in bytes, which equals the amount of dots the file
# contains, and hence how much keys were pressed since the file was last
# cleared.
lines=$(stat --format %s "$hackspeed_cache")
# Truncate the cache file so that in the next iteration, we count only new
# keypresses
printf '' > "$hackspeed_cache"
# The shell only does integer operations, so make sure to first multiply and
# then divide
value=$((lines * multiply_by / divide_by))
printf "$FORMAT\\n" "$value"
sleep $INTERVAL
done

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

View File

@ -0,0 +1,13 @@
# Script: info-kernel
A script that shows the running kernel version.
## Module
```ini
[module/info-kernel]
type = custom/script
exec = uname -r
interval = 1024
```

View File

@ -0,0 +1,17 @@
# Script: info-pingrtt
A script that displays a ping result. It also shows a colored icon.
![info-pingrtt](screenshots/1.png)
![info-pingrtt](screenshots/2.png)
![info-pingrtt](screenshots/3.png)
## Module
```ini
[module/info-pingrtt]
type = custom/script
exec = ~/polybar-scripts/info-pingrtt.sh
interval = 10
```

View File

@ -0,0 +1,19 @@
#!/bin/sh
HOST=127.43.12.64
if ! ping=$(ping -n -c 1 -W 1 $HOST); then
echo "# ping failed"
else
rtt=$(echo "$ping" | sed -rn 's/.*time=([0-9]{1,})\.?[0-9]{0,} ms.*/\1/p')
if [ "$rtt" -lt 50 ]; then
icon="%{F#3cb703}#%{F-}"
elif [ "$rtt" -lt 150 ]; then
icon="%{F#f9dd04}#%{F-}"
else
icon="%{F#d60606}#%{F-}"
fi
echo "$icon $rtt ms"
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 878 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

View File

@ -0,0 +1,15 @@
# Script: info-projecthamster
This script displays Hamster Time Tracker information.
![info-projecthamster](screenshots/1.png)
## Module
```ini
[module/info-projecthamster]
type = custom/script
exec = ~/polybar-scripts/info-projecthamster.sh
interval = 5
```

View File

@ -0,0 +1,9 @@
#!/bin/sh
activity=$(hamster current 2> /dev/null | cut -d " " -f 3- | sed 's/@.* / - /')
if [ -n "$activity" ]; then
echo "$activity"
else
echo "No Activity"
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -0,0 +1,15 @@
# Script: info-redshift-temp
This script displays the current color temperature.
![info-redshift](screenshots/1.png)
## Module
```ini
[module/info-redshift-temp]
type = custom/script
exec = ~/polybar-scripts/info-redshift-temp.sh
interval = 5
```

View File

@ -0,0 +1,15 @@
#!/bin/sh
if [ "$(pgrep -x redshift)" ]; then
temp=$(redshift -p 2> /dev/null | grep temp | cut -d ":" -f 2 | tr -dc "[:digit:]")
if [ -z "$temp" ]; then
echo "%{F#65737E} #"
elif [ "$temp" -ge 5000 ]; then
echo "%{F#8FA1B3} #"
elif [ "$temp" -ge 4000 ]; then
echo "%{F#EBCB8B} #"
else
echo "%{F#D08770} #"
fi
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

View File

@ -0,0 +1,25 @@
# Script: info-softwarecounter
A script that counts the number of specified running software including GUIs and processes.
Options to only monitor GUI applications or only processes exist. Users can add their own applications or processes they wish to watch simply by updating the existing dictionaries at the start of the script.
Arbitrary program counts can be combined, for example, the vim/nvim or chrome/chromium counts can be added together and the total displayed.
![info-softwarecounter](screenshots/1.png)
## Dependencies
* `wmctrl`
* `pgrep`
## Module
```
[module/info-softwarecounter]
type = custom/script
exec = ~/polybar-scripts/info-softwarecounter.py
interval = 10
```

View File

@ -0,0 +1,145 @@
#!/usr/bin/env python3
import subprocess
import sys
from collections import Counter, OrderedDict
# update GUIs
GUI = True
# update processes
PROCESS = True
# program/process names and corresponding gylphs
guis = OrderedDict({
'terminals': '#',
'chromes': '#',
'firefox': '#',
'skypeforlinux': '#',
'filemanager': '#',
'remote-desktop': '#',
'pdfviewer': '#',
'image': '#',
})
processes = OrderedDict({
'vims': '#',
'ssh': '#',
'updater': '#',
})
# combine counts of program/process names in the tuple
# the resulting glpyh used will be that of the corresponding key
combine_guis = {
'terminals': ('termite', 'terminator', 'urxvt'),
'chromes': ('chromium', 'chrome'),
'filemanger': ('nemo', 'thunar', 'dolphin', 'nautilus', 'pcmanfm'),
'remote-desktop': ('TeamViewer', ),
'pdfviewer': ('evince', 'okular', 'zathura'),
'image': ('gthumb', 'shotwell', 'deepin-image-vi'),
}
combine_proccesses = {
'vims': ('nvim', 'vim'),
'updater': ('pacman', 'yay', 'trizen', 'yaourt'),
}
gui_output = ''
process_output = ''
if GUI:
def get_running_guis():
try:
listed = sys.argv[1]
except IndexError:
listed = []
get = lambda cmd: subprocess.check_output(cmd).decode("utf-8").strip()
def check_wtype(w_id):
# check the type of window, only list "NORMAL" windows
return "_NET_WM_WINDOW_TYPE_NORMAL" in get(["xprop", "-id", w_id])
def get_process(w_id):
# get the name of the process, owning the window
proc = get(["ps", "-p", w_id, "-o", "comm="])
return proc
wlist = [l.split() for l in subprocess.check_output(["wmctrl", "-lp"])\
.decode("utf-8").splitlines()]
validprocs = [
get_process(w[2]) for w in wlist if check_wtype(w[0]) == True
]
return validprocs
# get list of running GUI programs
gui_counts = Counter(get_running_guis())
# combine programs in program combine list
for k, lst in combine_guis.items():
count = 0
for i in lst:
try:
count += gui_counts.pop(i)
except KeyError:
pass
if count:
gui_counts[k] += count
# generate program output
for k, v in guis.items():
try:
c = gui_counts[k]
if c:
gui_output += '%s %i ' % (v, c)
except:
pass
if PROCESS:
def get_running_proc(process_name_list):
counts = [None] * len(process_name_list)
for i, p in enumerate(process_name_list):
try:
count = int(
subprocess.check_output(['pgrep', '-c', '-x',
p]).decode('utf-8'))
except subprocess.CalledProcessError:
count = 0
counts[i] = (p, count)
return dict(counts)
# count running proccesses
process_counts = get_running_proc(processes.keys())
combine_counts = get_running_proc(
list(sum(combine_proccesses.values(), ())))
process_counts.update(combine_counts)
# combine processes in process combine list
for k, lst in combine_proccesses.items():
count = 0
for i in lst:
try:
count += process_counts.pop(i)
except KeyError:
pass
if count:
process_counts[k] += count
# generate process output
for k, v in processes.items():
try:
c = process_counts[k]
if c:
process_output += '%s %i ' % (v, c)
except:
pass
print(gui_output + process_output)

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -0,0 +1,20 @@
# Script: info-ssh-sessions
A script that displays the count of current ssh sessions as well as the public IP address of the fist session.
![info-ssh-sessions](screenshots/1.png)
## Dependencies
* `lsof`
## Module
```ini
[module/info-ssh-sessions]
type = custom/script
exec = ~/polybar-scripts/info-ssh-sessions.sh
interval = 5
```

View File

@ -0,0 +1,10 @@
#!/bin/sh
sessions="$(lsof -Pi | grep ":22")"
if [ ! -z "$sessions" ]; then
count=$(echo "$sessions" | wc -l)
echo "# ($count): $(echo "$sessions" | cut -d ">" -f 2 | cut -d " " -f 1 | cut -d ":" -f 1 | tail -n 1)"
else
echo "# (0)"
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,15 @@
# Script: info-todotxt
A script that shows todo.txt items due. The first column shows items due today, and the second column shows items due this week (including today).
![todotxt](screenshots/1.png)
## Module
```ini
[module/info-todotxt]
type = custom/script
exec = ~/polybar-scripts/info-todotxt.sh
interval = 60
```

View File

@ -0,0 +1,16 @@
#!/bin/sh
duetoday=$(grep "due:$(date -I)" ~/todo.txt | grep -c -v "x")
dueweek=0
weekday=0
while [ "$weekday" -le 7 ]; do
dueweek=$((dueweek + $(grep "due:$(date -I --date="$weekday day")" ~/todo.txt | grep -c -v "x")))
weekday=$(( weekday + 1 ))
done
if [ "$dueweek" -gt 0 ]; then
echo "#1 $duetoday $dueweek"
else
echo "#2"
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

View File

@ -0,0 +1,16 @@
# Script: info-trash
This script count the files in you trash directory.
![info-trash](screenshots/1.png)
## Module
```ini
[module/info-trash]
type = custom/script
exec = ~/polybar-scripts/info-trash.sh
interval = 60
click-left = ~/polybar-scripts/info-trash.sh --clean
```

View File

@ -0,0 +1,13 @@
#!/bin/sh
case "$1" in
--clean)
rm -rf ~/.local/share/Trash/files
rm -rf ~/.local/share/Trash/info
mkdir ~/.local/share/Trash/files
mkdir ~/.local/share/Trash/info
;;
*)
find ~/.local/share/Trash/files/ -maxdepth 1 | wc -l
;;
esac

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

View File

@ -0,0 +1,37 @@
# Script: info-twitch-countdown
This script pulls the time a live streamer is streaming from their Streamlabs countdown on their twitch page.
Please note that because Streamlabs does not have a public API, a Chromium process is launched to gather the information. This will use about 250 MiB of memory for a few seconds every hour. You can also include multiple instances of this on your bar to view the stream times of multiple twitch streamers.
![info-twitch-countdown](screenshots/1.png)
![info-twitch-live](screenshots/2.png)
## Dependencies
* `chromium`
* `jq`
* [cyrus-and/chrome-har-capturer](https://github.com/cyrus-and/chrome-har-capturer)
## Configuration
Get a Twitch Client ID:
* Go to [twitch.tv/console/apps/create](https://glass.twitch.tv/console/apps/create) and sign in
* Login, then go to `Apps` > `Register`
* Use any name and category, and set OAuth Redirect URL to `http://localhost`
* Click Manage on the application, and copy the Client ID from the end of the URL or from the box
If you want to be hide the seconds on the counter, you may comment the "showSeconds" line in the script. Please note that you may experience 10-20 seconds pauses every hour when the countdown updates.
## Module
```ini
[module/info-twitch-countdown]
type = custom/script
exec = ~/polybar-scripts/info-twitch-countdown.sh <streamer username>
tail = true
```

View File

@ -0,0 +1,68 @@
#!/bin/bash
streamer="$1" # You may change this to the streamer's username to override the command line argument.
filePath=""
clientId=
showSeconds=":%S" # Uncomment to hide seconds in countdown
function checkLive() {
while [[ $(curl -s https://api.twitch.tv/helix/streams?user_login="$streamer" -H "Client-ID: $clientId" | jq '.data[] | select(.type=="live")') ]]; do
echo "#1 LIVE"
sleep 10
done
}
function updateAuth() {
chromium --remote-debugging-port=9222 --headless >/dev/null 2>&1 & disown
sleep .1
chrome-har-capturer -f -c -g 7500 -o "$filePath/$streamer.har" https://twitch.tv/"$streamer" >/dev/null 2>&1
kill -1 "$(pgrep -f 'chromium --remote-debugging-port=9222 --headless')"
}
function checkReauth() {
if [[ ! -f "$filePath/$streamer.har" || "$(($(date +%s)-$(date +%s -r "$filePath/$streamer.har")))" -gt 3300 ]]; then
updateAuth
fi
}
function updateData() {
auth=$(jq -r '.["log"]["entries"][]["request"] | select(.url=="https://xt.streamlabs.com/api/v5/twitch-extensions/countdown/settings") | select(.method=="GET") | .["headers"][] | select(.name=="authorization") | .value' "$filePath/$streamer.har")
countdownData=$(curl -s https://xt.streamlabs.com/api/v5/twitch-extensions/countdown/settings -H "Authorization: $auth")
days=$(echo "$countdownData" | jq -r '.["enabled"] | keys[] as $k | "\($k), \(.[$k])" | select(endswith("true"))' | cut -d ',' -f1)
[[ -n "$1" ]] && days=$(echo "$days" | sed "/$1/d")
closestDay="8days"
for i in $days; do
dayUnixTime=$(date +%s --date="$i")
if [[ "$dayUnixTime" -lt "$(date +%s --date=$closestDay)" ]]; then
closestDay="$i"
fi
done
hour=$(echo "$countdownData" | jq -r ".[\"$closestDay\"][][\"HH\"]")
minute=$(echo "$countdownData" | jq -r ".[\"$closestDay\"][][\"mm\"]")
timeZone=$(echo "$countdownData" | jq '.["timezone"]')
streamTime=$(date +%s --date="TZ=$timeZone $closestDay $hour:$minute")
[[ "$(date +%s)" -gt "$streamTime" ]] && updateData "$closestDay"
}
function main() {
while [[ "$streamTime" -ge "$(date +%s)" ]]; do
daysUntil="$(((streamTime - $(date +%s))/86400)):"
[[ "$daysUntil" == "0:" ]] && daysUntil=
countdown="$(date -u --date @$((streamTime - "$(date +%s)")) +$daysUntil%H:%M"$showSeconds")"
echo "#2 $countdown"
[ $(($(date +%s) % 10)) -eq 0 ] && checkLive
checkReauth
sleep 1
done
checkLive
updateAuth
updateData
main
}
checkLive
updateAuth
updateData
main

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,20 @@
# Script: info-wifionice
This script shows some information about the current ICE train of Deutsche Bahn. It requests the data from the local information portal and was obviously hacked in a train.
![info-wifionice](screenshots/1.png)
## Dependencies
* You have to be logged in to the local SSID `WIFIonICE`.
## Module
```ini
[module/info-wifionice]
type = custom/script
exec = ~/polybar-scripts/info-wifionice.sh
interval = 10
```

View File

@ -0,0 +1,30 @@
#!/bin/sh
wifionice=$(curl -sf https://iceportal.de/api1/rs/status)
if [ "$(echo "$wifionice" | jq .connection)" = "true" ]; then
wifionice_speed=$(echo "$wifionice" | jq .speed)
if [ "$wifionice_speed" -ne 0 ]; then
wifionice_speed="$wifionice_speed km/h"
else
wifionice_speed=""
fi
station=$(curl -sf https://iceportal.de/api1/rs/tripInfo/trip | jq '[.[].stops[]? | select(.info.passed == false)][0]')
station_name=$(echo "$station" | jq -r '.station.name')
station_track=$(echo "$station" | jq -r '.track.actual')
station_arrival=$(echo "$station" | jq -r '.timetable.scheduledArrivalTime')
station_arrival=$(date --date="@$((station_arrival / 1000))" +%H:%M)
station_delay=$(echo "$station" | jq -r '.timetable.arrivalDelay')
if [ ! -z "$station_delay" ]; then
station_delay=" %{F#d60606}($station_delay)%{F-}"
else
station_delay=""
fi
echo "# $station_arrival$station_delay - $station_name, Gl. $station_track - $wifionice_speed"
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -0,0 +1,21 @@
# Script: info-wmname
This script prints the value of the window manager name property of the root window.
The BSPWM window manger, and maybe some more, has some problems with java scaling. To solve this you can [set the value of the window manager name property](https://wiki.archlinux.org/index.php/java#Impersonate_another_window_manager) to something different.
## Dependencies
* `wmname`
## Module
```ini
[module/info-wmname]
type = custom/script
exec = ~/polybar-scripts/info-wmname.sh
interval = 5
click-left = ~/polybar-scripts/info-wmname.sh --toggle
```

View File

@ -0,0 +1,15 @@
#!/bin/sh
case "$1" in
--toggle)
if [ "$(wmname)" != "BSPWM" ]; then
wmname BSPWM
else
wmname LG3D
fi
;;
*)
wmname=$(wmname)
echo "# $wmname"
;;
esac

View File

@ -0,0 +1,24 @@
# Script: info-xampp
The Script prints the status of [XAMPP](https://www.apachefriends.org/de/index.html) services (Apache, MySQL, ProFTPD) if they are running.
![info-xampp](screenshots/1.png)
## Configuration
You may need to add `xampp` command to the `/etc/sudoers` NOPASSWD of your user:
```ini
user ALL=(ALL) NOPASSWD: /opt/lampp/xampp
```
## Module
```ini
[module/info-xampp]
type = custom/script
exec = ~/polybar-scripts/info-xampp.sh
interval = 10
```

View File

@ -0,0 +1,21 @@
#!/bin/sh
if sudo /opt/lampp/xampp status | grep -q "Apache is running."; then
status_apache="#11"
else
status_apache="#12"
fi
if sudo /opt/lampp/xampp status |grep -q "MySQL is running."; then
status_mysql="#21"
else
status_mysql="#22"
fi
if sudo /opt/lampp/xampp status | grep -q "ProFTPD is running."; then
status_ftp="#31"
else
status_ftp="#32"
fi
echo "$status_apache $status_mysql $status_ftp"

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,13 @@
# Script: isactive-bluetooth
A script that shows if bluetooth is on or off.
## Module
```ini
[module/isactive-bluetooth]
type = custom/script
exec = ~/polybar-scripts/isactive-bluetooth.sh
interval = 10
```

View File

@ -0,0 +1,7 @@
#!/bin/sh
if [ "$(systemctl is-active bluetooth.service)" = "active" ]; then
echo "#1"
else
echo "#2"
fi

View File

@ -0,0 +1,16 @@
# Script: isrunning-claudius
A tiny module to report the state of claudius, the alternative filepicker for Discord.
Left click launches or closes claudius.
## Module
```ini
[module/isrunning-claudius]
type = custom/script
exec = ~/polybar-scripts/isrunning-claudius.sh
interval = 5
click-left = ~/polybar-scripts/isrunning-claudius --toggle
```

View File

@ -0,0 +1,18 @@
#!/bin/sh
case "$1" in
--toggle)
if [ "$(pgrep claudius)" ]; then
pkill claudius
else
claudius &
fi
;;
*)
if [ "$(pgrep claudius)" ]; then
echo "#1"
else
echo "#2"
fi
;;
esac

View File

@ -0,0 +1,14 @@
# Script: isrunning-compton
A simple script that allows you to toggle compton and shows if it is running.
## Module
```ini
[module/isrunning-compton]
type = custom/script
exec = ~/polybar-scripts/isrunning-compton.sh
interval = 5
click-left = ~/polybar-scripts/isrunning-compton.sh --toggle
```

View File

@ -0,0 +1,18 @@
#!/bin/sh
case "$1" in
--toggle)
if [ "$(pgrep -x compton)" ]; then
pkill compton
else
compton -b --config ~/.config/compton/config
fi
;;
*)
if [ "$(pgrep -x compton)" ]; then
echo "#1"
else
echo "#2"
fi
;;
esac

View File

@ -0,0 +1,14 @@
# Script: dropbox-isrunning
A script that shows if the dropbox client is running. You can also start and stop the client.
## Module
```ini
[module/dropbox-isrunning]
type = custom/script
exec = ~/polybar-scripts/dropbox-isrunning.sh
interval = 5
click-left = ~/polybar-scripts/dropbox-isrunning.sh --toggle
```

View File

@ -0,0 +1,18 @@
#!/bin/sh
case "$1" in
--toggle)
if [ "$(pgrep dropbox)" ]; then
pkill -f dropbox
else
dropbox &
fi
;;
*)
if [ "$(pgrep dropbox)" ]; then
echo "#1"
else
echo "#2"
fi
;;
esac

View File

@ -0,0 +1,14 @@
# Script: isrunning-offlineimap
A script that shows if offlineimap is running. The scripts require you to have setup offlineimap yourself.
## Module
```ini
[module/offlineimap-isrunning]
type = custom/script
exec = ~/polybar-scripts/offlineimap-isrunning.sh
interval = 5
click-left = ~/polybar-scripts/offlineimap-isrunning.sh --toggle
```

View File

@ -0,0 +1,18 @@
#!/bin/sh
case "$1" in
--toggle)
if [ "$(pgrep offlineimap)" ]; then
pkill -f offlineimap
else
nohup offlineimap > /tmp/offlineimap.log &
fi
;;
*)
if [ "$(pgrep offlineimap)" ]; then
echo "#1 Online"
else
echo "#2 Offline"
fi
;;
esac

View File

@ -0,0 +1,18 @@
# Script: news-archlinux
A Python script that shows Arch Linux RSS news.
## Dependencies
* [python-feedparser](https://github.com/kurtmckee/feedparser//)
## Module
```ini
[module/news-archlinux]
type = custom/script
exec = ~/polybar-scripts/news-archlinux.py
interval = 600
```

View File

@ -0,0 +1,12 @@
#!/usr/bin/python
import feedparser
from subprocess import call
import re
import textwrap
d = feedparser.parse("https://www.archlinux.org/feeds/news/")
for f in range(0, 1):
print(d.entries[f].title)
xy = d.entries[f].title

View File

@ -0,0 +1,23 @@
# Script: notification-chess
A small script that indicates whether you need to move.
![notification-chess](screenshots/1.png)
## Dependencies
* `curl`
* `jq`
* obviously a chess.com account
## Module
```ini
[module/notification-chess]
type = custom/script
exec = ~/polybar-scripts/notification-chess.sh
interval = 10
click-left = xdg-open https://www.chess.com/goto_ready_game & disown
```

View File

@ -0,0 +1,10 @@
#!/bin/sh
username=""
games=$(curl -sf "https://api.chess.com/pub/player/$username/games/to-move" | jq ".[] | length")
if [ "$games" -gt 0 ]; then
echo "#1 $games"
else
echo "#2"
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

View File

@ -0,0 +1,24 @@
# Script: notification-github
A small script that shows your GitHub notifications.
## Dependencies
* `curl`
* `jq`
## Configuration
Generate a token at `GitHub Settings` > `Developer settings` > `Personal access tokens`.
## Module
```ini
[module/notification-github]
type = custom/script
exec = ~/polybar-scripts/notification-github.sh
interval = 60
```

View File

@ -0,0 +1,11 @@
#!/bin/sh
TOKEN="1234567890"
notifications=$(curl -fs https://api.github.com/notifications?access_token=$TOKEN | jq ".[].unread" | grep -c true)
if [ "$notifications" -gt 0 ]; then
echo "# $notifications"
else
echo ""
fi

View File

@ -0,0 +1,24 @@
# Script: notification-mattermost
A small script that shows your unread Mattermost messages and mentions.
## Dependencies
* `curl`
* `jq`
## Configuration
Generate a token at `Account Settings` > `Security` > `Personal Access Tokens`. You have to enable tokens in your server config.
## Module
```ini
[module/notification-mattermost]
type = custom/script
exec = ~/polybar-scripts/notification-mattermost.sh
interval = 60
```

View File

@ -0,0 +1,15 @@
#!/bin/sh
MATTERMOST_SERVER="https://mattermost-server.net"
MATTERMOST_TOKEN=""
if notifications=$(curl -sf -H "Authorization: Bearer $MATTERMOST_TOKEN" "$MATTERMOST_SERVER/api/v4/users/me/teams/unread"); then
notifications_msg=$(echo "$notifications" | jq -s 'map(.[].msg_count) | add')
notifications_mention=$(echo "$notifications" | jq -s 'map(.[].mention_count) | add')
if [ "$notifications_msg" -gt 0 ] || [ "$notifications_mention" -gt 0 ]; then
echo "# $notifications_msg / $notifications_mention"
else
echo ""
fi
fi

View File

@ -0,0 +1,15 @@
# Script: openvpn-isrunning
A script that shows if OpenVPN is running.
![openvpn-isrunning](screenshots/1.png)
## Module
```ini
[module/openvpn-isrunning]
type = custom/script
exec = ~/polybar-scripts/openvpn-isrunning.sh
interval = 5
```

View File

@ -0,0 +1,7 @@
#!/bin/sh
if [ "$(pgrep openvpn)" ]; then
echo "#1"
else
echo "#2"
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,28 @@
# Script: openvpn-status
A script that shows if OpenVPN is running and which configuration file it uses.
![openvpn-status](screenshots/1.png)
![openvpn-status](screenshots/2.png)
## Configuration
* The configuration files must have an extension, e.g. `.ovpn`.
* The configuration files must be stored in a directory, e.g. `/etc/openvpn/conf.d`.
Launch OpenVPN with the following command:
```
openvpn --daemon --auth-nocache --cd "/etc/openvpn/conf.d" --config "UK-Southampton.ovpn"
```
## Module
```ini
[module/openvpn]
type = custom/script
exec = ~/polybar-scripts/openvpn-status.sh
interval = 5
```

View File

@ -0,0 +1,3 @@
#!/bin/sh
printf "VPN: " && (pgrep -a openvpn$ | head -n 1 | awk '{print $NF }' | cut -d '.' -f 1 && echo down) | head -n 1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@ -0,0 +1,46 @@
# Script: openweathermap-detailed
A weather script that displays some weather information.
It shows icons, temperatures and text for the current weather. The script can be easily modified to display a forecast. Look at the commented out line.
![openweathermap-detailed](screenshots/1.png)
## Dependencies
* [OpenWeatherMap-Key](https://openweathermap.org/appid)
* [weather-icons](https://github.com/erikflowers/weather-icons)
* `jq`
## Configuration
If `CITY` is left empty, the location is retrieved via the Mozilla Location API. `CITY` can either be a city ID (e.g. ID of Berlin is `2950159`), city name (e.g. `Berlin`) or city name + country code (e.g. `Berlin,DE`).
Change these values:
```sh
KEY=""
CITY=""
UNITS="metric"
SYMBOL="°"
```
## Module
```ini
[bar/polybar]
...
font-2 = Weather Icons:size=12;1
...
```
```ini
[module/openweathermap-detailed]
type = custom/script
exec = ~/polybar-scripts/openweathermap-detailed.sh
interval = 600
label-font = 3
```

View File

@ -0,0 +1,60 @@
#!/bin/sh
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
}
KEY=""
CITY=""
UNITS="metric"
SYMBOL="°"
API="https://api.openweathermap.org/data/2.5"
if [ ! -z $CITY ]; then
if [ "$CITY" -eq "$CITY" ] 2>/dev/null; then
CITY_PARAM="id=$CITY"
else
CITY_PARAM="q=$CITY"
fi
weather=$(curl -sf "$API/weather?appid=$KEY&$CITY_PARAM&units=$UNITS")
# weather=$(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 [ ! -z "$location" ]; then
location_lat="$(echo "$location" | jq '.location.lat')"
location_lon="$(echo "$location" | jq '.location.lng')"
weather=$(curl -sf "$API/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS")
fi
fi
if [ ! -z "$weather" ]; then
weather_desc=$(echo "$weather" | jq -r ".weather[0].description")
weather_temp=$(echo "$weather" | jq ".main.temp" | cut -d "." -f 1)
weather_icon=$(echo "$weather" | jq -r ".weather[0].icon")
echo "$(get_icon "$weather_icon")" "$weather_desc", "$weather_temp$SYMBOL"
fi

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,44 @@
# Script: openweathermap-forecast
A weather script that displays a weather forecast.
It shows icons and temperatures for the current weather and the 3 hour forecast.
## Dependencies
* [OpenWeatherMap-Key](https://openweathermap.org/appid)
* [weather-icons](https://github.com/erikflowers/weather-icons)
* `jq`
## Configuration
If `CITY` is left empty, the location is retrieved via the Mozilla Location API. `CITY` can either be a city ID (e.g. ID of Berlin is `2950159`), city name (e.g. `Berlin`) or city name + country code (e.g. `Berlin,DE`).
Change these values:
```sh
KEY=""
CITY=""
UNITS="metric"
SYMBOL="°"
```
## Module
```ini
[bar/polybar]
...
font-2 = Weather Icons:size=12;1
...
```
```ini
[module/openweathermap-forecast]
type = custom/script
exec = ~/polybar-scripts/openweathermap-forecast.sh
interval = 600
label-font = 3
```

View File

@ -0,0 +1,71 @@
#!/bin/sh
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
}
KEY=""
CITY=""
UNITS="metric"
SYMBOL="°"
API="https://api.openweathermap.org/data/2.5"
if [ ! -z $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 [ ! -z "$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 [ ! -z "$current" ] && [ ! -z "$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
echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL"
fi

Some files were not shown because too many files have changed in this diff Show More