#!/bin/bash


# THIS SCRIPT RELEASED UNDER GPL-3.0 LICENSE -> https://www.gnu.org/licenses/gpl-3.0.txt
# WRITTEN BY GIORDANO BOSCHETTI FROM GEEKOS DAW, AN GEEKOS ITALIA PROJECT
# DEPENDENCIES: kdialog

export TEXTDOMAIN=usermodaudio

#CHECK PERMISSION (in case it's being launched as $USER from terminal)
if [ "$EUID" -ne 0 ]
  then echo $"Please run as root, e.g. using 'xdg-su -c usermodaudio'."

  zenity --info \
      --title "GeekosDaw rt-config" \
      --text $"Permission denied: please run with administrator privileges." \
      --button="OK"

  exit
fi

#DIALOG
zenity --question \
    --title "GeekosDaw rt-config" \
    --text $"This script adds user '$USER' to groups 'pipewire' and 'audio'.\n\nDo you want to continue?" \
    --no-wrap \
    --ok-label "Yes" \
    --cancel-label "No"

if [ "$?" = 1 ]; then
exit
fi

groupadd -g 200 pipewire
usermod -a -G pipewire $USER
usermod -a -G audio $USER

zenity --info \
    --title "GeekosDaw rt-config" \
    --text $"User $USER got added to pipewire and audio groups.\n\n To activate, restart the computer."
# rm /tmp/usermodaudio
