From 3ec0ca06dda68e57925cf29c2f843e774ea7a58f Mon Sep 17 00:00:00 2001 From: Katie Date: Fri, 24 Jun 2022 06:40:51 -0500 Subject: [PATCH] Added preliminary support for OG PinePhone, made battery-combined-shell.sh show nothing if battery is missing, added a new bar for vertical mode, added custom hook to swap between those bars, and some other things I'm probably forgetting. --- .config/polybar/batt/ip5xxx_battery.sh | 4 + .../batt/ip5xxx_charge_now_compat.service | 11 ++ .config/polybar/batt/rk818_battery.sh | 4 + .../batt/rk818_charge_now_compat.service | 11 ++ .config/polybar/config.ini | 67 ++++++++- .config/polybar/launch.sh | 15 +- .../polybar/scripts/battery-combined-shell.sh | 28 ++-- .config/polybar/scripts/bspwmslim.sh | 5 + .config/sxhkd/sxhkdrc.save | 140 ++++++++++++++++++ bin/bspwm-session.sh | 9 +- bin/sxmo-bspwm-xinit.sh | 1 + 11 files changed, 268 insertions(+), 27 deletions(-) create mode 100755 .config/polybar/batt/ip5xxx_battery.sh create mode 100644 .config/polybar/batt/ip5xxx_charge_now_compat.service create mode 100755 .config/polybar/batt/rk818_battery.sh create mode 100644 .config/polybar/batt/rk818_charge_now_compat.service create mode 100755 .config/polybar/scripts/bspwmslim.sh create mode 100644 .config/sxhkd/sxhkdrc.save diff --git a/.config/polybar/batt/ip5xxx_battery.sh b/.config/polybar/batt/ip5xxx_battery.sh new file mode 100755 index 0000000..62db9bf --- /dev/null +++ b/.config/polybar/batt/ip5xxx_battery.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +PERCENTAGESTR=$(upower -i /org/freedesktop/UPower/devices/battery_ip5xxx_battery | grep percentage) +echo "${PERCENTAGESTR//[!0-9]/}" > /home/katie/.config/polybar/batt/ip5xxx-battery/ diff --git a/.config/polybar/batt/ip5xxx_charge_now_compat.service b/.config/polybar/batt/ip5xxx_charge_now_compat.service new file mode 100644 index 0000000..b47cdca --- /dev/null +++ b/.config/polybar/batt/ip5xxx_charge_now_compat.service @@ -0,0 +1,11 @@ +[Unit] +Description=ip5xxx Battery charge_now Compatability Service + +[Service] +User=root +ExecStart=ip5xxx_battery.sh +Restart=always +StartLimitBurst=1000000 + +[Install] +WantedBy=multi-user.target diff --git a/.config/polybar/batt/rk818_battery.sh b/.config/polybar/batt/rk818_battery.sh new file mode 100755 index 0000000..b20e397 --- /dev/null +++ b/.config/polybar/batt/rk818_battery.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +PERCENTAGESTR=$(upower -i /org/freedesktop/UPower/devices/battery_rk818_battery | grep percentage) +echo "${PERCENTAGESTR//[!0-9]/}" > /home/katie/.config/polybar/batt/rk818-battery/ diff --git a/.config/polybar/batt/rk818_charge_now_compat.service b/.config/polybar/batt/rk818_charge_now_compat.service new file mode 100644 index 0000000..36f064b --- /dev/null +++ b/.config/polybar/batt/rk818_charge_now_compat.service @@ -0,0 +1,11 @@ +[Unit] +Description=RK818 Battery charge_now Compatability Service + +[Service] +User=root +ExecStart=rk818_battery.sh +Restart=always +StartLimitBurst=1000000 + +[Install] +WantedBy=multi-user.target diff --git a/.config/polybar/config.ini b/.config/polybar/config.ini index b664571..4b62a9e 100644 --- a/.config/polybar/config.ini +++ b/.config/polybar/config.ini @@ -42,7 +42,7 @@ alter1 = #ffffff ;alter2 = ${xrdb:color3} alter2 = #ffffff -[bar/bar1] +[bar/barhorizontal] monitor = ${env:MONITOR:DSI-1} width = 99% height = 27 @@ -97,28 +97,85 @@ wm-restack = bspwm cursor-click = pointer cursor-scroll = ns-resize +[bar/barvertical] +monitor = ${env:MONITOR:DSI-1} +width = 99% +height = 27 +offset-x = 0.5% +;offset-y = 0.5% +radius = 0 +fixed-center = true + +background = ${colors.background} +foreground = ${colors.foreground} + +line-size = 3 +line-color = #f00 + +border-size = 0 +border-color = #00000000 + +padding-left = 2 +padding-right = 0 + +module-margin-left = 1 +module-margin-right = 1 + +font-0 = cherry-11-r;2 +font-1 = Wuncon Siji:pixelsize=12;2 +font-2 = Weather Icons:size=12;4 +font-3 = Monoid Nerd Font Mono:size=12;2 +font-4 = SauceCodePro Nerd Font:size=18:antialias=false;4 +font-5 = Material Icons:size=10;2 +font-6 = unifont:fontformat=truetype:size=8:antialias=false;0 + + +modules-left = bspwmslim +modules-center = xwindow +modules-right = wlan combobatt date sxmo powermenu + +tray-position = right +tray-padding = 2 +;tray-background = #0063ff + +wm-restack = bspwm +;wm-restack = i3 + +;override-redirect = true + +;scroll-up = bspwm-desknext +;scroll-down = bspwm-deskprev + +cursor-click = pointer +cursor-scroll = ns-resize + [module/bspwm] type = internal/bspwm label-focused = %name% label-focused-background = ${colors.background} -label-focused-padding = 2 +label-focused-padding = 1 label-focused-underline = ${colors.alter2} label-occupied = %name% -label-occupied-padding = 2 +label-occupied-padding = 1 label-urgent = %name%! label-urgent-background = ${colors.alert} -label-urgent-padding = 2 +label-urgent-padding = 1 label-empty = %name% label-empty-foreground = ${colors.foreground-alt} -label-empty-padding = 2 +label-empty-padding = 1 ; Separator in between workspaces label-separator = | +[module/bspwmslim] +type = custom/script +exec = ~/.config/polybar/scripts/bspwmslim.sh +interval = 1 + [module/cpu] type = internal/cpu interval = 2 diff --git a/.config/polybar/launch.sh b/.config/polybar/launch.sh index 53e608b..c7c96c6 100755 --- a/.config/polybar/launch.sh +++ b/.config/polybar/launch.sh @@ -4,11 +4,16 @@ # If all your bars have ipc enabled, you can use polybar-msg cmd quit # Otherwise you can use the nuclear option: -# killall -q polybar +killall -q polybar + + -# Launch bar1 and bar2 echo "---" | tee -a /tmp/polybar1.log /tmp/polybar2.log -polybar bar1 2>&1 | tee -a /tmp/polybar1.log & disown -#polybar bar2 2>&1 | tee -a /tmp/polybar2.log & disown -echo "Bars launched..." +if [[ "$1" == "normal" ]] || [[ "$1" == "inverted" ]]; then + polybar barvertical 2>&1 | tee -a /tmp/polybar2.log & disown +else + polybar barhorizontal 2>&1 | tee -a /tmp/polybar1.log & disown +fi + +echo "Bar launched..." diff --git a/.config/polybar/scripts/battery-combined-shell.sh b/.config/polybar/scripts/battery-combined-shell.sh index 01791c2..c98d54f 100755 --- a/.config/polybar/scripts/battery-combined-shell.sh +++ b/.config/polybar/scripts/battery-combined-shell.sh @@ -1,8 +1,10 @@ #!/bin/sh PATH_AC_0="/sys/class/power_supply/rk818-battery" +BACKUP_PATH_AC_0="/sys/class/power_supply/axp20x-battery" PATH_AC_1="/sys/class/power_supply/ip5xxx-battery" PATH_BATTERY_0="/sys/class/power_supply/rk818-battery" +BACKUP_PATH_BATTERY_0="/sys/class/power_supply/axp20x-battery" PATH_BATTERY_1="/sys/class/power_supply/ip5xxx-battery" ac_0="" @@ -12,11 +14,12 @@ battery_level_1=0 #battery_max_0=0 #battery_max_1=0 -if [ -f "$PATH_AC_0/status" ]; then - ac_0=$(cat "$PATH_AC_0/status" 2>/dev/null) -else - ac_0="-1" + + +if [ ! -f "$PATH_AC_0/status" ]; then + PATH_AC_0=$BACKUP_PATH_AC_0 fi +ac_0=$(cat "$PATH_AC_0/status" 2>/dev/null) if [ -f "$PATH_AC_1/status" ]; then ac_1=$(cat "$PATH_AC_1/status" 2>/dev/null) @@ -24,11 +27,10 @@ else ac_1="-1" fi -if [ -f "$PATH_BATTERY_0/capacity" ]; then - battery_level_0=$(cat "$PATH_BATTERY_0/capacity" 2>/dev/null) -else - battery_level_0=-1 +if [ ! -f "$PATH_BATTERY_0/capacity" ]; then + PATH_BATTERY_0=$BACKUP_PATH_BATTERY fi +battery_level_0=$(cat "$PATH_BATTERY_0/capacity" 2>/dev/null) if [ -f "$PATH_BATTERY_1/capacity" ]; then battery_level_1=$(cat "$PATH_BATTERY_1/capacity" 2>/dev/null) @@ -99,13 +101,15 @@ else fi if [[ "$battery_level_0" -lt "0" ]]; then - echo -n "$icon0 N/A" + #echo -n "$icon0 N/A" + : else - echo -n "$icon0 $battery_level_0 % " + echo -n "$icon0 $battery_level_0 %" fi if [[ "$battery_level_1" -lt "0" ]]; then - echo -n "$icon1 N/A" + #echo -n "$icon1 N/A" + : else - echo -n "$icon1 $battery_level_1 %" + echo -n " $icon1 $battery_level_1 %" fi diff --git a/.config/polybar/scripts/bspwmslim.sh b/.config/polybar/scripts/bspwmslim.sh new file mode 100755 index 0000000..25d0b47 --- /dev/null +++ b/.config/polybar/scripts/bspwmslim.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +desktop="$(DISPLAY=:0 bspc query -D -d focused --names)" +echo $desktop +echo $desktop > lastrun diff --git a/.config/sxhkd/sxhkdrc.save b/.config/sxhkd/sxhkdrc.save new file mode 100644 index 0000000..3bc9c9d --- /dev/null +++ b/.config/sxhkd/sxhkdrc.save @@ -0,0 +1,140 @@ +# +# wm independent hotkeys +# + +# terminal emulator +#super + Return +alt + Return + xfce4-terminal + +# program launcher +#super + @space +alt + @space + dmenu_run + +# make sxhkd reload its configuration files: +#super + Escape +alt + Escape + pkill -USR1 -x sxhkd + +# +# bspwm hotkeys +# + +# quit/restart bspwm +ctrl + alt + {q,r} + bspc {quit,wm -r} + +# close and kill +alt + {_,shift + }\w + bspc node -{c,k} + +# alternate between the tiled and monocle layout +alt + m + bspc desktop -l next + +# send the newest marked node to the newest preselected node +alt + y + bspc node newest.marked.local -n newest.!automatic.local + +# swap the current node and the biggest window +alt + g + bspc node -s biggest.window + +# +# state/flags +# + +# set the window state +alt + {t,shift + t,s,f} + bspc node -t {tiled,pseudo_tiled,floating,fullscreen} + +# set the node flags +alt + ctrl + {m,x,y,z} + bspc node -g {marked,locked,sticky,private} + +# +# focus/swap +# + +# focus the node in the given direction +alt + {_,shift + }{h,j,k,l} + bspc node -{f,s} {west,south,north,east} + +# focus the node for the given path jump +alt + {p,b,comma,period} + bspc node -f @{parent,brother,first,second} + +# focus the next/previous window in the current desktop +alt + {_,shift + }c + bspc node -f {next,prev}.local.!hidden.window + +# focus the next/previous desktop in the current monitor +alt + bracket{left,right} + bspc desktop -f {prev,next}.local + +# focus the last node/desktop +alt + {grave,Tab} + bspc {node,desktop} -f last + +# focus the older or newer node in the focus history +alt + {o,i} + bspc wm -h off; \ + bspc node {older,newer} -f; \ + bspc wm -h on + +# focus or send to the given desktop +alt + {_,shift + }{1-9,0} + bspc {desktop -f,node -d} '^{1-9,10}' + +# +# preselect +# + +# preselect the direction +shift + alt + {h,j,k,l} + bspc node -p {west,south,north,east} + +# preselect the ratio +shift + alt + {1-9} + bspc node -o 0.{1-9} + +# cancel the preselection for the focused node +shift + alt + space + bspc node -p cancel + +# cancel the preselection for the focused desktop +shift + alt + space + bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel + +# +# move/resize +# + +# expand a window by moving one of its side outward +shift + ctrl + {h,j,k,l} + bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0} + +# contract a window by moving one of its side inward +shift + ctrl + alt + {h,j,k,l} + bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0} + +# move a floating window +#alt + {Left,Down,Up,Right} +shift + ctrl + alt + {Left,Down,Up,Right} + bspc node -v {-20 0,0 20,0 -20,20 0} + +#XF86AudioRaiseVolume +# amixer set Master 5%+ + +#XF86AudioLowerVolume +# amixer set Master 5%- + +XF86AudioRaiseVolume + sxmo_multikey.sh volup volup_one volup_two volup_three + +XF86AudioLowerVolume + sxmo_multikey.sh voldown voldown_one voldown_two voldown_three + +XF86PowerOff + sxmo_multikey.sh powerbutton powerbutton_one powerbutton_two powerbutton_three diff --git a/bin/bspwm-session.sh b/bin/bspwm-session.sh index 3b6e012..5ae2976 100755 --- a/bin/bspwm-session.sh +++ b/bin/bspwm-session.sh @@ -1,8 +1,7 @@ #!/bin/bash -nitrogen --restore & -xsettingsd & -picom -f & > /dev/null 2>&1 +xrandr --output DSI-1 --primary & +#nitrogen --restore & +#xsettingsd & +#picom -f & > /dev/null 2>&1 exec bspwm -#exec xterm - diff --git a/bin/sxmo-bspwm-xinit.sh b/bin/sxmo-bspwm-xinit.sh index ce27757..33bd503 100755 --- a/bin/sxmo-bspwm-xinit.sh +++ b/bin/sxmo-bspwm-xinit.sh @@ -68,6 +68,7 @@ init() { envvars sxmo_migrate.sh sync + defaults # shellcheck disable=SC1090,SC1091