#!/bin/bash
roxterm --hide-menubar -T 'mocp Server service' -e "bash -c 'serverstate=0; if ! pidof mocp >/dev/null 2>&1; then serverstate=1; if wpctl status >/dev/null 2>&1; then mocp -S -O ALSADevice=pipewire; else mocp -S; fi; sleep .5; if ! pidof mocp >/dev/null 2>&1; then serverstate=3; fi; fi; mocp -h; echo; TEXTDOMAINDIR=/usr/share/locale; TEXTDOMAIN=antix26-desktop-files; export TEXTDOMAIN; export TEXTDOMAINDIR; source gettext.sh; echo -en \"\033[1;33m\"; (gettext \"MOC, standing for „Music on Console”, is a CLI program, consisting of a server component (mocp) and the cli client (moc), and for convenience one of two antiX MOC GUI managers can be installed, aCMG or PowerMOC. Visit https://gitlab.com/Robin-antiX/acmg/ and https://antix.x10.mx/truc-power-moc.html ​​for more information.\"; echo -n \" \"; gettext \"See above for the basics of moc/mocp (scroll up to read) and enter „man mocp” below for more detailed pieces of information.\"; echo -e \"\n\"; if test \$serverstate -ne 3; then [ \$serverstate -eq 1 ] && gettext \"The mocp server service has been started and is up and running on this machine now.\"; [ \$serverstate -eq 0 ] && gettext \"The mocp server was found running already on this machine.\"; echo -n \" \"; gettext \"To shut it down completely, enter mocp -x below. (For stopping the mocp server it is not enough to close the cli window by pressing q, it will continue in the background as a service.) After having started a playlist you can close all these windows, MOC will continue playing; to access its CLI afterwards, simply restart this program from the antiX menu.\"; echo -e \"\n\"; gettext \"Press the h key in the neighbouring CLI window to get a list of command keys for steering MOC without an additional GUI. Use arrow keys to navigate.\"; else echo -en \"\033[1;31m\"; gettext \"Error: The mocp server service could not be started.\"; echo -en \"\033[1;33m \"; gettext \"Try starting it manually by entering „mocp -SF” below and check for errors in the output text.\"; fi)|fold -s -w80; echo -e \"\033[0;37m\n\"; test \$serverstate -ne 3 && coproc (urxvt -e bash -c \"mocp\"); exec bash'"
