mirror of
https://github.com/olexsmir/dotfiles.git
synced 2026-01-15 16:51:34 +02:00
Add: i3, polybar, rofi, redshift config
This commit is contained in:
parent
68604c9c6a
commit
f8ffdbda2e
15 changed files with 1356 additions and 0 deletions
245
config/polybar/config
Normal file
245
config/polybar/config
Normal file
|
|
@ -0,0 +1,245 @@
|
|||
[settings]
|
||||
pseudo-transparency = true
|
||||
|
||||
[colors]
|
||||
background = #002B36
|
||||
background-alt = #073642
|
||||
foreground = #dfdfdf
|
||||
foreground-alt = #fdf6e3
|
||||
primary = #268bd2
|
||||
secondary = #218DC8
|
||||
alert = #268bd2
|
||||
;alert = #dc322f
|
||||
|
||||
############################################################################################################
|
||||
[bar/example]
|
||||
#monitor = ${env:MONITOR:HDMI-1}
|
||||
width = 100%
|
||||
height = 26
|
||||
fixed-center = true
|
||||
locale = en_US.UTF-8
|
||||
|
||||
background = ${colors.background}
|
||||
foreground = ${colors.foreground}
|
||||
|
||||
line-size = 1
|
||||
line-color = #f00
|
||||
|
||||
padding-left = 0
|
||||
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
|
||||
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
|
||||
cursor-click = pointer
|
||||
cursor-scroll = ns-resize
|
||||
wm-restack = i3
|
||||
|
||||
############################################################################################################
|
||||
; i3wm workspace indicator
|
||||
[module/i3]
|
||||
type = internal/i3
|
||||
format = <label-state><label-mode>
|
||||
index-sort = true
|
||||
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-foreground = ${colors.foreground}
|
||||
label-focused-padding = 1
|
||||
label-focused-underline = 018BFF
|
||||
#label-focused-overline = ${colors.primary}
|
||||
|
||||
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 "
|
||||
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 "
|
||||
;label-separator = |
|
||||
|
||||
############################################################################################################
|
||||
# PulseAudio- https://github.com/polybar/polybar/wiki/Module:-pulseaudio
|
||||
[module/pulseaudio]
|
||||
type = internal/pulseaudio
|
||||
format-volume = %{F#61a8ff}<ramp-volume><label-volume>
|
||||
label-volume = %{F#61a8ff} %percentage%%
|
||||
label-volume-foreground = ${root.foreground}
|
||||
label-muted =
|
||||
label-muted-foreground = #e8793e
|
||||
|
||||
ramp-volume-0 =
|
||||
ramp-volume-1 =
|
||||
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
|
||||
format-prefix = " "
|
||||
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/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
|
||||
|
||||
############################################################################################################
|
||||
; Keyboard layout - https://github.com/polybar/polybar/wiki/Module:-xkeyboard
|
||||
[module/xkeyboard]
|
||||
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
|
||||
|
||||
############################################################################################################
|
||||
; Battery - https://github.com/polybar/polybar/wiki/Module:-battery
|
||||
[module/battery-combined-tlp]
|
||||
type = custom/script
|
||||
exec = ~/.config/polybar/scripts/battery-combined-tlp.sh
|
||||
interval = 10
|
||||
|
||||
############################################################################################################
|
||||
; 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%
|
||||
|
||||
############################################################################################################
|
||||
; 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
|
||||
4
config/polybar/launch.sh
Executable file
4
config/polybar/launch.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
killall -q polybar
|
||||
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
|
||||
polybar example &
|
||||
5
config/polybar/scripts/battery-combined-tlp.sh
Executable file
5
config/polybar/scripts/battery-combined-tlp.sh
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
battery=$(sudo tlp-stat -b | tac | grep -m 1 "Charge" | tr -d -c "[:digit:],.")
|
||||
|
||||
echo " $battery %"
|
||||
25
config/polybar/scripts/btc
Executable file
25
config/polybar/scripts/btc
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/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);
|
||||
57
config/polybar/scripts/openweathermap-simple.sh
Executable file
57
config/polybar/scripts/openweathermap-simple.sh
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
#!/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
|
||||
41
config/polybar/scripts/popup-calendar.sh
Executable file
41
config/polybar/scripts/popup-calendar.sh
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
#!/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
|
||||
15
config/polybar/scripts/redshift.sh
Executable file
15
config/polybar/scripts/redshift.sh
Executable 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
|
||||
140
config/polybar/scripts/spotify_status.py
Normal file
140
config/polybar/scripts/spotify_status.py
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
#!/usr/bin/env python
|
||||
import sys
|
||||
import dbus
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
'-t',
|
||||
'--trunclen',
|
||||
type=int,
|
||||
metavar='trunclen'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-f',
|
||||
'--format',
|
||||
type=str,
|
||||
metavar='custom format',
|
||||
dest='custom_format'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-p',
|
||||
'--playpause',
|
||||
type=str,
|
||||
metavar='play-pause indicator',
|
||||
dest='play_pause'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--font',
|
||||
type=str,
|
||||
metavar='the index of the font to use for the main label',
|
||||
dest='font'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--playpause-font',
|
||||
type=str,
|
||||
metavar='the index of the font to use to display the playpause indicator',
|
||||
dest='play_pause_font'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-q',
|
||||
'--quiet',
|
||||
action='store_true',
|
||||
help="if set, don't show any output when the current song is paused",
|
||||
dest='quiet',
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
def fix_string(string):
|
||||
# corrects encoding for the python version used
|
||||
if sys.version_info.major == 3:
|
||||
return string
|
||||
else:
|
||||
return string.encode('utf-8')
|
||||
|
||||
|
||||
def truncate(name, trunclen):
|
||||
if len(name) > trunclen:
|
||||
name = name[:trunclen]
|
||||
name += '...'
|
||||
if ('(' in name) and (')' not in name):
|
||||
name += ')'
|
||||
return name
|
||||
|
||||
|
||||
|
||||
# Default parameters
|
||||
output = fix_string(u'{play_pause} {artist}: {song}')
|
||||
trunclen = 35
|
||||
play_pause = fix_string(u'\u25B6,\u23F8') # first character is play, second is paused
|
||||
|
||||
label_with_font = '%{{T{font}}}{label}%{{T-}}'
|
||||
font = args.font
|
||||
play_pause_font = args.play_pause_font
|
||||
|
||||
quiet = args.quiet
|
||||
|
||||
# parameters can be overwritten by args
|
||||
if args.trunclen is not None:
|
||||
trunclen = args.trunclen
|
||||
if args.custom_format is not None:
|
||||
output = args.custom_format
|
||||
if args.play_pause is not None:
|
||||
play_pause = args.play_pause
|
||||
|
||||
try:
|
||||
session_bus = dbus.SessionBus()
|
||||
spotify_bus = session_bus.get_object(
|
||||
'org.mpris.MediaPlayer2.spotify',
|
||||
'/org/mpris/MediaPlayer2'
|
||||
)
|
||||
|
||||
spotify_properties = dbus.Interface(
|
||||
spotify_bus,
|
||||
'org.freedesktop.DBus.Properties'
|
||||
)
|
||||
|
||||
metadata = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'Metadata')
|
||||
status = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus')
|
||||
|
||||
# Handle play/pause label
|
||||
|
||||
play_pause = play_pause.split(',')
|
||||
|
||||
if status == 'Playing':
|
||||
play_pause = play_pause[0]
|
||||
elif status == 'Paused':
|
||||
play_pause = play_pause[1]
|
||||
else:
|
||||
play_pause = str()
|
||||
|
||||
if play_pause_font:
|
||||
play_pause = label_with_font.format(font=play_pause_font, label=play_pause)
|
||||
|
||||
# Handle main label
|
||||
|
||||
artist = fix_string(metadata['xesam:artist'][0]) if metadata['xesam:artist'] else ''
|
||||
song = fix_string(metadata['xesam:title']) if metadata['xesam:title'] else ''
|
||||
album = fix_string(metadata['xesam:album']) if metadata['xesam:album'] else ''
|
||||
|
||||
if (quiet and status == 'Paused') or (not artist and not song and not album):
|
||||
print('')
|
||||
else:
|
||||
if font:
|
||||
artist = label_with_font.format(font=font, label=artist)
|
||||
song = label_with_font.format(font=font, label=song)
|
||||
album = label_with_font.format(font=font, label=album)
|
||||
|
||||
# Add 4 to trunclen to account for status symbol, spaces, and other padding characters
|
||||
print(truncate(output.format(artist=artist,
|
||||
song=song,
|
||||
play_pause=play_pause,
|
||||
album=album), trunclen + 4))
|
||||
|
||||
except Exception as e:
|
||||
if isinstance(e, dbus.exceptions.DBusException):
|
||||
print('')
|
||||
else:
|
||||
print(e)
|
||||
16
config/polybar/scripts/updates-pacman.sh
Executable file
16
config/polybar/scripts/updates-pacman.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/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
|
||||
Loading…
Add table
Add a link
Reference in a new issue