mirror of
https://github.com/dcarrillo/dotfiles.git
synced 2025-07-02 20:09:26 +00:00
First commit
This commit is contained in:
72
.config/polybar/bar.ini
Normal file
72
.config/polybar/bar.ini
Normal file
@ -0,0 +1,72 @@
|
||||
[settings]
|
||||
screenchange-reload = true
|
||||
|
||||
[global/wm]
|
||||
margin-top = 0
|
||||
margin-bottom = 0
|
||||
include-file = ~/.config/polybar/modules.ini
|
||||
|
||||
[colors]
|
||||
|
||||
background = #263238
|
||||
background-alt = #444
|
||||
foreground = #DFDFDF
|
||||
foreground-alt = #555
|
||||
primary = #F5A70A
|
||||
secondary = #e60053
|
||||
alert = #bd2c40
|
||||
|
||||
; bar colors
|
||||
bn = #43a047
|
||||
bm = #fdd835
|
||||
bd = #e53935
|
||||
|
||||
[bar/top]
|
||||
monitor = ${env:MONITOR:}
|
||||
|
||||
offset-x = 0
|
||||
offset-y = 0
|
||||
radius-top = 0.0
|
||||
radius-bottom = 0.0
|
||||
|
||||
border-bottom-size = 3
|
||||
border-color = ${colors.primary}
|
||||
padding = 1
|
||||
|
||||
module-margin-left = 1
|
||||
module-margin-right = 2
|
||||
separator =
|
||||
dim-value = 1.0
|
||||
locale = es_ES.UTF-8
|
||||
tray-position = none
|
||||
tray-detached = false
|
||||
tray-maxsize = 32
|
||||
tray-background = ${root.background}
|
||||
tray-offset-x = 0
|
||||
tray-offset-y = 0
|
||||
tray-padding = 10
|
||||
tray-scale = 1.0
|
||||
|
||||
width = 100%
|
||||
enable-ipc = true
|
||||
dpi = 96
|
||||
height = 36
|
||||
fixed-center = true
|
||||
|
||||
background = ${colors.background}
|
||||
foreground = ${colors.foreground}
|
||||
|
||||
font-0 = "Droid Sans Mono:size=16;1"
|
||||
; https://fontawesome.com/cheatsheet/free
|
||||
font-1 = "FontAwesome:size=16;2"
|
||||
font-2 = "Material Icons:size=16;1"
|
||||
font-3 = NotoSans-Regular:size=18:weight=bold;2
|
||||
font-4 = NotoSans-Regular:size=18:weight=bold;-7
|
||||
|
||||
modules-left = windows spotify
|
||||
modules-center = date
|
||||
modules-right = updates cpu_bar memory_bar network_manager vpn wireless wired alsa_bar
|
||||
|
||||
cursor-click = pointer
|
||||
cursor-scroll = ns-resize
|
||||
|
13
.config/polybar/launch.sh
Executable file
13
.config/polybar/launch.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
killall -q polybar
|
||||
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
|
||||
|
||||
export TERMINAL_CMD="tilix --profile orange --new-process -e"
|
||||
export WM_CONTROL="wmctrl -a"
|
||||
|
||||
for monitor in $(polybar --list-monitors | cut -d":" -f1); do
|
||||
export MONITOR=$monitor
|
||||
polybar top -c ~/.config/polybar/bar.ini >/dev/null &
|
||||
done
|
||||
|
152
.config/polybar/modules.ini
Normal file
152
.config/polybar/modules.ini
Normal file
@ -0,0 +1,152 @@
|
||||
[module/windows]
|
||||
type = custom/text
|
||||
content =" "
|
||||
click-left = rofi -modi window -show window -theme orange -show-icons -location 1 -yoffset +45 -xoffset +20
|
||||
|
||||
[module/mpd]
|
||||
type = internal/mpd
|
||||
format-online-prefix = " "
|
||||
format-online = <label-song> <icon-prev> <icon-stop> <toggle> <icon-next>
|
||||
|
||||
icon-prev =
|
||||
icon-stop =
|
||||
icon-play =
|
||||
icon-pause =
|
||||
icon-next =
|
||||
|
||||
label-song-maxlen = 30
|
||||
label-song-ellipsis = true
|
||||
|
||||
[module/cpu_bar]
|
||||
|
||||
type = custom/script
|
||||
exec = ~/.config/polybar/scripts/cpu_usage.py
|
||||
format-prefix = "%{A1:$TERMINAL_CMD 'top -o %CPU' &:} %{A-}"
|
||||
format-prefix-foreground = ${colors.foreground-alt}
|
||||
interval = 5
|
||||
|
||||
[module/memory_bar]
|
||||
type = internal/memory
|
||||
format = <bar-used>
|
||||
format-prefix = "%{A1:$TERMINAL_CMD 'top -o RES' &:}RAM %{A-}"
|
||||
format-prefix-foreground = ${colors.foreground-alt}
|
||||
|
||||
bar-used-width = 10
|
||||
bar-used-gradient = false
|
||||
bar-used-indicator =
|
||||
bar-used-indicator-foreground = ${colors.foreground}
|
||||
bar-used-indicator-font = 0
|
||||
bar-used-fill = "%{A1:$TERMINAL_CMD 'top -o RES' &:}%{T5}_%{T-}%{A-}"
|
||||
bar-used-foreground-0 = ${colors.bn}
|
||||
bar-used-foreground-1 = ${colors.bn}
|
||||
bar-used-foreground-2 = ${colors.bn}
|
||||
bar-used-foreground-3 = ${colors.bm}
|
||||
bar-used-foreground-4 = ${colors.bm}
|
||||
bar-used-foreground-5 = ${colors.bm}
|
||||
bar-used-foreground-6 = ${colors.bd}
|
||||
bar-used-foreground-7 = ${colors.bd}
|
||||
bar-used-foreground-8 = ${colors.bd}
|
||||
bar-used-empty = "%{A1:$TERMINAL_CMD 'top -o RES' &:}%{T5}_%{T-}%{A-}"
|
||||
bar-used-empty-foreground = ${colors.foreground-alt}
|
||||
|
||||
|
||||
[module/network_manager]
|
||||
type = custom/text
|
||||
content = ""
|
||||
content-font = 2
|
||||
; since I'm in zsh, bash invocation is necessary even if the shebang is set
|
||||
click-left = /usr/bin/bash ~/.config/polybar/scripts/nmcli_manager
|
||||
|
||||
[module/wireless]
|
||||
type = internal/network
|
||||
interface = wlp4s0
|
||||
interval = 3.0
|
||||
|
||||
format-connected = <ramp-signal> <label-connected>
|
||||
label-connected = "%{A1:/usr/bin/bash ~/.config/polybar/scripts/nmcli_manager:}%essid%%{A-}"
|
||||
format-disconnected =
|
||||
|
||||
ramp-signal-0 =
|
||||
ramp-signal-1 =
|
||||
ramp-signal-2 =
|
||||
ramp-signal-3 =
|
||||
ramp-signal-4 =
|
||||
ramp-signal-foreground = ${colors.foreground}
|
||||
|
||||
[module/wired]
|
||||
type = internal/network
|
||||
interface = enp3s0
|
||||
|
||||
accumulate-stats = true
|
||||
unknown-as-up = true
|
||||
|
||||
format-connected = <label-connected>
|
||||
format-connected-prefix =
|
||||
format-disconnected = <label-disconnected>
|
||||
|
||||
label-connected = "%{A1:/usr/bin/bash ~/.config/polybar/scripts/nmcli_manager:}%downspeed:8% %upspeed:8% %{A-}"
|
||||
label-disconnected = "%{A1:/usr/bin/bash ~/.config/polybar/scripts/nmcli_manager:}Not connected%{A-}"
|
||||
|
||||
[module/vpn]
|
||||
|
||||
type = custom/script
|
||||
exec = ~/.config/polybar/scripts/check_vpn
|
||||
interval = 5
|
||||
|
||||
[module/spotify]
|
||||
|
||||
type = custom/script
|
||||
exec = ~/.config/polybar/scripts/spotify.py
|
||||
interval = 5
|
||||
format-prefix = " "
|
||||
format-font = 1
|
||||
|
||||
[module/date]
|
||||
type = internal/date
|
||||
interval = 1
|
||||
|
||||
date = "%d de %B"
|
||||
date-alt = "%d de %B de %Y"
|
||||
|
||||
time = %H:%M
|
||||
time-alt = %H:%M:%S
|
||||
|
||||
label = %{F#f5a70a}%{T4}%time%%{F-}%{T-} | %date%
|
||||
|
||||
[module/alsa_bar]
|
||||
type = internal/alsa
|
||||
|
||||
format-volume = <label-volume> <bar-volume>
|
||||
label-volume = "%{A3:$TERMINAL_CMD 'pulsemixer' &:}%{A-}"
|
||||
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 = ${colors.bn}
|
||||
bar-volume-foreground-1 = ${colors.bn}
|
||||
bar-volume-foreground-2 = ${colors.bn}
|
||||
bar-volume-foreground-3 = ${colors.bn}
|
||||
bar-volume-foreground-4 = ${colors.bn}
|
||||
bar-volume-foreground-5 = ${colors.bn}
|
||||
bar-volume-foreground-6 = ${colors.bm}
|
||||
bar-volume-foreground-7 = ${colors.bm}
|
||||
|
||||
|
||||
bar-volume-gradient = false
|
||||
bar-volume-indicator =
|
||||
bar-volume-fill = "%{A3:$TERMINAL_CMD 'pulsemixer' &:}%{T5}_%{T-}%{A-}"
|
||||
bar-volume-empty = "%{A3:$TERMINAL_CMD 'pulsemixer' &:}%{T5}_%{T-}%{A-}"
|
||||
bar-volume-empty-foreground = ${colors.foreground-alt}
|
||||
|
||||
click-right = $TERMINAL_CMD 'pulsemixer'
|
||||
|
||||
[module/updates]
|
||||
type = custom/script
|
||||
exec = ~/.config/polybar/scripts/check_updates
|
||||
tail = true
|
||||
interval = 5
|
||||
click-left = $TERMINAL_CMD "yay -Suy --noconfirm" &
|
||||
|
8
.config/polybar/scripts/check_updates
Executable file
8
.config/polybar/scripts/check_updates
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
while true; do
|
||||
UPDATES=$(checkupdates 2>/dev/null | wc -l)
|
||||
|
||||
[[ $UPDATES -gt 0 ]] && echo " $UPDATES" && sleep 30
|
||||
[[ $UPDATES -eq 0 ]] && echo "" && sleep 300
|
||||
done
|
12
.config/polybar/scripts/check_vpn
Executable file
12
.config/polybar/scripts/check_vpn
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
OUTPUT=""
|
||||
|
||||
openvpn=$(pgrep -c openvpn$)
|
||||
[[ $openvpn -gt 0 ]] && OUTPUT=$(eval printf "%.0s" {1..$openvpn})
|
||||
|
||||
openfortivpn=$(pgrep -c openfortivpn$)
|
||||
[[ $openfortivpn -gt 0 ]] && OUTPUT=${OUTPUT}$(eval printf '%.0s' {1..$openfortivpn})
|
||||
|
||||
echo $OUTPUT | sed -e 's/\(.\)/\1 /g'
|
||||
|
43
.config/polybar/scripts/cpu_usage.py
Executable file
43
.config/polybar/scripts/cpu_usage.py
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
colors = {
|
||||
'us': '#43A047', # us, user : time running un-niced user processes
|
||||
'sy': '#87CEFA', # sy, system : time running kernel processes
|
||||
'ni': '#FFFFFF', # ni, nice : time running niced user processes
|
||||
'wa': '#E53935', # wa, IO-wait : time waiting for I/O completion
|
||||
'hi': '#66CDAA', # hi : time spent servicing hardware interrupts
|
||||
'si': '#7FFFD4', # si : time spent servicing software interrupts
|
||||
'st': '#7B2B4E', # st : time stolen from this vm by the hypervisor
|
||||
'id': '#555555'
|
||||
}
|
||||
|
||||
|
||||
def show_cpu_usage():
|
||||
new_env = dict(os.environ)
|
||||
new_env['LANG'] = 'en_US.UTF-8' # ensure that the decimal separator is a point
|
||||
top = subprocess.run(["top", "-bn1"], capture_output=True, env=new_env)
|
||||
|
||||
raw_cpu_usages = top.stdout.decode("utf-8").split('\n')[2]
|
||||
cpu_usage = str.replace(raw_cpu_usages, '%Cpu(s):', '')
|
||||
|
||||
bar = ''
|
||||
global_count = 0
|
||||
for usage in cpu_usage.split(','):
|
||||
value, key = str.lstrip(usage).split(' ')
|
||||
count = round(float(value) / 10)
|
||||
if count > 0 and key != 'id':
|
||||
global_count += count
|
||||
bar += '%{F' + colors[key] + '}' + '_' * count + '%{F-}'
|
||||
|
||||
padding = ''
|
||||
if global_count < 10:
|
||||
padding = '%{F' + colors['id'] + '}' + '_' * (10 - global_count) + '%{F-}'
|
||||
|
||||
print("%{A1:$TERMINAL_CMD 'top -o %CPU' &:}%{T5}" + bar + padding + "%{T-}%{A-}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
show_cpu_usage()
|
77
.config/polybar/scripts/nmcli_manager
Executable file
77
.config/polybar/scripts/nmcli_manager
Executable file
@ -0,0 +1,77 @@
|
||||
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# nmcli connection switching from a rofi menu.
|
||||
# When a network is selected its status is switched from UP to DOWN or vice versa.
|
||||
#
|
||||
# WARNING, connection name can't contain a # or | symbol
|
||||
#
|
||||
|
||||
ROFI="rofi -dmenu
|
||||
-sep #
|
||||
-i -p Network:
|
||||
-theme orange
|
||||
-location 3
|
||||
-yoffset +45
|
||||
-xoffset -80
|
||||
-width 30
|
||||
"
|
||||
|
||||
function build_rofi_menu()
|
||||
{
|
||||
local menu
|
||||
local name
|
||||
local dtype
|
||||
local device
|
||||
local option
|
||||
|
||||
while read -r line
|
||||
do
|
||||
name="$(cut -d':' -f1 <<< $line)"
|
||||
dtype="$(cut -d':' -f2 <<< $line)"
|
||||
device="$(cut -d':' -f3 <<< $line)"
|
||||
|
||||
[[ -z $device ]] && status=DOWN || status=UP
|
||||
dtype=${dtype##*-}
|
||||
option="$name $dtype is $status"
|
||||
|
||||
option=$(printf '%-45s | %s | %s\n' "$name" $dtype $status)
|
||||
menu="$menu # $option"
|
||||
done < <(nmcli -c no --terse -f NAME,TYPE,DEVICE connection show)
|
||||
|
||||
echo "$(cut -c 3- <<< $menu)"
|
||||
}
|
||||
|
||||
function switch_connections()
|
||||
{
|
||||
local name="$1"
|
||||
local status=$2
|
||||
|
||||
if [[ "$status" == "UP" ]]; then
|
||||
nmcli connection down "$name"
|
||||
else
|
||||
nmcli connection up "$name"
|
||||
fi
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
local menu
|
||||
local choice
|
||||
local name
|
||||
local stat
|
||||
|
||||
menu=$(build_rofi_menu)
|
||||
choice=$($ROFI <<< $menu)
|
||||
[[ $? -ne 0 ]] && return 1
|
||||
|
||||
name=$(cut -d '|' -f 1 <<< $choice | awk '{$1=$1;print}')
|
||||
stat=$(cut -d '|' -f 3 <<< $choice | awk '{$1=$1;print}')
|
||||
|
||||
switch_connections "$name" $stat
|
||||
}
|
||||
|
||||
|
||||
main
|
||||
|
34
.config/polybar/scripts/spotify.py
Executable file
34
.config/polybar/scripts/spotify.py
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import dbus
|
||||
|
||||
bus_name = 'org.mpris.MediaPlayer2.spotify'
|
||||
|
||||
|
||||
def get_spotify_song():
|
||||
output = ''
|
||||
|
||||
try:
|
||||
session_bus = dbus.SessionBus()
|
||||
spotify_bus = session_bus.get_object(bus_name, '/org/mpris/MediaPlayer2')
|
||||
spotify_properties = dbus.Interface(spotify_bus, 'org.freedesktop.DBus.Properties')
|
||||
metadata = spotify_properties.Get("org.mpris.MediaPlayer2.Player", "Metadata")
|
||||
|
||||
artist = metadata['xesam:artist'][0]
|
||||
title = metadata['xesam:title']
|
||||
|
||||
window_title = artist + ' - ' + title
|
||||
output = "%{A1:$WM_CONTROL '" + window_title + "' &:}" + window_title + "%{A-}"
|
||||
except dbus.DBusException as e:
|
||||
if (e.get_dbus_message() == f'The name {bus_name} was not provided by any .service files'):
|
||||
pass
|
||||
else:
|
||||
output = e.get_dbus_message()
|
||||
except Exception as e:
|
||||
output = str(e)
|
||||
|
||||
print(output)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_spotify_song()
|
Reference in New Issue
Block a user