feat: set-light, banana, better set-wlp

This commit is contained in:
AngeD 2023-05-22 13:44:18 +02:00
parent f3f96e1749
commit 0e8d085598
16 changed files with 112 additions and 38 deletions

@ -1 +1 @@
Subproject commit c90e273f7b8c50a02f956c24ce4804a47f18162e Subproject commit 47302af74be7b79f002773011f0d8e85679a7618

@ -1 +1 @@
Subproject commit eeda94a0b5b370d837f1ba6f70c8038b3936808b Subproject commit 6f1d124bbcf03c4c410c093143a86415f46d16a0

@ -1 +1 @@
Subproject commit d20f23c0d6810c8754737428771eef40bd1056a7 Subproject commit f6e82074761473d30a722f5d90c60282de1ac41d

@ -1 +1 @@
Subproject commit f2645c13205abb9ee3dbcee68416645c69b863c8 Subproject commit 40c31fdde93bcd85aeb3447bb3e2a3208395a868

@ -1 +1 @@
Subproject commit 455ded29924aeebdd584f2bb0866788ba0a49dfe Subproject commit f2778bd1a28b74adf5b1aa51aa57da85adfa3d16

@ -1 +1 @@
Subproject commit aa631e13d23ea0b0cfa72ea13411f6dbad18ecbf Subproject commit b4715b5963c086b30679da718a47aea9aa9394a8

@ -1 +1 @@
Subproject commit 045f006c50d782a6d3acbd8a07d1595322ff7e43 Subproject commit 951d6957895b1887567b3ea7e548f9533daa3c83

@ -1 +1 @@
Subproject commit 5d3e86e2a48adf7a308773f8f1b725d187c7c5ef Subproject commit b06663df23b2910a6e542dc114dc7adc2cdce22f

19
bin/banana Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash -e
DBUS_SESSION_BUS_ADDRESS= # https://wiki.archlinux.org/title/Podman#Permission_denied:_OCI_permission_denied
CRI=(podman)
IMG=ghcr.io/epitech/coding-style-checker
TAG=latest
REPORTS="$(mktemp -d)"
LOGS="$REPORTS/coding-style-reports.log"
"${CRI[@]}" run --rm \
-v "$PWD:/mnt/delivery" \
-v "$REPORTS:/mnt/reports" \
"$IMG:$TAG" \
/mnt/delivery /mnt/reports
cat "$LOGS"
echo "$(grep -c ': MAJOR:' "$LOGS") major, $(grep -c ': MINOR:' "$LOGS") minor, $(grep -c ': INFO:' "$LOGS") info coding style error(s) reported in $LOGS"

View File

@ -1,3 +1,16 @@
#!/bin/bash #!/bin/bash -e
sudo docker run -it --rm --user "$UID:$GID" -v "$PWD:/usr/app/" docker.io/epitechcontent/epitest-docker bash "$@" DBUS_SESSION_BUS_ADDRESS= # https://wiki.archlinux.org/title/Podman#Permission_denied:_OCI_permission_denied
CRI=(podman)
IMG=docker.io/epitechcontent/epitest-docker
TAG=latest
if ! "${CRI[@]}" container start epitest > /dev/null 2>&1; then
"${CRI[@]}" run --rm -d \
--name epitest \
-v "$HOME:$HOME" \
"$IMG:$TAG" sleep infinity > /dev/null
fi
"${CRI[@]}" exec -it -w "$PWD" epitest "$@"

View File

@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash -e
set -e
# counts target = 8182 ~ 25cm # counts target = 8182 ~ 25cm
sleep 3 sleep 3
for _ in {0..1023}; do for _ in {0..1023}; do
xdotool mousemove_relative 8 0 xdotool mousemove_relative 8 0
#ydotool mousemove -x 8 -y 0
done done

View File

