2023-03-20 13:40:03 +03:00
|
|
|
|
#!/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
|
|
|
|
|
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=video-display"
|
|
|
|
|
echo "--Скриншот | iconName=image-x-generic bash='sleep 0.3 && flameshot gui' terminal=false"
|
|
|
|
|
echo "--GIF с экрана | iconName=video-display bash='peek' terminal=false"
|
|
|
|
|
echo "--Видео с экрана | iconName=simplescreenrecorder bash='simplescreenrecorder' terminal=false"
|
|
|
|
|
|
2023-10-25 14:44:26 +03:00
|
|
|
|
echo "Изменить размер окна на 1920x1080 | iconName=view-fullscreen bash='sleep 2 && wmctrl -i -r \`xdotool getwindowfocus\` -e 0,0,0,1920,1080' terminal=false"
|
|
|
|
|
echo "Изменить размер окна на 2560x1440 | iconName=view-fullscreen bash='sleep 2 && wmctrl -i -r \`xdotool getactivewindow\` -e 0,0,0,2560,1440' terminal=false"
|