From bf57ecdd6ba6fc00825bea91b6a0cde88f714495 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Sun, 5 May 2024 14:25:22 +0200 Subject: [PATCH] Update blocks --- GNUmakefile | 10 ++++++++-- blocks.def/battery.sh | 9 +++++++-- blocks.def/cpu_temp_button.sh | 2 +- blocks.def/mail.sh | 9 --------- blocks.def/mail_button.sh | 8 +++++--- blocks.def/time_button.sh | 4 ---- blocks.def/volume.sh | 24 ++++++++++++++++++++++-- blocks.def/volume_button.sh | 20 +++++++++++++++----- blocks.def/weather.sh | 14 +------------- 9 files changed, 59 insertions(+), 41 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index b7f2fe6..0497e3c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -6,9 +6,15 @@ CFLAGS = -O3 -Wall -Wextra X11CFLAGS = $(shell pkg-config --cflags x11) X11LIBS = $(shell pkg-config --libs x11) +ifdef LAPTOP + CFLAGS += -DLAPTOP +endif + +ifdef THINKPAD + CFLAGS += -DTHINKPAD +endif + all: dwmblocks sigdwmblocks/sigdwmblocks xgetrootname/xgetrootname -laptop: LFLAG = -DLAPTOP -laptop: install dwmblocks: dwmblocks.c config.h block.h ${CC} -o $@ -Wno-missing-field-initializers -Wno-unused-parameter ${LFLAG} ${CFLAGS} ${X11CFLAGS} $< ${X11LIBS} diff --git a/blocks.def/battery.sh b/blocks.def/battery.sh index e59669e..d7e6c8b 100755 --- a/blocks.def/battery.sh +++ b/blocks.def/battery.sh @@ -18,8 +18,13 @@ if [ "$status" = "Full" ]; then exit 0 fi -chargeNow=$(cat "$battery/charge_now" 2>&1) -chargeFull=$(cat "$battery/charge_full" 2>&1) +if [[ -n "${THINKPAD}" ]]; then + chargeNow=$(cat "$battery/energy_now" 2>&1) + chargeFull=$(cat "$battery/energy_full" 2>&1) +else + chargeNow=$(cat "$battery/charge_now" 2>&1) + chargeFull=$(cat "$battery/charge_full" 2>&1) +fi capacity=$(echo "$chargeNow/$chargeFull*100" | bc -l) printf "%s %.0f%%" "$statusIcon" "$capacity" diff --git a/blocks.def/cpu_temp_button.sh b/blocks.def/cpu_temp_button.sh index 763409e..b1b4a00 100755 --- a/blocks.def/cpu_temp_button.sh +++ b/blocks.def/cpu_temp_button.sh @@ -3,5 +3,5 @@ case "$1" in 1) "$TERMINAL" -e "htop" ;; 2) "$TERMINAL" -e "bashmount" ;; - 3) psensor ;; + 3) ! [ -v THINKPAD ] && psensor ;; esac diff --git a/blocks.def/mail.sh b/blocks.def/mail.sh index 25bcd1d..3577288 100755 --- a/blocks.def/mail.sh +++ b/blocks.def/mail.sh @@ -2,15 +2,6 @@ ICON="📧" -getMails() { - #mw -Y > /dev/null & - #setsid -f mw -Y > /dev/null - #setsid -f $TERMINAL -e "mw" "-Y" - #mailsync > /dev/null - /.$HOME/mailCheck > /dev/null -} - -#getMails unreadMails="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f 2>/dev/null | wc -l 2>/dev/null)" printf "$ICON %s" "$unreadMails" diff --git a/blocks.def/mail_button.sh b/blocks.def/mail_button.sh index 8b71355..c23c1b0 100755 --- a/blocks.def/mail_button.sh +++ b/blocks.def/mail_button.sh @@ -1,10 +1,12 @@ #!/bin/sh +if [ -v THINKPAD ]; then + thunderbird + return +fi + case "$1" in - #1) "$TERMINAL" -e "neomutt" ;; 1) "$TERMINAL" -e "neomutt" > ~/.cache/neomutt.log 2>&1 - #3) mw -Y ;; - # 3) "$TERMINAL" -e "neomutt" ;; esac sigdwmblocks 3 diff --git a/blocks.def/time_button.sh b/blocks.def/time_button.sh index b25535f..555a45b 100755 --- a/blocks.def/time_button.sh +++ b/blocks.def/time_button.sh @@ -9,14 +9,10 @@ manageCalcurse() { } manageNotifications() { - #"$TERMINAL" -e "dunstctl" "history-pop" dunstctl history-pop } case "$1" in 1) manageCalcurse ;; 3) manageNotifications ;; - - # Agregar appointments o algo de ese estilo - # Time tracker tmb puede ser esac diff --git a/blocks.def/volume.sh b/blocks.def/volume.sh index c7b9eb0..edaf47e 100755 --- a/blocks.def/volume.sh +++ b/blocks.def/volume.sh @@ -7,6 +7,9 @@ ICONmute="🔇" ICONspeakermute="🔕" ICONspeaker="🔔" ICONheadphone="🎧" +ICONmicrophone="🎤" +ICONmicrophonemute="😶" +ICONmicrophonemute="🤫" #SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1 SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo @@ -29,8 +32,14 @@ checkDefaultSink() { fi } -VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{printf $5}' | sed s/%//) -MUTE=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{printf $2}') +if [ -v THINKPAD ]; then + VOLUME=$(wpctl get-volume @DEFAULT_SINK@ | awk '{printf "%d", $2 * 100}') + MUTE=$(wpctl get-volume @DEFAULT_SINK@ | grep -q "MUTED" && echo "yes") + MUTE_SOURCE=$(wpctl get-volume @DEFAULT_SOURCE@ | grep -q "MUTED" && echo "yes") +else + VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{printf $5}' | sed s/%//) + MUTE=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{printf $2}') +fi checkDefaultSink @@ -47,6 +56,17 @@ getIcon() { fi fi + if [ -v THINKPAD ]; then + MIC_ICON=$ICONmicrophone + if [ "$MUTE_SOURCE" = "yes" ]; then + MIC_ICON=$ICONmicrophonemute + fi + printf "$ICON %s $MIC_ICON" "$VOLUME%" + return + fi + + echo "?" + if [ -v LAPTOP ]; then printf "$ICON %s" "$VOLUME%" return diff --git a/blocks.def/volume_button.sh b/blocks.def/volume_button.sh index 92bde68..2197e04 100755 --- a/blocks.def/volume_button.sh +++ b/blocks.def/volume_button.sh @@ -5,6 +5,8 @@ SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo SINKANALOG=alsa_output.pci-0000_00_1b.0.analog-stereo checkDefaultSink() { + [ -v LAPTOP ] && return + PACTLOUTPUT="$(pactl get-default-sink)" if echo $PACTLOUTPUT | grep -q "$SINKANALOG"; then @@ -56,10 +58,18 @@ refreshVolumeBlock() { checkDefaultSink -case "$1" in - 1) manageAlsamixer ;; - 2) changeDefaultSink;; - 3) pactl set-sink-mute @DEFAULT_SINK@ toggle;; -esac +if [ -v THINKPAD ]; then + case "$1" in + 1) manageAlsamixer ;; + 2) ;; #changeDefaultSink ;; + 3) wpctl set-mute @DEFAULT_SINK@ toggle ;; + esac +else + case "$1" in + 1) manageAlsamixer ;; + 2) changeDefaultSink ;; + 3) pactl set-sink-mute @DEFAULT_SINK@ toggle ;; + esac +fi refreshVolumeBlock diff --git a/blocks.def/weather.sh b/blocks.def/weather.sh index 8ad94be..e5956fe 100755 --- a/blocks.def/weather.sh +++ b/blocks.def/weather.sh @@ -1,14 +1,7 @@ #!/bin/sh -#TEMP=$(curl -s "wttr.in/Argentina?format=%c%t\n" | sed 's/+//') -#TEMP=$(curl -s "wttr.in/Argentina?format=%c%t\n") -TEMP=$(curl -s "wttr.in/BuenosAires?format=%c+%t\n") -# Corto algunos caracteres pues se imprime un caracter inválido entre medio. -# Es algún tema de los unicode. En terminal se imprime bien... -#TEMP_ICON=$(echo -n $TEMP | cut -b 1-3) -#TEMP_ICON=$(echo -n $TEMP | cut -b 1-4) +TEMP=$(curl -s "wttr.in/Vienna?format=%c+%t\n") TEMP_ICON=$(echo -n $TEMP | cut -d+ -f1) -#TEMP=$(echo -n $TEMP | cut -b 8-) TEMP_TEMP=$(echo -n $TEMP | cut -d+ -f2) ICON_LEN=$(printf $TEMP_ICON | wc -c) @@ -16,12 +9,7 @@ ICON_VAR=$(($ICON_LEN-3)) if [ $ICON_LEN -gt 4 ]; then TEMP_ICON=$(echo -n $TEMP | cut -b 1-$ICON_VAR) printf "%s %s" "$TEMP_ICON" "$TEMP_TEMP" - #printf "%s %s •" "$TEMP_ICON" "$TEMP_TEMP" else printf "%s%s" "$TEMP_ICON" "$TEMP_TEMP" fi -#perl -CO -E "say "\N{$TEMP_ICON}"" - -# Otra forma de bypassear el feof y que se imprima bien es haciendo un grep: -#printf $TEMP_ICON | grep -P "[\x{fe0f}]"