@ -33,15 +33,6 @@ update_vol() {
fi fi
} }
update_backlight() {
local actual_brightness
local max_brightness
read -r actual_brightness </sys/class/backlight/*/actual_brightness
read -r max_brightness </sys/class/backlight/*/max_brightness
backlight=" $((actual_brightness * 100 / max_brightness))%"
}
update_wlp() { update_wlp() {
local sig; sig="$(grep wlp /proc/net/wireless | awk '{print $3 * 100}')" local sig; sig="$(grep wlp /proc/net/wireless | awk '{print $3 * 100}')"
local ssid; ssid="$(nmcli -t -f name,device connection show --active | grep wlp | cut -d: -f1)" local ssid; ssid="$(nmcli -t -f name,device connection show --active | grep wlp | cut -d: -f1)"
@ -73,22 +64,20 @@ while [ -z "$(wpctl get-volume '@DEFAULT_AUDIO_SINK@' 2> /dev/null)" ]; do
sleep 1 sleep 1
done done
update_vol update_vol
update_backlight
reload_bar() { reload_bar() {
sec=0 sec=0
} }
display() { display() {
xsetroot -name "$crypto | $cpu | $memory | $vol | $backlight | $wlp | $bat | $time" xsetroot -name "$crypto | $cpu | $memory | $vol | $wlp | $bat | $time"
} }
# SIGNALING # SIGNALING
# trap '<function>;display' 'RTMIN+n' # trap '<function>;display' 'RTMIN+n'
trap 'reload_bar;display' 'RTMIN' trap 'reload_bar;display' 'RTMIN'
trap 'update_vol;display' 'RTMIN+1' trap 'update_vol;display' 'RTMIN+1'
trap 'update_backlight;display' 'RTMIN+2' trap 'update_crypto;display' 'RTMIN+2'
trap 'update_crypto;display' 'RTMIN+3'
# to update it from external commands # to update it from external commands
## kill -m "$(cat ~/.cache/pidofbar)" ## kill -m "$(cat ~/.cache/pidofbar)"
# where m = 34 + n # where m = 34 + n

34
bin/set-light Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash -e
function get_current() {
local d="$1"
local cur; cur="$(cat "$1/brightness")"
local max; max="$(cat "$1/max_brightness")"
echo "$((cur * 100 / max))"
}
function set-light() {
local d="$1"
local max; max="$(cat "$d/max_brightness")"
echo "$((CUR * max / 100))" > "$d/brightness"
}
NOTIFY='notify-send -t 1000 -a changeVolume -u low'
NOTIFYVOL="$NOTIFY -i audio-volume-high"
DIRS=(/sys/class/backlight/*)
CUR="$(get_current "${DIRS[0]}")"
case "${1:0:1}" in
'') echo "$CUR"; exit ;;
'+'|'-') CUR="$((CUR + $1))" ;;
*) CUR="$1" ;;
esac
for d in "${DIRS[@]}"; do
set-light "$d" "$CUR"
done
$NOTIFYVOL -h string:synchronous:vol -h int:value:"$CUR" "$CUR%"

View File

@ -1,7 +1,7 @@
#!/bin/bash -e #!/bin/bash -e
DUNSTIFY='dunstify -t 1000 -a changeVolume -u low' NOTIFY='notify-send -t 1000 -a changeVolume -u low'
DUNSTIFYVOL="$DUNSTIFY -i audio-volume-high" NOTIFYVOL="$NOTIFY -i audio-volume-high"
SINK='@DEFAULT_AUDIO_SINK@' SINK='@DEFAULT_AUDIO_SINK@'
WPCUR="$(wpctl get-volume "$SINK")" WPCUR="$(wpctl get-volume "$SINK")"
@ -12,10 +12,10 @@ grep -q MUTED <<< "$WPCUR" && MUTE=1 || MUTE=0
if [ "$1" == 'm' ]; then if [ "$1" == 'm' ]; then
if [ "$MUTE" = 1 ]; then if [ "$MUTE" = 1 ]; then
wpctl set-mute "$SINK" 0 wpctl set-mute "$SINK" 0
$DUNSTIFYVOL -h string:x-dunst-stack-tag:vol -h int:value:"$CUR" "$CUR%" $NOTIFYVOL -h string:synchronous:vol -h int:value:"$CUR" "$CUR%"
else else
wpctl set-mute "$SINK" 1 wpctl set-mute "$SINK" 1
$DUNSTIFY -i audio-volume-muted -h string:x-dunst-stack-tag:vol "Mute" $NOTIFY -i audio-volume-muted -h string:synchronous:vol "Mute"
fi fi
else else
case "${1:0:1}" in case "${1:0:1}" in
@ -28,7 +28,7 @@ else
if [ "$MUTE" = 1 ]; then if [ "$MUTE" = 1 ]; then
wpctl set-mute "$SINK" 0 wpctl set-mute "$SINK" 0
fi fi
$DUNSTIFYVOL -h string:x-dunst-stack-tag:vol -h int:value:"$CUR" "$CUR%" $NOTIFYVOL -h string:synchronous:vol -h int:value:"$CUR" "$CUR%"
fi fi
# update sbar # update sbar

View File

@ -1,16 +1,35 @@
#!/bin/bash -e #!/bin/bash -e
readarray -t NET <<< \ RESCAN=0
"$(nmcli -f SSID,CHAN,RATE,SIGNAL,BARS,SECURITY dev wifi list \
| awk '!seen[$1]++')" NMCLI=(nmcli dev wifi)
CON=("${NMCLI[@]}" connect)
function connect() {
if ! "${CON[@]}" "$1" 2> /dev/null; then
if [ "$RESCAN" = 1 ]; then
return
fi
RESCAN=1
"${NMCLI[@]}" list --rescan yes > /dev/null
if ! "${CON[@]}" "$1"; then
return
fi
fi
kill -36 "$(cat "$HOME/.cache/pidofbar")"
exit
}
if [ -n "$1" ]; then if [ -n "$1" ]; then
nmcli device wifi con "$1" connect "$1"
else else
readarray -t NET <<< \
"$(nmcli -f SSID,CHAN,RATE,SIGNAL,BARS,SECURITY dev wifi list \
| awk '!seen[$1]++')"
COLUMNS=1 COLUMNS=1
select net in "${NET[@]}"; do select net in "${NET[@]}"; do
nmcli device wifi con "$(awk '{print $1}' <<< "$net")" && break connect "$(awk '{print $1}' <<< "$net")" && break
done done
fi fi
kill -37 "$(cat "$HOME/.cache/pidofbar")"

View File

@ -14,6 +14,6 @@ fi
(set -e (set -e
asciiquarium & asciiquarium &
cmatrix -ab & cmatrix -abo &
while true; do sl; done & while true; do sl; done &
) | lolcat > "$1" ) | lolcat > "$1"