diff --git a/ansible/roles/gpg/templates/gpg-agent.conf.j2 b/ansible/roles/gpg/templates/gpg-agent.conf.j2 index 2c1159e..5f614e4 100644 --- a/ansible/roles/gpg/templates/gpg-agent.conf.j2 +++ b/ansible/roles/gpg/templates/gpg-agent.conf.j2 @@ -5,7 +5,7 @@ default-cache-ttl 600 max-cache-ttl 7200 display :0 {% if os_flavor == "linux" %} -pinentry-program /usr/bin/pinentry-qt5 +pinentry-program /usr/bin/pinentry-qt {% elif os_flavor == "freebsd" %} pinentry-program /usr/local/bin/pinentry-qt5 {% endif %} diff --git a/ansible/roles/sway/files/waybar_battery b/ansible/roles/sway/files/waybar_battery_freebsd similarity index 100% rename from ansible/roles/sway/files/waybar_battery rename to ansible/roles/sway/files/waybar_battery_freebsd diff --git a/ansible/roles/sway/files/waybar_battery_linux b/ansible/roles/sway/files/waybar_battery_linux new file mode 100644 index 0000000..af221ff --- /dev/null +++ b/ansible/roles/sway/files/waybar_battery_linux @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# +# Read battery status in FreeBSD +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +SLEEP_INTERVAL=${SLEEP_INTERVAL:-30} + +batteries=$(find /sys/class/power_supply -name 'BAT*') + +while true; do + text="" + tooltip="" + percentage="" + while read bat; do + battery_now=$(cat "$bat/charge_now") + battery_capacity=$(cat "$bat/charge_full") + battery_percentage=$(( battery_now * 100 / battery_capacity )) + battery_status=$(cat "$bat/status") + seconds_remaining="-1" + + if [ $battery_status = "Charging" ]; then + if [ $battery_percentage -eq 100 ]; then + battery_icon="" + else + battery_icon="" + fi + elif [ $battery_percentage -le 20 ]; then + battery_icon="" + elif [ $battery_percentage -le 40 ]; then + battery_icon="" + elif [ $battery_percentage -le 60 ]; then + battery_icon="" + elif [ $battery_percentage -le 80 ]; then + battery_icon="" + elif [ $battery_percentage -lt 100 ]; then + battery_icon="" + else + battery_icon="" + fi + if [ $seconds_remaining -eq -1 ]; then + time_remaining="unknown time remaining." + else + time_remaining=$(printf '%dh:%dm:%ds\n' $((seconds_remaining/3600)) $((seconds_remaining%3600/60)) $((seconds_remaining%60)) ) + fi + + text="$text${battery_percentage}% ${battery_icon}" + tooltip="$tooltip${time_remaining}" + percentage="$percentage${battery_percentage}" + done<<<"$batteries" + + + jq --unbuffered --compact-output <