#!/bin/bash

# This script choose and run right text editor
# for Sparky applications
# Created by Paweł "pavroo' Pijanowski 2015/11/12
# Copyright 2015-2023 under the GNU GPL2 License
# Last update 2023/03/09

if [ -f /usr/bin/spedit ]; then
	spedit "$@"

elif [ $(pidof xfwm4) ] && [ -f /usr/bin/mousepad ]; then
	mousepad "$@"

elif [ $(pidof marco) ] && [ -f /usr/bin/pluma ]; then
	pluma "$@"

elif [ $(pidof kwin_x11) ] && [ -f /usr/bin/featherpad ]; then
	featherpad "$@"

elif [ $(pidof kwin_x11) ] && [ -f /usr/bin/leafpad ]; then
	leafpad "$@"

elif [ $(pidof enlightenment) ] && [ -f /usr/bin/ecrire ]; then
	ecrire "$@"

elif [ $(pidof gala) ] && [ -f /usr/bin/leafpad ]; then
	leafpad "$@"

elif [ $(pidof lxqt-session) ] && [ -f /usr/bin/featherpad ]; then
	featherpad "$@"

elif [ $(pidof openbox) ]; then
	if [ -f /usr/bin/leafpad ]; then
		leafpad "$@"
	elif [ -f /usr/bin/mousepad ]; then
		mousepad "$@"
	fi

else
	if [ -f /usr/bin/gnome-text-editor ]; then
		gnome-text-editor "$@"

	elif [ -f /bin/nano ]; then
		$SPARKYXTERM nano "$@"

	fi
fi

exit 0
