Add scripts & configs

This commit is contained in:
Smirnov Olexandr 2020-10-16 22:55:26 +03:00
parent f8ffdbda2e
commit 734af357dd
33 changed files with 1432 additions and 957 deletions

View file

@ -3,26 +3,25 @@ pseudo-transparency = true
[colors]
background = #002B36
background-alt = #073642
background-alt = #002236
foreground = #dfdfdf
foreground-alt = #fdf6e3
foreground-alt = #f0f0f0
primary = #268bd2
secondary = #218DC8
alert = #268bd2
;alert = #dc322f
############################################################################################################
[bar/example]
#monitor = ${env:MONITOR:HDMI-1}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[bar/bar]
;monitor = ${env:MONITOR:HDMI-1}
width = 100%
height = 26
height = 25
fixed-center = true
locale = en_US.UTF-8
background = ${colors.background}
foreground = ${colors.foreground}
line-size = 1
line-size = 2
line-color = #f00
padding-left = 0
@ -30,41 +29,22 @@ padding-right = 0
module-margin-left = 1
module-margin-right = 1
; Fonts
font-0 = Iosevka Nerd Font:style=Medium:size=8;3
font-1 = FontAwesome5Free:style=Solid:size=7.5;2.5
font-2 = Weather Icons:size=7;2
font-3 = FontAwesome5Brands:style=Solid:size=7.5;2.5
############################################################################################################
; Modules position
modules-left = i3 sp2 openweathermap-simple updates-pacman
;modules-center = title
modules-center = spotify
modules-right = pulseaudio xkeyboard powermenu sp2 calendar
;; Modules positii3on ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
modules-left = i3 sp2 weather updates-pacman
modules-center =
modules-right = pulseaudio microphone backlight keyboard clipmenu wlan date time sp2
tray-position = right
tray-padding = 2
tray-detached = false
############################################################################################################
# INCLUDE MODULES
############################################################################################################
[module/filesystem]
type = internal/fs
interval = 25
mount-0 = /
mount-1 = /home
label-mounted = %{F#c38611} %mountpoint%: %percentage_used%%
label-unmounted = %mountpoint% not mounted
label-unmounted-foreground = ${colors.foreground-alt}
############################################################################################################
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[settings]
screenchange-reload = true
############################################################################################################
; Used for top and bottom aligned bars
[global/wm]
margin-top = 5
margin-bottom = 5
@ -72,8 +52,7 @@ cursor-click = pointer
cursor-scroll = ns-resize
wm-restack = i3
############################################################################################################
; i3wm workspace indicator
[module/i3]
type = internal/i3
format = <label-state><label-mode>
@ -82,33 +61,28 @@ wrapping-scroll = false
label-mode-padding = 1
label-mode-foreground = #000
label-mode-background = ${colors.primary}
label-focused = %icon%
label-focused-background = 002873C0
label-focused-background = 073642
label-focused-foreground = ${colors.foreground}
label-focused-padding = 1
label-focused-underline = 018BFF
#label-focused-overline = ${colors.primary}
label-focused-underline = 268bd2
label-unfocused = %icon%
label-unfocused-background = 00255498
label-unfocused-foreground = ${colors.foreground}
label-unfocused-padding = 1
#label-unfocused-underline = 255498
#label-unfocused-overline = ${colors.background}
label-urgent = %icon%
label-urgent-background = ${colors.alert}
label-urgent-foreground = ${colors.foreground}
label-urgent-padding = 1
label-urgent-underline = ${colors.alert}
#label-urgent-overline = ${colors.background}
label-visible = %icon%
label-visible-background = ${colors.background}
label-visible-foreground = ${colors.foreground}
label-visible-padding = 1
label-visible-underline = ${colors.background}
#label-visible-overline = ${colors.background}
ws-icon-0 = "1;1 "
ws-icon-1 = "2;2 "
@ -118,19 +92,46 @@ 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-8 = 9;9
ws-icon-9 = "10;10 "
;label-separator = |
############################################################################################################
# PulseAudio- https://github.com/polybar/polybar/wiki/Module:-pulseaudio
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; INCLUDE MODULES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[module/backlight]
type = internal/xbacklight
format = <ramp> <label>
label = %percentage%%
ramp-0 = 
[module/wlan]
type = internal/network
interface = wlp3s0
format-connected = <ramp-signal> <label-connected>
label-connected = %essid%
format-disconnected =  No sing
ramp-signal-0 = 
interval = 3.0
[module/filesystem]
type = internal/fs
interval = 25
mount-0 = /
mount-1 = /home
label-mounted = %{F#c38611} %mountpoint%: %percentage_used%%
label-unmounted = %mountpoint% not mounted
label-unmounted-foreground = ${colors.foreground-alt}
[module/pulseaudio]
type = internal/pulseaudio
format-volume = %{F#61a8ff}<ramp-volume><label-volume>
label-volume = %{F#61a8ff} %percentage%%
format-volume = <ramp-volume> <label-volume>
label-volume = %percentage%%
label-volume-foreground = ${root.foreground}
label-muted = 
label-muted-foreground = #e8793e
label-muted = 
ramp-volume-0 = 
ramp-volume-1 = 
@ -138,8 +139,7 @@ ramp-volume-2 = 
ramp-volume-3 = 
ramp-volume-4 = 
############################################################################################################
; CPU Loads - https://github.com/polybar/polybar/wiki/Module:-cpu
[module/cpu]
type = internal/cpu
interval = 2
@ -148,98 +148,81 @@ format-prefix-foreground = ${colors.foreground-alt}
label = %{F#1ecb0b} CPU %percentage%%
############################################################################################################
# Memmory(RAM) - https://github.com/polybar/polybar/wiki/Module:-memory
[module/memory]
type = internal/memory
interval = 2
format-prefix = " "
#format-prefix-foreground = ${colors.foreground-alt}
#format-overline = #61C07C
#format-underline = #61C07C
label = %{F#8d61ff}  MEM %percentage_used%%
############################################################################################################
; Weather
[module/openweathermap-simple]
type = custom/script
exec = ~/.config/polybar/scripts/openweathermap-simple.sh
interval = 60
label-font = 3
############################################################################################################
; Sporify inkator - https://github.com/Jvanrhijn/polybar-spotify
[module/weather]
type = custom/script
exec = python3 ~/.config/polybar/scripts/weather.py
interval = 60
label-font = 1
[module/spotify]
type = custom/script
interval = 1
format-prefix = " "
format = <label>
exec = python ~/.config/polybar/scripts/spotify_status.py -f '{artist} - {song}'
line-size
format-underline = #1db954
############################################################################################################
; Updates cheacker (pacman)
[module/updates-pacman]
type = custom/script
exec = ~/.config/polybar/scripts/updates-pacman.sh
interval = 600
exec = ~/.config/polybar/scripts/updates-pacman-aur.sh
interval = 60
############################################################################################################
; Keyboard layout - https://github.com/polybar/polybar/wiki/Module:-xkeyboard
[module/xkeyboard]
[module/keyboard]
type = internal/xkeyboard
blacklist-0 = num lock
label-NAME-maxlen = 10
format-prefix = ""
label-layout =  %layout%
label-indicator-padding = 2
label-indicator-margin = 1
label-indicator-background = 2B7DBC
label-indicator-overline = 2B7DBC
label-indicator-underline = 2B7DBC
blacklist-0 = num lock
blacklist-1 = scroll lock
blacklist-2= caps lock
############################################################################################################
; Battery - https://github.com/polybar/polybar/wiki/Module:-battery
[module/battery-combined-tlp]
[module/microphone]
type = custom/script
exec = ~/.config/polybar/scripts/battery-combined-tlp.sh
interval = 10
label = %output:0:40:...%
exec = ~/.config/polybar/scripts/microphone.sh  
click-left = ~/.config/polybar/scripts/microphone.sh --click
interval = 0
############################################################################################################
; Separator
[module/sp2]
type = custom/text
content = "┇"
; content-foreground = #93A1A1
############################################################################################################
; Calendar
[module/calendar]
type = custom/script
exec = ~/.config/polybar/scripts/popup-calendar.sh
interval = 5
click-left = ~/.config/polybar/scripts/popup-calendar.sh --popup &
############################################################################################################
# Date & time - https://github.com/polybar/polybar/wiki/Module:-date
[module/date]
type = internal/date
interval = 1
dqate =
time =%{F#E0D9FF} %H:%M:%S
date-alt =%{F#E0D9FF} %a %e %B %Y
time-alt = %H:%M
format-prefix = 
label = %date% %time%
interval = 600
date = %b %e
label =  %date%
[module/time]
type = internal/date
interval = 0
time = %H:%M
label =  %time%
############################################################################################################
; Focus window name - https://github.com/polybar/polybar/wiki/Module:-xwindow
[module/title]
type = internal/xwindow
label = %{F#f0f0f0}%title:0:50:...%
label-empty = Empty
label-empty-foreground = #707880
label-maxlen = 30
label-padding = 0
[module/clipmenu]
type = custom/text
content = ""
click-left = "CM_LAUNCHER=rofi clipmenu"
interval = 0

View file

@ -1,4 +1,11 @@
#!/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
polybar example &
# Launch Polybar, using default config location ~/.config/polybar/config
polybar bar &
echo "Polybar launched..."

View file

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

View file

@ -1,25 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json,sys,urllib.request,time
if len(sys.argv) != 3:
print("Usage: btc usd,eur,btc nok")
sys.exit()
currencies = sys.argv[1]
basecurrency = sys.argv[2]
currencyurl = "http://freecurrencyrates.com/api/action.php?do=cvals&iso=" + currencies.replace(',','') + "&f=" + basecurrency + "&v=1&s=cbr"
f = urllib.request.urlopen(currencyurl)
obj = json.loads(f.read())
res="";
for c in currencies.split(','):
res += c.upper() + ":{:,.2f}".format(1/obj[c.upper()]).replace(',',' ')
# some unicode currency code replacement (optional)
res = res.replace("USD", " $")
res = res.replace("EUR", " €")
res = res.replace("BTC", " ")
print(res);

View file

@ -0,0 +1,21 @@
#!/bin/bash
MICSYMBOL=$1
MICMUTEDSYMBOL=$2
case "$1" in
--click)
amixer -D pulse sset Capture toggle
;;
*)
;;
esac
STATUS=$(amixer -D pulse get Capture | grep -E "\[on\]|\[off\]" | cut -s -d ' ' -f 8 | uniq)
if [[ $STATUS = "[on]" ]]; then
echo $MICSYMBOL
elif [[ $STATUS = "[off]" ]]; then
echo $MICMUTEDSYMBOL
else
echo "Not working, check script."
fi

View file

@ -1,57 +0,0 @@
#!/bin/sh
API="https://api.openweathermap.org/data/2.5"
KEY="34e5d198afe8fb0303e3c3c37774d2ca"
CITY="Horodnytsya, UA"
UNITS="metric"
SYMBOL="°С"
get_icon() {
case $1 in
# Icons for weather-icons
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
}
if [ -n "$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")
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')"
weather=$(curl -sf "$API/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS")
fi
fi
if [ -n "$weather" ]; then
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_temp$SYMBOL"
fi

View file

@ -1,41 +0,0 @@
#!/bin/sh
BAR_HEIGHT=22 # polybar height
BORDER_SIZE=1 # border size from your wm settings
YAD_WIDTH=222 # 222 is minimum possible value
YAD_HEIGHT=193 # 193 is minimum possible value
DATE="$(date +"%a %d %H:%M")"
case "$1" in
--popup)
if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then
exit 0
fi
eval "$(xdotool getmouselocation --shell)"
eval "$(xdotool getdisplaygeometry --shell)"
# X
if [ "$((X + YAD_WIDTH / 2 + BORDER_SIZE))" -gt "$WIDTH" ]; then #Right side
: $((pos_x = WIDTH - YAD_WIDTH - BORDER_SIZE))
elif [ "$((X - YAD_WIDTH / 2 - BORDER_SIZE))" -lt 0 ]; then #Left side
: $((pos_x = BORDER_SIZE))
else #Center
: $((pos_x = X - YAD_WIDTH / 2))
fi
# Y
if [ "$Y" -gt "$((HEIGHT / 2))" ]; then #Bottom
: $((pos_y = HEIGHT - YAD_HEIGHT - BAR_HEIGHT - BORDER_SIZE))
else #Top
: $((pos_y = BAR_HEIGHT + BORDER_SIZE))
fi
yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \
--width="$YAD_WIDTH" --height="$YAD_HEIGHT" --posx="$pos_x" --posy="$pos_y" \
--title="yad-calendar" --borders=0 >/dev/null &
;;
*)
echo "$DATE"
;;
esac

View file

@ -1,15 +0,0 @@
#!/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

View file

@ -1,7 +1,6 @@
#!/usr/bin/env python
import sys
import dbus
import argparse
# -*- encoding: utf-8 -*-
import sys, dbus, argparse
parser = argparse.ArgumentParser()
parser.add_argument(

View file

@ -0,0 +1,20 @@
#!/bin/sh
if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then
updates_arch=0
fi
if ! updates_aur=$(yay -Qum 2> /dev/null | wc -l); then
# if ! updates_aur=$(cower -u 2> /dev/null | wc -l); then
# if ! updates_aur=$(trizen -Su --aur --quiet | wc -l); then
# if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then
# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then
updates_aur=0
fi
updates=$(("$updates_arch" + "$updates_aur"))
if [ "$updates" -gt 0 ]; then
echo "$updates"
else
echo ""
fi

View file

@ -1,16 +0,0 @@
#!/bin/sh
if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then
updates_arch=0
fi
if ! updates_aur=$(yay -Qum 2> /dev/null | wc -l); then
updates_aur=0
fi
updates=$(("$updates_arch" + "$updates_aur"))
if [ "$updates" -gt 0 ]; then
echo "# $updates"
else
echo ""
fi

View file

@ -0,0 +1,30 @@
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import requests, os
API_KEY = os.getenv("OWM_POLYBAR")
CITY = "Horodnytsya,UA"
try:
JSON = requests.get(f"http://api.openweathermap.org/data/2.5/weather?q={CITY}&lang=EN&&units=metric&appid={API_KEY}").json()
except Exception as e:
print("No connection")
try:
if JSON['weather'][0]['main'] == "Clear": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Thunderstorm": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Drizzle": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Rain": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Snow": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Mist": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Smoke": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Haze": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Dust": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Fog": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Sand": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Ash": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Squall": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Tornado": print("", int(JSON["main"]["temp"]),"°С")
elif JSON['weather'][0]['main'] == "Clouds": print("", int(JSON["main"]["temp"]),"°С")
except Exception as e:
print(int(JSON["main"]["temp"]),"°С")