#! /bin/bash

# add them ti .local/bin
# then add a simple launcher
# with their names and select
# to use the terminal

FILE1=/usr/lib/vala-panel/appmenu-registrar
FILE2=/usr/lib/vala-panel/appmenu-registrar.OFF
if [ -f "$FILE1" ]; then
    ## Disable Global Menu
    sudo mv "$FILE1" "$FILE2" || exit
    xfconf-query -c xfce4-panel -p /plugins/plugin-3/plugins/plugin-3/compact-mode -n -t bool -s true
    killall appmenu-registrar 
    rofi -e 'Disabling the top menu
Please wait...' &
    ## Reset panels and windows
    xfce4-panel -r &
    xfwm4 --replace &
    xfce4-panel &
    sleep 4 && notify-send 'Top menu DISABLED !' 'Restart your computer in order for this to work properly!'

elif [ -f "$FILE2" ]; then
    ## Enable Global Menu
    sudo mv "$FILE2" "$FILE1" || exit
    xfconf-query -c xfce4-panel -p /plugins/plugin-3/plugins/plugin-3/compact-mode -n -t bool -s false
    rofi -e 'Enabling the top menu
Please wait...' &
    ## Reset panels and windows
    xfce4-panel -r &
    xfwm4 --replace &
    xfce4-panel &
    sleep 4 && notify-send 'The top menu ENABLED !' 'Restart your computer in order for this to work properly!'

else
    notify-send 'ERROR: is the Global Menu installed ?'
fi