utility-belt/menu.+.sh
Neur0toxine f38276b2cf
All checks were successful
continuous-integration/drone/push Build is passing
update
2024-02-28 14:24:54 +03:00

111 lines
5.9 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
CONFIG_DIR="$HOME/.config/retailcrm-menu"
TP_EMAILS_FILE="$CONFIG_DIR/tech-support-emails"
TP_PASS_FILE="$CONFIG_DIR/tech-support-password"
TEST_SYSTEM_CREDENTIALS_FILE="$CONFIG_DIR/test-system-credentials"
mkdir -p "$CONFIG_DIR"
copytext () {
if [ "$XDG_SESSION_TYPE" == "x11" ]; then
xclip -selection clipboard <&0
else
wl-copy <&0
fi
}
if [ "$1" == "to-clipboard" ]; then
copytext <&0
exit
fi
if [ "$1" == "tech-password" ]; then
if [ "$2" == "update" ]; then
NEW_PASSWORD=$(zenity --forms --title="Обновление пароля техподдержки" --text="Введите пароль техподдержки" --add-entry="Пароль техподдержки")
if [ $? == 0 ]; then
echo "$NEW_PASSWORD" > "$TP_PASS_FILE"
notify-send -h int:transient:1 -u normal -t 1000 -i dialog-password "Пароль техподдержки обновлён"
fi
fi
if [ "$2" == "copy" ]; then
< "$TP_PASS_FILE" tr -d '\n' | copytext
notify-send -h int:transient:1 -u normal -t 1000 -i dialog-password "Пароль техподдержки скопирован"
fi
exit
fi
if [ "$1" == "testsystem" ]; then
if [ "$2" == "update" ]; then
NEW_CREDENTIALS=$(zenity --forms --title="Обновление доступов тестовой системы" --text="Введите доступы к тестовой системе" --add-entry="API URL" --add-entry="API-ключ")
if [ $? == 0 ]; then
# shellcheck disable=SC2046
echo "$NEW_CREDENTIALS|$(curl -fsSL $(echo "$NEW_CREDENTIALS" | cut -d'|' -f1 | tr -d '\n')/api/system-info | jq -j '.technicalUrl')" > "$TEST_SYSTEM_CREDENTIALS_FILE"
notify-send -h int:transient:1 -u normal -t 1000 -i dialog-password "Данные тестовой системы обновлены"
fi
fi
if [ "$2" == "open-url" ]; then
< "$TEST_SYSTEM_CREDENTIALS_FILE" cut -d'|' -f1 | tr -d '\n' | xargs xdg-open
fi
if [ "$2" == "copy-url" ]; then
< "$TEST_SYSTEM_CREDENTIALS_FILE" cut -d'|' -f1 | tr -d '\n' | copytext
notify-send -h int:transient:1 -u normal -t 1000 -i dialog-password "API URL тестовой системы скопирован"
fi
if [ "$2" == "copy-tech-url" ]; then
< "$TEST_SYSTEM_CREDENTIALS_FILE" cut -d'|' -f3 | tr -d '\n' | copytext
notify-send -h int:transient:1 -u normal -t 1000 -i dialog-password "Технический API URL тестовой системы скопирован"
fi
if [ "$2" == "copy-key" ]; then
< "$TEST_SYSTEM_CREDENTIALS_FILE" cut -d'|' -f2 | tr -d '\n' | copytext
notify-send -h int:transient:1 -u normal -t 1000 -i dialog-password "API-ключ тестовой системы скопирован"
fi
exit
fi
if [ "$1" == "emails-update" ]; then
curl -sSfL https://infra-data.retailcrm.tech/crm-domains.json | jq -r '.domains[].domain' | sed -e s/^/mail@/ > "$TP_EMAILS_FILE"
notify-send -h int:transient:1 -u normal -t 1000 -i mail-unread "Почтовые адреса техподдержки обновлены"
exit
fi
echo " |iconName=system-help"
echo "---"
echo "Логин техподдержки | iconName=avatar-default"
if [[ -f "$TP_EMAILS_FILE" ]]; then
while IFS="" read -r p || [ -n "$p" ]
do
printf '%s%s | iconName=mail-unread bash='"'"'echo %s | %s && notify-send -h int:transient:1 -u normal -t 1000 -i mail-unread "%s скопировано"'"'"' terminal=false\n' "--" "$p" "$p" "$0 to-clipboard" "$p"
done < "$TP_EMAILS_FILE"
else
echo "--Список пуст, обновите"
fi
echo "--Обновить | iconName=view-refresh bash='$0 emails-update' terminal=false"
echo "Пароль техподдержки | iconName=dialog-password"
echo "--Скопировать | iconName=edit-copy bash='$0 tech-password copy' terminal=false"
echo "--Обновить | iconName=view-refresh bash='$0 tech-password update' terminal=false"
echo "Доступы в тестовую CRM | iconName=user-info"
echo "--Открыть систему | iconName=emblem-web bash='$0 testsystem open-url' terminal=false"
echo "--API URL | iconName=system-lock-screen bash='$0 testsystem copy-url' terminal=false"
echo "--Технический API URL | iconName=system-lock-screen bash='$0 testsystem copy-tech-url' terminal=false"
echo "--API-ключ | iconName=emblem-system bash='$0 testsystem copy-key' terminal=false"
echo "--Обновить | iconName=view-refresh bash='$0 testsystem update' terminal=false"
echo "--"
echo "Запись с экрана | iconName=camera-photo"
echo "--Скриншот | iconName=image-x-generic bash='sleep 0.3 && flameshot gui' terminal=false"
echo "--OCR | iconName=document-properties bash='sleep 0.3 && flatpak run com.github.rajsolai.textsnatcher' terminal=false"
echo "--GIF с экрана | iconName=video-display bash='peek' terminal=false"
echo "--Видео с экрана | iconName=simplescreenrecorder bash='simplescreenrecorder' terminal=false"
echo "Соотношение сторон | iconName=video-display"
echo "--XRandr: 2K 21:9 | iconName=view-fullscreen bash='xrandr --output DP-4 --mode 3440x1440 --rate 165 --scale 1.7x1.7' terminal=false"
echo "--XRandr: 2K 16:9 | iconName=view-fullscreen bash='xrandr --output DP-4 --mode 2560x1440 --rate 60 --scale 1.7x1.7' terminal=false"
echo "Размер активного окна | iconName=preferences-system-windows"
echo "--Установить 1920x1080 через 2 секунды | iconName=view-fullscreen bash='sleep 2 && wmctrl -i -r \`xdotool getwindowfocus\` -e 0,0,0,1920,1080' terminal=false"
echo "--Установить 2560x1440 через 2 секунды | iconName=view-fullscreen bash='sleep 2 && wmctrl -i -r \`xdotool getactivewindow\` -e 0,0,0,2560,1440' terminal=false"