diff options
Diffstat (limited to '.config/polybar')
| -rw-r--r-- | .config/polybar/config | 816 | ||||
| -rwxr-xr-x | .config/polybar/launch.sh | 18 | ||||
| -rwxr-xr-x | .config/polybar/scripts/bluetooth.sh | 12 | ||||
| -rwxr-xr-x | .config/polybar/scripts/check-network.sh | 21 | ||||
| -rwxr-xr-x | .config/polybar/scripts/check_updates.sh | 118 | ||||
| -rwxr-xr-x | .config/polybar/scripts/cmus.sh | 39 | ||||
| -rwxr-xr-x | .config/polybar/scripts/get_spotify_status.sh | 52 | ||||
| -rwxr-xr-x | .config/polybar/scripts/menu.sh | 63 | ||||
| -rwxr-xr-x | .config/polybar/scripts/menu.shsave | 63 | ||||
| -rwxr-xr-x | .config/polybar/scripts/menu_full.sh | 65 | ||||
| -rwxr-xr-x | .config/polybar/scripts/now-playing.sh | 217 | ||||
| -rwxr-xr-x | .config/polybar/scripts/polybar_wrapper | 92 | ||||
| -rwxr-xr-x | .config/polybar/scripts/popup-calendar.sh | 41 | ||||
| -rwxr-xr-x | .config/polybar/scripts/rofi-power.sh | 45 | ||||
| -rwxr-xr-x | .config/polybar/scripts/scroll_spotify_status.sh | 12 | ||||
| -rwxr-xr-x | .config/polybar/scripts/sysmenu.sh | 40 | ||||
| -rwxr-xr-x | .config/polybar/scripts/sysmenu.shsave | 40 | ||||
| -rwxr-xr-x | .config/polybar/scripts/system-usb-mount.sh | 53 | ||||
| -rwxr-xr-x | .config/polybar/scripts/toggle_bluetooth.sh | 8 |
19 files changed, 1815 insertions, 0 deletions
diff --git a/.config/polybar/config b/.config/polybar/config new file mode 100644 index 0000000..6310991 --- /dev/null +++ b/.config/polybar/config @@ -0,0 +1,816 @@ +;========================================================== +; +; +; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗ +; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗ +; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝ +; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗ +; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║ +; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ +; +; +; To learn more about how to configure Polybar +; go to https://github.com/polybar/polybar +; +; The README contains a lot of information +; +;========================================================== + +[colors] +background = #aa000000 +;background = #aa101212 +;background = #00000000 +background-alt = #aaCECCC9 +;foreground = #aaCECCC9 +foreground = #fafafa +foreground-alt = #aaCECCC9 +primary = #aaCECCC9 +secondary = #aaCECCC9 +alert = #aaCECCC9 +non = #aaCECCC9 +;background = #aa000000 +blue = #61afef +dark_blue = #42A5F5 +nord = #81a1c1 +light_blue = #ADD8E6 +;green = #a0c980 +purple = #c882e7 +orange = #E57C46 +;orange = #d08770 +gray = #676E95 +red = #EC7875 +pink = #EC407A +yellow = #FDD835 +;yellow = #ECBE7B +amber = #FBC02D +indigo = #6C77BB +green = #61C766 +lime = #B9C244 +cyber = #53E2AE + +[bar/top] +;width = 100% +width = 99.15% +height = 24 +offset-x = 0.5% +offset-y = 0.5% +radius = 10.0 +;radius = 0 +fixed-center = true +bottom = false +enable-ipc = true +tray-position = right +tray-padding = 4 +tray-background = ${colors.background} +;tray-offest-x = -15 +;tray-offset-x = 400 +;tray-offset-x = -95 +;tray-offset-x = -208 +;tray-offset-x = -178 +;tray-offset-x = -183 +tray-offset-x = -188 +;tray-offset-x = -210 +tray-offset-y = -0.9 +tray-detached = true + +background = ${colors.background} +foreground = ${colors.foreground} + +line-size = 0 +line-color = ${colors.background-alt} + +;border-top-size = 1 +;border-bottom-size = 1 +;border-right-size = 1 +;border-left-size = 1 +;border-color = ${colors.foreground} +;border-size = 2 +;border-color = ${colors.background} + +padding-left = 0 +padding-right = 0 + +module-margin-left = 0 +module-margin-right = 0 +; Font for date +font-0 = "SF Pro Mono:style=Display Bold:size=10;2" +; Font for crypto, dunst +font-1 = "Material Design Icons:style=Bold:size=11.5;2" +; Font for menu +font-2 = "Material Design Icons:style=Bold:size=13.5;2" +; Font for controlCenter +font-3 = "SF Pro:style=Medium:size=10.5;2" +; Font for search +font-4 = "SF Pro:style=Medium:size=9.5;2" +; Font for bspwm/workspaces +font-5 = "UbuntuMono Nerd font:size=11;2" + +modules-left = sep menu sep close sep minimize sep maximize sep xwindow sep +modules-center = bspwm +modules-right = spotify spotify-prev spotify-play-pause spotify-next long-sep dunst search control date sep + +;modules-left = sep menu +;modules-center = date +;modules-right = bspwm whitespace crypto dunst search control space + +;modules-right = crypto dunst search date sep powermenu sep +;modules-right = crypto toggle_spotify volume backlight battery network notification powermenu + +wm-restack = bspwm +;wm-restack = bspwm + +override-redirect = true + +;; scroll-up = bspwm-desknext +;; scroll-down = bspwm-deskprev + +;scroll-up = i3wm-wsnext +;scroll-down = i3wm-wsprev + +cursor-click = pointer +cursor-scroll = ns-resize + +[module/menu] +type = custom/text +content = +content-font = 3 +content-padding = 1 +content-foreground = ${colors.foreground} +click-left = ~/.config/polybar/scripts/menu.sh +click-right = ~/.config/polybar/scripts/menu_full.sh + +[module/bspwm] +type = internal/bspwm +format = <label-state> +;format = <label-state> <label-mode> +format-padding = 0 +;format-padding-right = 2 +format-foreground = ${colors.foreground} +index-sort = true +enable-click = true +reverse-scroll = true +#reverse-scroll = false + +label-focused = +label-focused-padding = 2 + +label-occupied = +label-occupied-padding = 2 + +label-empty = +label-empty-padding = 2 + + +[module/sepp] +type = custom/text +content = " " + + +[module/close] +type = custom/text +content-foreground = ${colors.red} +content-padding = 1 +content = +click-left = "xdotool getwindowfocus windowkill" + +[module/minimize] +type = custom/text +content-foreground = ${colors.yellow} +content-padding = 1 +content = +click-left = bspc node -g hidden +click-right = ${HOME}/.config/bspwm/bspcmd unhide + +;label = +[module/maximize] +type = custom/text +content-foreground = ${colors.green} +content-padding = 1 +content = +;click-left = bspc node -t {fullscreen} +click-left = bspc node -t ~floating +click-right = bspc desktop -l next +#bspc node -t \~{fullscreen}; + +[module/blur-toggle] +type = custom/ipc +hook-0 = echo +hook-1 = echo +click-left = ~/.local/bin/scripts/blurtoggle.sh +initial = 1 +format-foreground = ${colors.foreground} + + +[module/battery] +type = internal/battery +full-t = 99 +time-format = %H:%M +battery = BAT1 +adapter = ACAD +format-padding = 1 +format-charging = <animation-charging> <label-charging> +format-charging-background = +label-charging = %percentage%% +format-discharging = <ramp-capacity> <label-discharging> +format-discharging-background = +label-discharging = %percentage%% +format-full = <label-full> +format-full-prefix = " " +format-full-prefix-foreground = ${colors.green} +;format-foreground = ${colors.green} +ramp-capacity-0 = +ramp-capacity-1 = +ramp-capacity-2 = +ramp-capacity-3 = +ramp-capacity-4 = +ramp-capacity-5 = +ramp-capacity-6 = +ramp-capacity-7 = +ramp-capacity-8 = +ramp-capacity-9 = + +ramp-capacity-0-foreground = ${colors.red} +ramp-capacity-1-foreground = ${colors.red} +ramp-capacity-foreground = ${colors.green} +;ramp-capacity-foreground = ${colors.foreground} +bar-capacity-width = 10 + +animation-charging-0 = +animation-charging-1 = +animation-charging-2 = +animation-charging-3 = +animation-charging-4 = +animation-charging-5 = +animation-charging-6 = +animation-charging-foreground = ${colors.green} + +animation-charging-framerate = 750 + +[module/xbacklight] +type = internal/xbacklight +enable-scroll = true + +[module/backlight] +inherit = module/xbacklight +type = internal/backlight +card = intel_backlight +format-backlight = <ramp-backlight> <label> +format-padding = 1 +format-prefix = " " +format-prefix-foreground = ${colors.indigo} +label = %percentage%% +label-foreground = ${colors.foreground} + +[module/bluetooth] +type = custom/script +exec = ~/.config/polybar/scripts/bluetooth.sh +tail = true +click-left = exec blueberry & +click-right = exec $HOME/.config/polybar/scripts/toggle_bluetooth.sh + +[module/network] +type = custom/script +exec = ~/.config/polybar/scripts/check-network.sh +format-background = +format-foreground = ${colors.light_blue} +click-left = networkmanager_dmenu & +click-right = nm-applet +tail = true +format-padding = 1 + + +;[module/date] +;type = internal/date +;interval = 30 +;label = %time% +;label-padding = 2 +;label-background = +;time = %H:%M +;time-alt = %Y-%m-%d + +[module/date] +type = internal/date +interval = 1 +label = %date%, %time% +label-padding = 2.5 +label-background = +date = %a %d %b +time = %H:%M + +;[module/powermenu] +;type = custom/text +;content = +;;content = 襤 +;content-foreground = ${colors.red} +;content-padding = 1 +;label-margin = 3 +;click-left = ~/.config/polybar/scripts/sysmenu.sh +;click-right = ~/.config/polybar/scripts/sysmenu.sh + +[module/control] +type = custom/text +content = +;content = 襤 +content-foreground = ${colors.foreground} +content-padding = 1 +label-margin = 10 +click-left = ~/.config/polybar/scripts/sysmenu.sh +click-right = ~/.config/polybar/scripts/sysmenu.sh + + +;[module/title] +;type = internal/xwindow +;; Available tags: +;; <label> (default) +;format = <label> +;format-background = ${colors.background} +;format-foreground = ${colors.foreground} +;format-padding = 1 +;label-maxlen = 10 +;label-empty = " " + + +;[module/bspwm] +;type = internal/bspwm +;format = <label-state> +;;format = <label-state> <label-mode> +;format-padding = 1 +;format-foreground = ${colors.foreground} +;index-sort = true +;enable-click = true +;reverse-scroll = true +;#reverse-scroll = false +; +;label-focused = +;label-focused-padding = 2 +; +;label-occupied = +;label-occupied-padding = 2 +; +;label-empty = +;label-empty-padding = 2 +; +;label-monocle = " " +;label-tiled = " " +;label-fullscreen = " " +;label-floating = " " +;label-pseudotiled = " " +;label-locked = " " +;;label-sticky = " " +;label-private = " " + +; Separator in between workspaces +;label-separator = | +;label-separator-padding = 10 +;label-separator-foreground = #ffb52a +[module/search] +type = custom/text +content = "" +; hack nerd +content-padding = 1 +content-font = 5 +;content-padding-right = 5 +content-foreground = ${colors.foreground} +click-left = rofi -show drun +;click-left = ~/.config/polybar/scripts/menu.sh + + + +[module/crypto] +type = custom/script +exec = echo +format = <label> +format-padding = 1 +label-padding = +content-background = +format-foreground = ${colors.foreground} +interval = 60 +click-left = cryptonotify +click-right = $TERMINAL -e cointop & + +[module/now-playing] +type = custom/script +tail = true +;format-prefix = "" +format = <label> +exec = ~/.config/polybar/scripts/now-playing.sh +click-right = "kill -USR1 $(pgrep --oldest --parent %pid%)" + + +[module/sep] +type = custom/text +content = " " + +[module/long-sep] +type = custom/text +content = " " + +[module/space] +type = custom/text +content = " " + +[module/whitespace] +type = custom/text +content = " " + +[module/xwindow] +type = internal/xwindow +label = %title:0:60:...% +format-foreground = ${colors.foreground} +format-padding = 6 + +[module/arch] +typ = custom/text +content = " " +format-foreground = ${colors.foreground} +format-padding = 4 + + + +[module/workspaces] +type = internal/xworkspaces +pin-workspaces = true +enable-click = true +enable-scroll = true +format-padding = 1 + +icon-default = + +format = <label-state> +format-background = ${colors.bg1} +label-active = " " +label-occupied = " " +label-urgent = " " +label-empty = " " + +label-empty-padding = 1 +label-active-padding = 1 +label-urgent-padding = 1 +label-occupied-padding = 1 + +label-empty-foreground = ${colors.foreground} +label-active-foreground = ${colors.acolor} +label-urgent-foreground = ${colors.curgent} +label-occupied-foreground = ${colors.foreground} + +[module/spotify] +type = custom/script +tail = true +interval = 1 +; prefix symbol is shown before the text +format-prefix = "" +format = <label> +exec = ~/.config/polybar/scripts/scroll_spotify_status.sh + +[module/spotify-prev] +type = custom/script +tail = true +interval = 1 +exec = echo " " +format = <label> +click-left = playerctl previous -p spotify + +[module/spotify-play-pause] +type = custom/ipc +tail = true +interval = 1 +hook-0 = echo "" +hook-1 = echo "" +initial = 1 +click-left = playerctl play-pause -p spotify + +[module/spotify-next] +type = custom/script +#type = custom/ipc +tail = true +interval = 1 +exec = echo " " +format = <label> +click-left = playerctl next -p spotify + +[module/toggle_spotify] +type = custom/text +content = " " +content-padding = 1 +content-foreground = ${colors.pink} +click-left = spotify +click-right = spotify + +[module/cmus] +type = custom/script + +exec = ~/.config/polybar/scripts/cmus.sh +exec-if = pgrep -x cmus +interval = 1 + +click-left = cmus-remote --next +click-right = cmus-remote --prev +click-middle = cmus-remote --pause +scroll-up = cmus-remote --volume +5% +scroll-down = cmus-remote --volume -5% + +label-font = 1 +format = <label> +format-underline = ${colors.foreground-alt} +label = %output% +label-maxlen = 50 + +[module/notification] +type = custom/text +content = +content-padding = 0 +content-foreground = ${colors.foreground-alt} +click-left = sh rofi_notif_center.sh +click-right = sh rofi_notif_center.sh + +[module/dunst] +type = custom/text +content-foreground = ${colors.foreground} +content-padding = 1 +content = +click-left = "dunstctl history-pop" + +[module/popup-calendar] +type = custom/script +exec = ~/.config/polybar/scripts/popup-calendar.sh +interval = 5 +click-left = ~/.config/polybar/scripts/popup-calendar.sh --popup & + +;[module/dunst] +;type = custom/ipc +;initial = 1 +;format-foreground = ${colors.foreground} +;hook-0 = echo "%{A1:notify-send dunstctl && polybar-msg hook dunst 2:}%{A}" & +;hook-1 = echo "%{A1:notify-send dunstctl && polybar-msg hook dunst 1:}%{A}" & + +[module/eww] +type = custom/text +content = +content-padding = 0 +content-foreground = #d8dee9 +click-left = sh toggle_eww.sh +click-right = sh toggle_eww.sh + +[module/pulseaudio] +type = internal/pulseaudio +ramp-volume-foreground = #8959a8 +format-volume-padding = 0 +format-volume-margin = 0 +format-volume = <ramp-volume> +use-ui-max = true +interval = 5 + +ramp-volume-0 = " " +ramp-volume-1 = " " +ramp-volume-2 = " " + + +label-muted = +label-muted-background = #3e999f +format-muted-foreground = #3e999f +format-muted-overline = #3e999f +format-muted-margin = 2 +format-muted-padding = 2 + +[module/volume] +type = internal/pulseaudio +format-volume = <ramp-volume> <label-volume> +format-volume-font = 10 +format-volume-padding = 0 +;ramp-volume-foreground = ${colors.foreground} +label-volume = %percentage%% +label-volume-padding = 0 +;label-muted-foreground = ${colors.foreground} +;format-volume-foreground = ${colors.purple} +format-muted-foreground = ${colors.red} +format-muted-underline = ${colors.red} +ramp-volume-foreground = ${colors.purple} +label-muted = "婢 " +ramp-volume-0 = "" +ramp-volume-1 = "" +ramp-volume-2 = "" +ramp-volume-3 = "" +ramp-volume-4 = "" +ramp-volume-5 = "" +ramp-volume-6 = "" + + +[module/xkeyboard] +type = internal/xkeyboard +blacklist-0 = num lock + +format-prefix = +format-foreground = ${colors.foreground-alt} +label-layout = " %layout%" + +label-indicator-foreground = ${colors.alert} +label-indicator-padding = 2 + +[module/filesystem] +type = internal/fs +interval = 25 + +mount-0 = / + +format-mounted = <label-mounted> +format-mounted-foreground = #b48ead +format-mounted-prefix = " " +label-mounted = " %free%" + +format-unmounted = <label-unmounted> +format-unmounted-prefix = +label-unmounted = %mountpoint%: not mounted + +[module/updates] +type = custom/script +exec = xbps-updates +format = <label> +interval = 4600 +label = %output% +label-padding = 2 +label-foreground = #81A1C1 + + +[module/cpu] +type = internal/cpu +interval = 2 +format-prefix = " " +format-prefix-foreground = #b48ead +label = %percentage:2%% + + +[module/memory] +type = internal/memory +interval = 2 +format-prefix = " " +format-prefix-foreground = #5e81ac +label = %percentage_used%% + +[module/globalmenu] +type = custom/script +exec = ~/.config/polybar/globalmenu.sh +format = <label> +label = %output% +;type = custom/ipc +;hook-0 = xfce4-panel | sed -e 's/^"//' -e 's/"$//' +;;exec = awk /usr/bin/xfce4-panel +;initial = 1 +;format-underline = ${colors.cyber} +;format-padding = 1 + +[module/global] +type = custom/script +exec = ~/.config/polybar/globaldmenu +label = %output% + +[settings] +screenchange-reload = true +;compositing-background = xor +;compositing-background = screen +;compositing-foreground = source +;compositing-border = over +;pseudo-transparency = false + +[global/wm] +margin-top = 0 +margin-bottom = 0 + +[module/options_open] +type = custom/text +content-foreground = ${colors.foreground} +content = "" +click-left = ~/.config/polybar/scripts/polybar_wrapper options + +[module/options_close] +type = custom/text +content-foreground = ${colors.primary} +content = "" +click-left = ~/.config/polybar/scripts/polybar_wrapper options + +;[bar/bottom] +;width = 8% +;height = 15 +;offset-x = 46% +;;offset-x = 35% +;;offset-x = 0.5% +;offset-y = 2.5% +;radius = 7.0 +;fixed-center = true +;bottom = false +;enable-ipc = true +;;tray-offset-x = 515 +;;tray-detached = true +; +;background = ${colors.background} +;foreground = ${colors.foreground} +; +;line-size = 0 +;line-color = ${colors.background-alt} +; +;;border-top-size = 1 +;;border-bottom-size = 1 +;;border-right-size = 1 +;;border-left-size = 1 +;;border-color = ${colors.foreground} +;;border-size = 2 +;;border-color = ${colors.background} +; +;padding-left = 0 +;padding-right = 0 +; +;module-margin-left = 0 +;module-margin-right = 0 +;; Font for date +;font-0 = "SF Pro Mono:style=Display Bold:size=10;2" +;; Font for bspwm/workspaces +;font-1 = "UbuntuMono Nerd font:size=10.5;2" +;; Font for crypto, dunst +;font-2 = "Material Design Icons:style=Bold:size=11;3" +;; Font for menu +;font-3 = "Material Design Icons:style=Bold:size=14;5" +;; Font for search and controlCenter +;font-4 = "SF Pro:style=Medium:size=10.5;3" +; +;modules-center = bspwm sepp +; +;;wm-restack = bspwm +; +;override-redirect = true +; +;;; scroll-up = bspwm-desknext +;;; scroll-down = bspwm-deskprev +; +;;scroll-up = i3wm-wsnext +;;scroll-down = i3wm-wsprev +; +;cursor-click = pointer +;cursor-scroll = ns-resize +; +; +;[bar/left] +;width = 5% +;height = 15 +;offset-x = 2.5% +;;offset-x = 35% +;;offset-x = 0.5% +;offset-y = 2.5% +;radius = 7.0 +;fixed-center = true +;bottom = false +;enable-ipc = true +;;tray-offset-x = 515 +;;tray-detached = true +; +;background = ${colors.background} +;foreground = ${colors.foreground} +; +;line-size = 0 +;line-color = ${colors.background-alt} +; +;;border-top-size = 1 +;;border-bottom-size = 1 +;;border-right-size = 1 +;;border-left-size = 1 +;;border-color = ${colors.foreground} +;;border-size = 2 +;;border-color = ${colors.background} +; +;padding-left = 0 +;padding-right = 0 +; +;module-margin-left = 0 +;module-margin-right = 0 +;; Font for date +;font-0 = "SF Pro Mono:style=Display Bold:size=10;2" +;; Font for bspwm/workspaces +;font-1 = "UbuntuMono Nerd font:size=11.5;2" +;; Font for crypto, dunst +;font-2 = "Material Design Icons:style=Bold:size=11;3" +;; Font for menu +;font-3 = "Material Design Icons:style=Bold:size=14;5" +;; Font for search and controlCenter +;font-4 = "SF Pro:style=Medium:size=10.5;3" +; +;modules-left = close blank minimize blank maximize blank +; +;;wm-restack = bspwm +; +;override-redirect = true +; +;;; scroll-up = bspwm-desknext +;;; scroll-down = bspwm-deskprev +; +;;scroll-up = i3wm-wsnext +;;scroll-down = i3wm-wsprev +; +;cursor-click = pointer +;cursor-scroll = ns-resize +; +;;[module/decorations] +;;type = custom/text +; +;[module/blank] +;type = custom/text +;content = " " + +; vim:ft=dosini diff --git a/.config/polybar/launch.sh b/.config/polybar/launch.sh new file mode 100755 index 0000000..1c0ac10 --- /dev/null +++ b/.config/polybar/launch.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env sh + +# 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 bar +polybar top & +#polybar bottom & +#polybar left & +#polybar top_external & + +#sleep 5 && xdo raise -N "polybar-bottom_LVDS-1" & +if [[ $(xrandr -q | grep 'HDMI-1 connected') ]]: then + polybar top_external & +fi diff --git a/.config/polybar/scripts/bluetooth.sh b/.config/polybar/scripts/bluetooth.sh new file mode 100755 index 0000000..061604b --- /dev/null +++ b/.config/polybar/scripts/bluetooth.sh @@ -0,0 +1,12 @@ +#!/bin/sh +if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ] +then + echo "" +else + if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ] + then + echo "" + fi + echo "" +fi + diff --git a/.config/polybar/scripts/check-network.sh b/.config/polybar/scripts/check-network.sh new file mode 100755 index 0000000..dabe74c --- /dev/null +++ b/.config/polybar/scripts/check-network.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +count=0 +disconnected="睊" +wireless_connected="直" +ethernet_connected="泌" + +ID="$(ip link | awk '/state UP/ {print $2}')" + +while true; do + if (ping -c 1 archlinux.org || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) &>/dev/null; then + if [[ $ID == e* ]]; then + echo "$ethernet_connected" ; sleep 25 + else + echo "$wireless_connected" ; sleep 25 + fi + else + echo "$disconnected" ; sleep 0.5 + fi +done + diff --git a/.config/polybar/scripts/check_updates.sh b/.config/polybar/scripts/check_updates.sh new file mode 100755 index 0000000..52e51a9 --- /dev/null +++ b/.config/polybar/scripts/check_updates.sh @@ -0,0 +1,118 @@ + +#!/usr/bin/bash +# +# checkupdates: Safely print a list of pending updates. +# +# Copyright (c) 2013 Kyle Keen <keenerd@gmail.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +declare -r myname='checkupdates' +declare -r myver='1.0.0' + +plain() { + (( QUIET )) && return + local mesg=$1; shift + printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 +} + +msg() { + (( QUIET )) && return + local mesg=$1; shift + printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 +} + +msg2() { + (( QUIET )) && return + local mesg=$1; shift + printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 +} + +ask() { + local mesg=$1; shift + printf "${BLUE}::${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}" "$@" >&1 +} + +warning() { + local mesg=$1; shift + printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +error() { + local mesg=$1; shift + printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +# check if messages are to be printed using color +unset ALL_OFF BOLD BLUE GREEN RED YELLOW +if [[ -t 2 && ! $USE_COLOR = "n" ]]; then + # prefer terminal safe colored and bold text when tput is supported + if tput setaf 0 &>/dev/null; then + ALL_OFF="$(tput sgr0)" + BOLD="$(tput bold)" + BLUE="${BOLD}$(tput setaf 4)" + GREEN="${BOLD}$(tput setaf 2)" + RED="${BOLD}$(tput setaf 1)" + YELLOW="${BOLD}$(tput setaf 3)" + else + ALL_OFF="\e[1;0m" + BOLD="\e[1;1m" + BLUE="${BOLD}\e[1;34m" + GREEN="${BOLD}\e[1;32m" + RED="${BOLD}\e[1;31m" + YELLOW="${BOLD}\e[1;33m" + fi +fi +readonly ALL_OFF BOLD BLUE GREEN RED YELLOW + + +if (( $# > 0 )); then + echo "${myname} v${myver}" + echo + echo "Safely print a list of pending updates" + echo + echo "Usage: ${myname}" + echo + echo 'Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary database.' + exit 0 +fi + +if ! type -P fakeroot >/dev/null; then + error 'Cannot find the fakeroot binary.' + exit 1 +fi + +if [[ -z $CHECKUPDATES_DB ]]; then + CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/" +fi + +trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT + +DBPath="$(pacman-conf DBPath)" +if [[ -z "$DBPath" ]] || [[ ! -d "$DBPath" ]]; then + DBPath="/var/lib/pacman/" +fi + +mkdir -p "$CHECKUPDATES_DB" +ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null +if ! fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null; then + error 'Cannot fetch updates' + exit 1 +fi +pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]' + +exit 0 + +# vim: set noet: diff --git a/.config/polybar/scripts/cmus.sh b/.config/polybar/scripts/cmus.sh new file mode 100755 index 0000000..2f42c63 --- /dev/null +++ b/.config/polybar/scripts/cmus.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +prepend_zero () { + seq -f "%02g" $1 $1 +} + +artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-)) + +if [[ $artist = *[!\ ]* ]]; then + song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-)) + position=$(cmus-remote -C status | grep position | cut -c 10-) + minutes1=$(prepend_zero $(($position / 60))) + seconds1=$(prepend_zero $(($position % 60))) + duration=$(cmus-remote -C status | grep duration | cut -c 10-) + minutes2=$(prepend_zero $(($duration / 60))) + seconds2=$(prepend_zero $(($duration % 60))) + echo -n "$artist - $song " +else + echo +fi + +#prepend_zero () { +# seq -f "%02g" $1 $1 +#} +# +#artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-)) +# +#if [[ $artist = *[!\ ]* ]]; then +# song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-)) +# position=$(cmus-remote -C status | grep position | cut -c 10-) +# minutes1=$(prepend_zero $(($position / 60))) +# seconds1=$(prepend_zero $(($position % 60))) +# duration=$(cmus-remote -C status | grep duration | cut -c 10-) +# minutes2=$(prepend_zero $(($duration / 60))) +# seconds2=$(prepend_zero $(($duration % 60))) +# echo -n "$artist - $song [$minutes1:$seconds1/$minutes2:$seconds2]" +#else +# echo +#fi diff --git a/.config/polybar/scripts/get_spotify_status.sh b/.config/polybar/scripts/get_spotify_status.sh new file mode 100755 index 0000000..f04400d --- /dev/null +++ b/.config/polybar/scripts/get_spotify_status.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# The name of polybar bar which houses the main spotify module and the control modules. +PARENT_BAR="now-playing" +PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1) + +# Set the source audio player here. +# Players supporting the MPRIS spec are supported. +# Examples: spotify, vlc, chrome, mpv and others. +# Use `playerctld` to always detect the latest player. +# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control +#PLAYER="spotify" +PLAYER="playerctld" + +# Format of the information displayed +# Eg. {{ artist }} - {{ album }} - {{ title }} +# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata +FORMAT="{{ title }} - {{ artist }}" + +# Sends $2 as message to all polybar PIDs that are part of $1 +update_hooks() { + while IFS= read -r id + do + polybar-msg -p "$id" hook spotify-play-pause $2 1>/dev/null 2>&1 + done < <(echo "$1") +} + +PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null) +EXIT_CODE=$? + +if [ $EXIT_CODE -eq 0 ]; then + STATUS=$PLAYERCTL_STATUS +else + STATUS="No player is running" +fi + +if [ "$1" == "--status" ]; then + echo "$STATUS" +else + if [ "$STATUS" = "Stopped" ]; then + echo "No music is playing" + elif [ "$STATUS" = "Paused" ]; then + update_hooks "$PARENT_BAR_PID" 2 + playerctl --player=$PLAYER metadata --format "$FORMAT" + elif [ "$STATUS" = "No player is running" ]; then + echo "" + else + update_hooks "$PARENT_BAR_PID" 1 + playerctl --player=$PLAYER metadata --format "$FORMAT" + fi +fi + diff --git a/.config/polybar/scripts/menu.sh b/.config/polybar/scripts/menu.sh new file mode 100755 index 0000000..93f3779 --- /dev/null +++ b/.config/polybar/scripts/menu.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#FF6F00" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true \ +-hide-sidebar-mode true \ +-bw 0 \ +-lines 15 \ +-line-padding 10 \ +-padding 0 \ +-width 20 \ +-xoffset 7 -yoffset 28 \ +-location 1 \ +-columns 1 \ +-show-icons -icon-theme "Papirus" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" +#rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true -sidebar-mode false -bw 0 -lines 6 -line-padding 10 -padding 20 -width 30 -xoffset 7 -yoffset 25 -location 1 -columns 2 -show-icons -icon-theme "Papirus" + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground + diff --git a/.config/polybar/scripts/menu.shsave b/.config/polybar/scripts/menu.shsave new file mode 100755 index 0000000..ea5bf8e --- /dev/null +++ b/.config/polybar/scripts/menu.shsave @@ -0,0 +1,63 @@ +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#FF6F00" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar false \ +-hide-sidebar-mode true \ +-bw 0 \ +-lines 15 \ +-line-padding 10 \ +-padding 0 \ +-width 20 \ +-xoffset 7 -yoffset 28 \ +-location 1 \ +-columns 1 \ +-show-icons -icon-theme "Papirus" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" +#rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true -sidebar-mode false -bw 0 -lines 6 -line-padding 10 -padding 20 -width 30 -xoffset 7 -yoffset 25 -location 1 -columns 2 -show-icons -icon-theme "Papirus" + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground + diff --git a/.config/polybar/scripts/menu_full.sh b/.config/polybar/scripts/menu_full.sh new file mode 100755 index 0000000..9f898a4 --- /dev/null +++ b/.config/polybar/scripts/menu_full.sh @@ -0,0 +1,65 @@ + +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#FF6F00" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +rofi -no-lazy-grab -show drun \ +-display-drun "Applications " -drun-display-format "{name}" \ +-hide-scrollbar true \ +-bw 0 \ +-lines 10 \ +-line-padding 15 \ +-padding 60 \ +-width 30 \ +-xoffset 10 -yoffset 40 \ +-location 1 \ +-fullscreen \ +-columns 4 \ +-show-icons -icon-theme "Papirus" \ +-font "Fantasque Sans Mono 10" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground diff --git a/.config/polybar/scripts/now-playing.sh b/.config/polybar/scripts/now-playing.sh new file mode 100755 index 0000000..8fa6000 --- /dev/null +++ b/.config/polybar/scripts/now-playing.sh @@ -0,0 +1,217 @@ +#!/usr/bin/env python3 +import dbus +import signal +import time +from unicodedata import east_asian_width + +# Config options + +# (int) : Length of media info string. If length of string exceedes this value, the text will scroll. Default value is 20 +message_display_len = 20 + +# (int) : Font index of polybar. this value should be 1 more than the font value specified in polybar config. +font_index = 1 + +# (float) : Update speed of the text in seconds. +update_delay = 0.3 + +# (list) : list of chars containing previous, play, pause, next glyphs for media controls in respective order +control_chars = ['','','',''] + +# (dict) : dict of char icons to display as prefix. +# If player name is available as key, then use the corressponding icon, +# else default key value. +# example: +display_player_prefix = { + "spotify": ' ', + "firefox": ' ', + "default": ' ' +} + +# (list) : list of metadata fields based on mpris sepecification. +# For more details/ field names, refer [mpris sepecification](https://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata/) +metadata_fields = ["xesam:title", "xesam:artist"] + +# (char) : separator for metadata fields +metadata_separator = "-" + +# (bool) : Hide text when no player is available? True disables the output for no players. +hide_output = False + +# Defult initialization +current_player = None +player_names = None +players = None +message = None +display_text = "" +display_prefix = " " +display_suffix = "" +last_player_name = None + +session_bus = dbus.SessionBus() + +def get_name(player_name ): + if player_name not in player_names: + return + name = ".".join(player_name.split(".")[3:]) + return name + +def get_name_by_index(index): + if index >= len(player_names): + return + return get_name(player_names[index]) + +def get_status(player): + status = "" + try: + status = player.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus', dbus_interface='org.freedesktop.DBus.Properties') + except Exception as e: + pass + return status + +def get_metadata(player): + metadata = {} + try: + metadata = player.Get('org.mpris.MediaPlayer2.Player', 'Metadata', dbus_interface='org.freedesktop.DBus.Properties') + except Exception as e: + pass + return metadata + +def update_prefix_suffix(player_name="", status=""): + global display_prefix, display_suffix, status_paused + + player_option = "" + if player_name != "": + player_option = "-p " + player_name + + prev_button = "%%{A:playerctl %s previous :}%c%%{A}" %(player_option,control_chars[0]) + play_button = "%%{A:playerctl %s play :}%c%%{A}" %(player_option,control_chars[1]) + pause_button = "%%{A:playerctl %s pause :}%c%%{A}" %(player_option,control_chars[2]) + next_button = "%%{A:playerctl %s next :}%c%%{A}" %(player_option,control_chars[3]) + + suffix = "| " + prev_button + if status == "Playing": + suffix += " "+pause_button + status_paused = False + else: + suffix += " "+play_button + status_paused = True + suffix += " "+next_button + # print(suffix) + display_suffix = suffix + + for key in display_player_prefix.keys(): + if key in player_name: + display_prefix = display_player_prefix[key] + break + else: + display_prefix = display_player_prefix["default"] + +def update_players(): + global player_names, players, session_bus, current_player, last_player_name + player_names = [service for service in session_bus.list_names() if service.startswith('org.mpris.MediaPlayer2.')] + players = [session_bus.get_object(service, '/org/mpris/MediaPlayer2') for service in player_names] + if last_player_name != get_name(current_player): + for index, player in enumerate(player_names): + if get_name(player) == last_player_name: + current_player = index + +def handle_event(*args): + global current_player, players, last_player_name + update_players() + if len(players) == 0: + return + current_player += 1 + current_player %= len(players) + last_player_name = getname_by_index(current_player) +# print("SIGUSR1: updated values - current_player = %d players len = %d"%(current_player,len(players))) + +def update_message(): + global players, current_player,player_names, message, display_text, message_display_len, display_suffix, last_player_name + if len(players) == 0: + tmp_message = "No player available" + update_prefix_suffix() + else: + name = get_name_by_index(current_player) + status = get_status(players[current_player]) + metadata_obj = get_metadata(players[current_player]) + metadata_string_list = [] + for field in metadata_fields: + result = metadata_obj.get(field) + if type(result) == dbus.Array: + result = result[0] + if not result: + result = "No "+field.split(":")[1] + metadata_string_list.append(str(result)) + metadata_string = (" "+metadata_separator+" ").join(metadata_string_list) + if visual_len(metadata_string) > message_display_len: + metadata_string = " " + metadata_string + " |" + update_prefix_suffix(name,status) + tmp_message = "" + if metadata_string: + tmp_message += str(metadata_string) + last_player_name = name + if message != tmp_message: + message = tmp_message + display_text = message + +def scroll(): + global display_text, message_display_len, status_paused + if not status_paused: + if len(display_text) > message_display_len: + display_text = display_text[1:] + display_text[0] + elif len(display_text) < message_display_len: + display_text += " "*(message_display_len - len(display_text)) + +def visual_len(text): + visual_length = 0 + for ch in text: + width = east_asian_width(ch) + if width == 'W' or width == 'F': + visual_length += 1 + visual_length += 1 + return visual_length + +def make_visual_len(text, visual_desired_length): + visual_length = 0 + altered_text = '' + for char in text: + if visual_length < visual_desired_length: + width = east_asian_width(char) + if width == 'W' or width == 'F': + visual_length += 2 + else: + visual_length += 1 + altered_text += char + else: + break + if visual_length == visual_desired_length + 1: + altered_text = altered_text[:-1] + ' ' + elif visual_length < visual_desired_length: + altered_text += ' ' * (visual_desired_length - visual_length) + return altered_text + +def print_text(): + global display_text, message_display_len, players, player_names, display_prefix, display_suffix + if hide_output and len(players)==0: + print("", flush = True) + return + scroll() + print(display_prefix + " " + + "%%{T%d}" % (font_index) + + make_visual_len(display_text, message_display_len) + + "%{T-}" + display_suffix, flush=True) + +def main(): + global current_player, players + update_players() + current_player = 0 + while True: + time.sleep(update_delay) + update_players() + update_message() + print_text() + +if __name__ == '__main__': + signal.signal(signal.SIGUSR1, handle_event) + main() diff --git a/.config/polybar/scripts/polybar_wrapper b/.config/polybar/scripts/polybar_wrapper new file mode 100755 index 0000000..901bb28 --- /dev/null +++ b/.config/polybar/scripts/polybar_wrapper @@ -0,0 +1,92 @@ +#!/bin/bash + +DIR=$(dirname $(realpath $0)) + +WINDOW_ID_CONKY=/tmp/conky_window_id +WINDOW_ID_TOP=/tmp/polybar_top_window_id +WINDOW_ID_EXPANDED=/tmp/polybar_expanded_window_id + +conky_launch() { + # Hacky X11 magic to make Conky appear above polybar + killall conky + # xdotool search can't find Conky's window but fortunately Conky outputs it + conky -c ~/.config/conky/config 2> /tmp/conky_out + # Extract the hex window id from Conky's output + HEX=$(awk '/drawing to created window/ {print $NF}' /tmp/conky_out | tr -d '()' | awk -Fx '{print $2}') + WIN_ID=$(( 16#$HEX )) # convert to decimal + xdotool windowunmap $WIN_ID + echo $WIN_ID > $WINDOW_ID_CONKY +} + +polybar_launch() { + killall polybar + + polybar top & + xdotool search --sync --pid $! > $WINDOW_ID_TOP + + polybar expanded & + xdotool search --sync --pid $! > $WINDOW_ID_EXPANDED + + bar_collapse +} + +launch() { + # Temporarily disable conky until I update the config + # conky_launch + # sleep 0.2 + polybar_launch +} + +bar_expand() { + xdotool windowmap $(cat $WINDOW_ID_EXPANDED) + xdotool windowunmap $(cat $WINDOW_ID_TOP) +} + +bar_collapse() { + xdotool windowunmap $(cat $WINDOW_ID_EXPANDED) + xdotool windowmap $(cat $WINDOW_ID_TOP) +} + +rofi_open() { + options_close + bar_expand & + rofi -modi run -show run + bar_collapse +} + +drun_open() { + bar_expand & + rofi -theme drun -modi drun -show drun -drun-categories Custom + bar_collapse +} + +search_open() { + options_close + bar_expand & + rofi -theme window -modi window -show window + bar_collapse +} + +options_open() { + bar_expand + $DIR/rofi_option_menu + bar_collapse + # echo "open" > /tmp/polybar_side_panel_state + # ID_CONKY=$(cat $WINDOW_ID_CONKY) + # xdotool windowmap $ID_CONKY + # xdotool windowraise $ID_CONKY + # ~/.config/i3/scripts/music_player show_applet +} + +case "$1" in + rofi) + rofi_open;; + search) + search_open;; + drun) + drun_open;; + options) + options_open;; + launch) + launch;; +esac diff --git a/.config/polybar/scripts/popup-calendar.sh b/.config/polybar/scripts/popup-calendar.sh new file mode 100755 index 0000000..4e5303c --- /dev/null +++ b/.config/polybar/scripts/popup-calendar.sh @@ -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 %b, %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 diff --git a/.config/polybar/scripts/rofi-power.sh b/.config/polybar/scripts/rofi-power.sh new file mode 100755 index 0000000..87ac92c --- /dev/null +++ b/.config/polybar/scripts/rofi-power.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env sh +# +# A rofi powered menu to execute power related action. +# Uses: amixer mpc poweroff reboot rofi rofi-prompt + +power_off='' +reboot='' +lock='' +suspend='鈴' +log_out='' + +chosen=$(printf '%s;%s;%s;%s;%s\n' "$power_off" "$reboot" "$lock" "$suspend" \ + "$log_out" \ + | rofi -theme '~/.config/rofi/themes/power.rasi' \ + -dmenu \ + -sep ';' \ + -selected-row 2) + +case "$chosen" in + "$power_off") + rofi-prompt --query 'Shutdown?' && poweroff + ;; + + "$reboot") + rofi-prompt --query 'Reboot?' && reboot + ;; + + "$lock") + # TODO Add your lockscreen command. + ;; + + "$suspend") + # Pause music and mute volume before suspending. + mpc --quiet pause + amixer set Master mute + # TODO Add your suspend command. + ;; + + "$log_out") + # TODO Add your log out command. + ;; + + *) exit 1 ;; +esac + diff --git a/.config/polybar/scripts/scroll_spotify_status.sh b/.config/polybar/scripts/scroll_spotify_status.sh new file mode 100755 index 0000000..74e0bfd --- /dev/null +++ b/.config/polybar/scripts/scroll_spotify_status.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# see man zscroll for documentation of the following parameters +zscroll -l 20 \ + --delay 0.1 \ + --scroll-padding " " \ + --match-command "$HOME/.config/polybar/scripts/get_spotify_status.sh --status" \ + --match-text "Playing" "--scroll 1" \ + --match-text "Paused" "--scroll 0" \ + --update-check true "$HOME/.config/polybar/scripts/get_spotify_status.sh" & + +wait diff --git a/.config/polybar/scripts/sysmenu.sh b/.config/polybar/scripts/sysmenu.sh new file mode 100755 index 0000000..721bc1d --- /dev/null +++ b/.config/polybar/scripts/sysmenu.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# display a power menu to: shutdown, reboot, +# lock, logout, and suspend. This script can be +# executed by clicking on the polybar powermenu module +# or with a keyboard shortcut + + +# options to be displayed +shutdown=" Shutdown" +reboot=" Reboot" +lock=" Lock" +logout=" Logout" +suspend=" Suspend" + +uptime=$(uptime -p | sed -e 's/up //g') + +# options passed into variable +options="$shutdown\n$reboot\n$lock\n$logout\n$suspend" + +chosen="$(echo -e "$options" | rofi -no-lazy-grab -sep -lines 5 -hide-scrollbar true -border 0 -padding 0 -height 2px -width 15 -xoffset -8 -yoffset 28 -location 3 -columns 1 -dmenu -p 'System ' "$uptime")" + +case $chosen in +$shutdown) + systemctl poweroff + ;; +$reboot) + systemctl reboot + ;; +$lock) + betterlockscreen --lock dimblur + ;; +$logout) + bspc quit + ;; +$suspend) + systemctl suspend + ;; +esac + diff --git a/.config/polybar/scripts/sysmenu.shsave b/.config/polybar/scripts/sysmenu.shsave new file mode 100755 index 0000000..00ce125 --- /dev/null +++ b/.config/polybar/scripts/sysmenu.shsave @@ -0,0 +1,40 @@ +#!/bin/bash + +# display a power menu to: shutdown, reboot, +# lock, logout, and suspend. This script can be +# executed by clicking on the polybar powermenu module +# or with a keyboard shortcut + + +# options to be displayed +shutdown=" Shutdown" +reboot=" Reboot" +lock=" Lock" +logout=" Logout" +suspend=" Suspend" + +uptime=$(uptime -p | sed -e 's/up //g') + +# options passed into variable +options="$shutdown\n$reboot\n$lock\n$logout\n$suspend" + +chosen="$(echo -e "$options" | rofi -no-lazy-grab -sep -lines 5 -hide-scrollbar true -border 0 -padding 0 -height 2px -width 15 -xoffset -10 -yoffset 28 -location 3 -columns 1 -dmenu -p 'System ' "$uptime")" + +case $chosen in +$shutdown) + systemctl poweroff + ;; +$reboot) + systemctl reboot + ;; +$lock) + betterlockscreen --lock dimblur + ;; +$logout) + bspc quit + ;; +$suspend) + systemctl suspend + ;; +esac + diff --git a/.config/polybar/scripts/system-usb-mount.sh b/.config/polybar/scripts/system-usb-mount.sh new file mode 100755 index 0000000..63e9187 --- /dev/null +++ b/.config/polybar/scripts/system-usb-mount.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +devices=$(lsblk -Jplno NAME,TYPE,RM,SIZE,MOUNTPOINT,VENDOR) + +case "$1" in + --mount) + for mount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do + udisksctl mount --no-user-interaction -b "$mount" + + mountpoint=$(udisksctl mount --no-user-interaction -b $mount) + mountpoint=$(echo $mountpoint | cut -d " " -f 4- | tr -d ".") + kitty -e "bash -lc 'pcmanfm $mountpoint'" & + done + ;; + --unmount) + for unmount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .name'); do + udisksctl unmount --no-user-interaction -b "$unmount" + udisksctl power-off --no-user-interaction -b "$unmount" + done + ;; + *) + output="" + counter=0 + + for unmounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do + unmounted=$(echo "$unmounted" | tr -d "[:digit:]") + unmounted=$(echo "$devices" | jq -r '.blockdevices[] | select(.name == "'"$unmounted"'") | .vendor') + unmounted=$(echo "$unmounted" | tr -d ' ') + + if [ $counter -eq 0 ]; then + space="" + else + space=" " + fi + counter=$((counter + 1)) + + output="$output$space#1 $unmounted" + done + + for mounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .size'); do + if [ $counter -eq 0 ]; then + space="" + else + space=" " + fi + counter=$((counter + 1)) + + output="$output$space#2 $mounted" + done + + echo "$output" + ;; +esac diff --git a/.config/polybar/scripts/toggle_bluetooth.sh b/.config/polybar/scripts/toggle_bluetooth.sh new file mode 100755 index 0000000..899d5ec --- /dev/null +++ b/.config/polybar/scripts/toggle_bluetooth.sh @@ -0,0 +1,8 @@ +#!/bin/sh +if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ] +then + bluetoothctl power on +else + bluetoothctl power off +fi + |
