Compare commits

..

6 Commits

2 changed files with 13 additions and 9 deletions

View File

@@ -16,7 +16,7 @@ RestartSec=3
[Install]
WantedBy=default.target
" > HOME/.config/systemd/user/webcam-barcode.service
" > $HOME/.config/systemd/user/webcam-barcode.service
systemctl --user daemon-reload
systemctl --user enable --now webcam-barcode.service

16
scan.sh
View File

@@ -3,17 +3,21 @@
# Debian: sudo apt-get install zbar-tools xdotool mpv
# Arch: sudo pacman -S zbar xdotool mpv
if [[ $XDG_SESSION_TYPE != "x11" ]]; then
echo "Unsupported session type: $XDG_SESSION_TYPE"
exit 1
fi
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
zbarcam $1 | while read line; do
zbarcam --nodisplay $1 | while read line; do
if [[ $line == *:* ]]; then
code="${line#*:}"
echo "$code"
if ls /run/user/$(id -u)/wayland-*.lock > /dev/null 2>&1
then
wtype "$code" & mpv --quiet --no-video beep.mp3 >> /dev/null
wtype $'\n'
else
xdotool type --delay 0 "$code" & mpv --quiet --no-video beep.mp3 >> /dev/null
xdotool key Return
fi
fi
done