VSIDO Community

VSIDO Controls => VSIDO Changes => Topic started by: VastOne on July 07, 2015, 04:15:59 PM

Title: (SOLVED) Yad startup script for ceni
Post by: VastOne on July 07, 2015, 04:15:59 PM
This will be added to the next ISO build to make sure people are are aware and do in fact run ceni to establish their network


  (http://www.zimagez.com/miniature/screenshot2015-07-1622-57-45.php)
(http://www.zimagez.com/zimage/screenshot2015-07-1622-57-45.php)

Script is here

vsido-start (must be made executable)

#! /bin/bash

# Greeting window
action=$(yad --title="VSIDO Messge Center" \
--width=420 \
--image=vsido-start \
--button=$"Run Ceni        :1" \
--button=$"Run WICD        :2" \
--button=$"Close           :3" \
--text=$"Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates

It is recommended that you run Ceni or WICD to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options

Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established
${custom_text}" \ )

ret=$?

[[ $ret -eq 3 ]] && exit 0


if [[ $ret -eq 1 ]] ; then
xfce4-terminal -e ceni
exit 0
fi

if [[ $ret -eq 2 ]] ; then
wicd-gtk -n
exit 0
fi
Title: Re: Yad startup script for ceni
Post by: jedi on July 07, 2015, 06:03:40 PM
Great work VastOne!  Once again, persistence pays off!   :D
Title: Re: Yad startup script for ceni
Post by: hakerdefo on July 07, 2015, 09:44:49 PM
Kudos VastOne!!! A job well-done!!!
Cheers!!!
Title: Re: Yad startup script for ceni
Post by: VastOne on July 09, 2015, 05:38:22 AM
Added wicd to the mix and cleaned it up


  (http://www.zimagez.com/miniature/screenshot2015-07-1013-13-51.php)
(http://www.zimagez.com/zimage/screenshot2015-07-1013-13-51.php)

Script is here

vsido-start (needs to be made executable)

#! /bin/bash

# Greeting window
yad --title="VSIDO Messge Center" --width=420 --image=vsidoorb_blk_sm_140 \
--button=$"Run Ceni                                       :0" \
--button=$"Run Wicd                                       :1" \
--text=$"$live_session_warning

Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates

It is recommended that you run Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options

Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established
${custom_text}" \

if [ $? -eq 0 ] ; then
xfce4-terminal -e ceni

else

if [ $? -eq 1 ] ; then
wicd-gtk


exit 0

fi
fi
Title: Re: Yad startup script for ceni
Post by: VastOne on July 09, 2015, 05:40:40 AM
Thanks jedi and hakerdefo

;D
Title: Re: Yad startup script for ceni
Post by: PackRat on July 09, 2015, 01:35:29 PM
Looks good. But I think Ceni first showed up in Aptosid so calling it an Siduction script may not be accurate. I would just modify their own description contained in the copyright information at the end of the script:

"A Curses user interface for configuring network interfaces with ifupdown."

Or give the author Kel Modderman direct credit.
Title: Re: Yad startup script for ceni
Post by: VastOne on July 09, 2015, 03:05:41 PM
I was never sure of who was the first with that script, the chicken or the egg...

I will give all the creds to Kell Modderman, thanks for that!
Title: Re: Yad startup script for ceni
Post by: VastOne on July 10, 2015, 06:47:15 PM
Made some changes to reflect the proper author


  (http://www.zimagez.com/miniature/screenshot2015-07-1013-13-51.php)
(http://www.zimagez.com/zimage/screenshot2015-07-1013-13-51.php)

Script is here

vsido-start (needs to be made executable)

#! /bin/bash

# Greeting window
yad --title="VSIDO Messge Center" --width=420 --image=vsidoorb_blk_sm_140 \
--button=$"Run Ceni                                       :0" \
--button=$"Run Wicd                                       :1" \
--text=$"$live_session_warning

Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates

It is recommended that you run Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options

Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established
${custom_text}" \

if [ $? -eq 0 ] ; then
xfce4-terminal -e ceni

else

if [ $? -eq 1 ] ; then
wicd-gtk


exit 0

fi
fi


I am having an issue with the exit part of the bash... If you exit terminal by clicking the X on the top right, WICD runs instead of a clean exit of the bash script...

Something basic but I have yet to see what it is to fix

bash pro's, I could use an assist

Thanks
Title: Re: Yad startup script for ceni
Post by: PackRat on July 10, 2015, 07:50:29 PM
I'm no pro, but don't the "fi" have to come before the "exit 0"?
Title: Re: Yad startup script for ceni
Post by: VastOne on July 10, 2015, 08:08:58 PM
^ I thought the same also but it makes no differences... It is something very fundamental I am missing
Title: Re: Yad startup script for ceni
Post by: hakerdefo on July 11, 2015, 06:16:23 PM
Currently I've no way of testing this as I don't have either a latest ISO of VSIDO or a system with YAD.

#!/bin/bash

yad --width=420 \
    --title="VSIDO Message Center" \
    --image=vsidoorb_blk_sm_140 \
    --button="Run Ceni:2" \
    --button="Run Wicd:3" \
    --text="Live_Session_Warning
    Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev creates. It is recommended that you run Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni. If you prefer something with Graphical User Interface select and use the Wicd that has more robust WIFI connectivity options. Using either Ceni or Wicd you'll have a ready to go Network and a working Internet connection in no time." \

ret=$?
cenee=$(xfce4-terminal -e ceni)
wiicd=$(wicd-gtk)

if [[ $ret -eq 2 ]]; then
"$cenee"

else

if [[ $ret -eq 3 ]]; then
"$wiicd"

fi
fi

exit 0



Try it and let me know.
Cheers!!!
Title: Re: Yad startup script for ceni
Post by: PackRat on July 11, 2015, 09:10:32 PM
@hakerdefo - it's a no go on my system. Any selection - ceni, wicd, or close - actually makes both apps run in succession.
Title: Re: Yad startup script for ceni
Post by: VastOne on July 11, 2015, 09:46:54 PM
For me it does the same thing as the original except it opens ceni on close instead of WICD as what PackRat reports

Continuing to test with it

This format seems to work for the looks with your functions hakerdefo


#! /bin/bash

# Greeting window
yad --title="VSIDO Messge Center" --width=420 --image=vsido-start \
--button=$"Run Ceni                                       :2" \
--button=$"Run Wicd                                       :3" \
--text=$"$live_session_warning

Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates

It is recommended that you run Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options

Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established
${custom_text}" \

ret=$?
cenee=$(xfce4-terminal -e ceni)
wiicd=$(wicd-gtk)

if [[ $ret -eq 2 ]]; then
"$cenee"

else

if [[ $ret -eq 3 ]]; then
"$wiicd"

fi
fi

exit 0
Title: Re: Yad startup script for ceni
Post by: hakerdefo on July 11, 2015, 10:26:11 PM
@PackRat @VastOne thanks for the feedback! Sorry my previous script didn't work! Anyways here is a fresh take,


#!/bin/bash

yad --width=420 \
    --title="VSIDO Message Center" \
    --image=vsidoorb_blk_sm_140 \
    --button="Run Ceni:1" \
    --button="Run Wicd:2" \
    --button="Exit:3" \
    --text="Live_Session_Warning
    Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates.

It is recommended that you run Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options.

Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established." \

function tataa (){
exit 0
}

function cenee (){
xfce4-terminal -e ceni
}

function wiicd (){
wicd-gtk
}

case $? in

1) cenee ;;
2) wiicd ;;
3) tataa ;;
esac


Hope this yields better results!!!
Cheers!!!
Title: Re: Yad startup script for ceni
Post by: VastOne on July 11, 2015, 10:35:51 PM
Exit button works but neither the Ceni or WICD functions work at all
Title: Re: Yad startup script for ceni
Post by: hakerdefo on July 11, 2015, 11:53:38 PM
Yet another dash,


#!/bin/bash

yad --width=420 \
    --title="VSIDO Message Center" \
    --image=vsidoorb_blk_sm_140 \
    --button="Run Ceni:$cenee" \
    --button="Run Wicd:$wiicd"
    --text="Live_Session_Warning
    Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates.

It is recommended that you run Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options.

Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established."  \

cenee=$(xfce4-terminal -e ceni)
wiicd=$(wicd-gtk)

exit 0


This attemp is a wild guess! Hoping for some good!
Cheers!!!
Title: Re: Yad startup script for ceni
Post by: VastOne on July 12, 2015, 12:13:34 AM
Same issue, everything button clicked or X clicked makes both Ceni and WICD run
Title: Re: Yad startup script for ceni
Post by: VastOne on July 12, 2015, 03:51:34 AM
I have decided to go with this setup and context

vsido-start (must be made executable)

#! /bin/bash

# Greeting window
action=$(yad --title="VSIDO Messge Center" \
--width=420 \
--image=vsido-start \
--button=$"Run Ceni        :1" \
--button=$"Run WICD        :2" \
--button=$"Close           :3" \
--text=$"Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates

It is recommended that you run Ceni or WICD to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options

Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established
${custom_text}" \ )

ret=$?

[[ $ret -eq 3 ]] && exit 0


if [[ $ret -eq 1 ]] ; then
xfce4-terminal -e ceni
exit 0
fi

if [[ $ret -eq 2 ]] ; then
wicd-gtk -n
exit 0
fi
Title: Re: Yad startup script for ceni
Post by: hakerdefo on July 12, 2015, 09:40:07 AM
I've a Sunday surprise for VastOne  :)
I finally figured it out  8)
YAD has it's own peculiar ways of doing things and it lacks proper documentation! That was the reason YAD had us all confused!
VastOne, I think user should be able to run either ceni or wicd from the startup message. No need to send him/her on hunt for the wicd. Here is the working script at long last,


#! /bin/bash

action=$(yad --width 420 --entry --title "VSIDO Message Center" \
    --image=vsidoorb_blk_sm_140 \
    --button="gtk-ok:0" --button="gtk-close:1" \
    --text "Live_Session_Warning

Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates.

It is recommended that you run Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options.

Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni. Your network is then ready to go and connectivity to the Internet established.

Choose action:" \
    --entry-text \
    "Run_Ceni" "Run_Wicd")

ret=$?

[[ $ret -eq 1 ]] && exit 0

case $action in

Run_Ceni*) cmd="xfce4-terminal -e ceni" ;;
Run_Wicd*) cmd="wicd-gtk --no-tray" ;;
*) exit 1 ;;       

esac

eval exec $cmd



And as PackRat like to say, scrot or it didn't happen,

(http://i.imgur.com/iNVYWEWm.jpg)

(http://i.imgur.com/6RUZLjxm.jpg)

Cheers!!!
Title: Re: Yad startup script for ceni
Post by: PackRat on July 12, 2015, 12:19:22 PM
Script works as advertised.

Thought of one issue though. If the user selects ceni to configure the network, will the wicd.service still be running on boot-up since wicd is getting installed? In the past, having a configured /etc/network/interfaces file was incompatible with wicd (and network-manager).
Title: Re: Yad startup script for ceni
Post by: VastOne on July 14, 2015, 07:04:22 PM
I have decided to stick with the Ceni button option and have anyone else click on the already installed and running wicd icon that is there both in the LiveCD sessions and the install

I do appreciate all of the help from everyone most notably hakerdefo and PackRat

@RatMan

Not quite sure of the issue since wicd is installed and running as a service no matter what, just for the extra wifi capabilities it has.  What I see is a blue triangle on the icon telling me wicd is not seeing a network because I already have it configured with ceni.  If I open wicd and go through it's setup and options, it then correctly starts the network... All of mine is wired though, I cannot speak to anything else
Title: Re: Yad startup script for ceni
Post by: PackRat on July 14, 2015, 11:12:56 PM
An issue of efficiency and compatibility.

If you have a wired (wireless) network and configure it with ceni, you don't need the wicd.service running, or the wicd-gtk tray icon - check out it's memory use with htop. You should now be able to disable the wicd.service with systemctl and still have your network running when you reboot.

If you configured the network with ceni, then use wicd for roaming, in the past that would have caused issues because wicd does not read the /etc/network/interfaces file - it creates it's own configuration files in /etc/wicd. On reboot, it hangs for a while and there would be no network. I believe it still does that.

I don't know what it would require, but having the script disable the wicd.service when ceni is selected for network configuration would be a good thing IMO.
Title: Re: Yad startup script for ceni
Post by: misko_2083 on July 15, 2015, 03:59:30 AM
Had some spare time to play with yad.  :)
Just some cosmetic changes to the VSIDO Message Center. Tried text-info dialogue but it won't process html so I just added some markup to the existing.
(http://i.imgur.com/nRRyzAM.png)
#! /bin/bash

# Greeting window
yad --title="VSIDO Message Center" --center --width=420 --image=vsido-start \
--button=$"Run Ceni                                  :0" \
--button=$"Close                                     :1" \
--text=$"\t\t\t<b><big>Welcome to VSIDO</big></b>\n\n\tDue to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates\n
\t<tt>It is recommended that you run <b>Ceni</b> or <b>WICD</b> to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options by clicking on the WICD icon in the system-tray above right</tt>\n
\tSimply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established
${custom_text}" \


if [ $? -eq 0 ] ; then
xfce4-terminal -e ceni

else
exit 0

fi


By the way, this is a way to display Time and date with yad:
while true; do echo "$(echo "Time               Date" | sed 's/^/#/g')\n" "$(date '+%T       %D')"; sleep 1; done | yad --progress --title="Time" --cancel-label="close"

:D
(http://i.imgur.com/kZovhCy.png)
Title: Re: Yad startup script for ceni
Post by: VastOne on July 15, 2015, 04:32:22 AM
@ misko_2083

Thanks for that!  I will look more into making the script a cosmetic makeover
Title: Re: Yad startup script for ceni
Post by: VastOne on July 15, 2015, 04:34:14 AM
Quote from: PackRat on July 14, 2015, 11:12:56 PM
An issue of efficiency and compatibility.

Snip...

I don't know what it would require, but having the script disable the wicd.service when ceni is selected for network configuration would be a good thing IMO.

Phase two of the script and thank you for the explanation... I will get it done

Thanks!
Title: Re: Yad startup script for ceni
Post by: PackRat on July 15, 2015, 12:13:01 PM
No problem.

When does this script show up? When logging into the live session, or a first run after an install?

I was thinking you will want to remove the "wicd-gtk --tray" from the ~/.fluxbox/startup file. That app is mainly needed to manage networks; it doesn't need to run once connectivity is established using wicd. Certainly doesn't need to be running if a user decides to go with ceni.

Edit - booted the new iso; script shows when logging into live session.
Title: Re: Yad startup script for ceni
Post by: VastOne on July 15, 2015, 03:35:36 PM
It also shows up on the very first boot after a login

If I can get a two button script to work correctly I would then remove the wicd-gtk option from startup and make it just a choice during the LiveCD and at first boot to get the network working

WICD has always been there and ONLY been there for anyone to use as a gui and for the ease of use in how WICD sees the entire wireless networks

If it were up to me, I would remove it completely... but I have no wireless needs... ::)
Title: Re: Yad startup script for ceni
Post by: PackRat on July 15, 2015, 04:11:45 PM
Quote from: VastOne on July 15, 2015, 03:35:36 PM
It also shows up on the very first boot after a login

If I can get a two button script to work correctly I would then remove the wicd-gtk option from startup and make it just a choice during the LiveCD and at first boot to get the network working

WICD has always been there and ONLY been there for anyone to use as a gui and for the ease of use in how WICD sees the entire wireless networks

If it were up to me, I would remove it completely... but I have no wireless needs... ::)

Once I booted the newest VSIDO-live, I realized the situation you're actually facing here. I was thinking that if ceni is going to be your preferred method for network connectivity, you will want to remove wicd so that it is not running services in the background (that's always been the default, not a new systemd issue).

I have not done a clean VSIDO install for a while (it's that f'ing stable, people!). Is there still a first-run script to install applications like geany and cups? It would be an easy fix to add wicd to that list for those that want to go that route. That would require some additional configuration (comment out everything but the loopback interface in /e/n/interfaces) for wicd to work properly, though.

Bit of a dilemma.
Title: Re: Yad startup script for ceni
Post by: hakerdefo on July 15, 2015, 08:31:22 PM
@VastOne @PackRat
Let's suppose VSIDO boots with Wicd disabled and not running. The 'VSIDO Message Center' greets the user and prompt him to choose between Ceni and Wicd. If user decides to use Ceni then there is no need to do anything. User configures the network using Ceni and Wicd can rest in peace. But if user selects Wicd then the 'VSIDO Message Center' will have to start Wicd, Make Wicd to autostart with the system and present user with GTK interface.
If the above is what you guys are trying to achieve then try following Yad startup script,


#! /bin/bash

action=$(yad --width 420 --entry --title "VSIDO Message Center" \
    --image=vsidoorb_blk_sm_140 \
    --button="gtk-ok:0" --button="gtk-close:1" \
    --text "Live_Session_Warning

Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates.

It is recommended that you Run_Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni. Your network is then ready to go and connectivity to the Internet established. You can also select and use the WICD GUI by selecting Run_Wicd. WICD has more robust WIFI connectivity options. Choosing this option will also make WICD to autostart with the system.

Choose action:" \
    --entry-text \
    "Run_Ceni" "Run_Wicd")

ret=$?

[[ $ret -eq 1 ]] && exit 0

case $action in

Run_Ceni*) cmd="xfce4-terminal -e ceni" ;;
Run_Wicd*) cmd="xfce4-terminal -e 'sudo systemctl start wicd' && xfce4-terminal -e 'sudo systemctl enable wicd' && wicd-gtk" ;;
*) exit 1 ;;       

esac

eval exec $cmd



As usual the script is absolutely untested in the absence of xfce terminal and systemd on my end. Test it and let me know the results please.
Cheers!!!
Title: Re: Yad startup script for ceni
Post by: PackRat on July 16, 2015, 12:06:02 AM
Ceni started ok, but the script crashed right after I entered the password for sudo.

Not sure if it's your script, I had wicd installed but it fails to start - get a dbus error.
Title: Re: Yad startup script for ceni
Post by: hakerdefo on July 16, 2015, 06:43:26 AM
PackRat thanks for testing. Please run the following command first and then retest the script,
sudo rm /etc/wicd/*.conf
Cheers!!!
Title: Re: Yad startup script for ceni
Post by: PackRat on July 16, 2015, 12:24:57 PM
No change - did manage to get wicd purged and re-installed so it is working.

There is an error message in the terminal before it quite - something about a non-native systemd service(?).

systemctl list-units | grep wicd

does list a wicd.service

Any idea what log, if any, would have that error?
Title: Re: Yad startup script for ceni
Post by: hakerdefo on July 16, 2015, 06:32:47 PM
Thanks there PackRat. I'll need your help here. I want you to run following commands in the exact order and observe their outcome.
First just check if wicd is running or not,

sudo systemctl status wicd

If wicd is running then try to stop it,

sudo systemctl stop wicd

And then try and start wicd,

sudo systemctl start wicd

Try and run the GTK client,

wicd-gtk

Next check if it is enabled to startup at boot,

sudo systemctl is-enabled wicd

If it is not then try and make it autostart with system,

sudo systemctl enable wicd

Reboot and check if wicd has started and whether the wicd-gtk is running in the tint2 tray.
Thanks in advance PackRat!
Cheers!!!
Title: Re: Yad startup script for ceni
Post by: PackRat on July 16, 2015, 07:02:40 PM
No error messages.

Wicd is enabled and running so all the commands are working like they are supposed to. It's actually how I manage my wireless on the laptop now. The tray applet doesn't show up in the system tray unless -

wicd-gtk --tray

is in an autostart file. I don't have that in my ~/.fluxbox/startup; it's mainly for those that regularly roam between networks.
Title: Re: Yad startup script for ceni
Post by: hakerdefo on July 16, 2015, 07:06:58 PM
Thanks for testing them out! Then why the same commands are failing in the script? Well another puzzle! Any ideas?
Title: Re: Yad startup script for ceni
Post by: PackRat on July 16, 2015, 07:34:09 PM
No specific ideas. But I did change the wicd command to:

Run_Wicd*) cmd="xfce4-terminal -e 'sudo htop' && xfce4-terminal -e 'sudo ps_mem' && wicd-gtk" ;;

and I did get an instance of xfce4-terminal with htop running after entering my password. The second xfce4-terminal did not start.
Title: Re: Yad startup script for ceni
Post by: VastOne on July 16, 2015, 11:10:31 PM
I finally figured out the failures with the button style I wanted and now have it working... It was all in the single [ ] brackets

Once I changed to double brackets and added the ret=$? variables, everything fell into place...

This script has  been tested on new installs and all works as it should and everything exits as it should

This will be the final vsido-start script and will be on the next ISO's

vsido-start (must be made executable)

#! /bin/bash

# Greeting window
action=$(yad --title="VSIDO Messge Center" \
--width=420 \
--image=vsido-start \
--button=$"Run Ceni        :1" \
--button=$"Run WICD        :2" \
--button=$"Close           :3" \
--text=$"Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates

It is recommended that you run Ceni or WICD to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options

Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established
${custom_text}" \ )

ret=$?

[[ $ret -eq 3 ]] && exit 0


if [[ $ret -eq 1 ]] ; then
xfce4-terminal -e ceni
exit 0
fi

if [[ $ret -eq 2 ]] ; then
wicd-gtk -n
exit 0
fi
Title: Re: Yad startup script for ceni
Post by: VastOne on July 17, 2015, 02:44:06 AM
A new install of VSIDO x32 uses 84 MiB on boot even with wicd services running...

Just a tidbit of info...

BTW, I have always removed and purge wicd as a first step on any distro I used that had it

Including VSIDO...  :P
Title: Re: Yad startup script for ceni
Post by: VastOne on July 17, 2015, 03:51:00 AM
I want to say Thank You to everyone who helped with this script

(http://assets.diylol.com/hfs/bd9/292/465/resized/creepy-dog-meme-generator-you-are-beautiful-thank-you-7a8e5b.jpg)
Title: Re: (SOLVED) Yad startup script for ceni
Post by: hakerdefo on July 19, 2015, 06:22:25 PM
EDIT BEGINS (20, July 2015 13:36 [IST]):
Thanks to PackRat I've made some critical changes to the script. Thanks again PackRat!
EDIT ENDS :

VastOne has already decided the vsido-start script but I've spent a good deal of sunday afternoon on this one so here is a different version of vsido-start. I want to thank relentless ratman PackRat for his suggestions,ideas and testing.
This vsido-start script once launched works like this,
* Presents user with the information written by VastOne and gives option of launching either Ceni or Wicd.
* If user selects Ceni, then the script will check the running status of Wicd and if it is running then the script offers option to stop Wicd or keep it running, Next the script checks if Wicd is autostarting or not, If Wicd is enabled to autostart then the script will offer option to disable it or keep it enabled, And finally the script will launch Ceni.
* If user selects Wicd, then the script will check the running status of Wicd service, If the Wicd service is dead then the script will start the Wicd service, Next the script checks if Wicd is autostarting or not. If Wicd is disabled from autostarting then the script will enable Wicd autostart, And finally the script will launch Wicd GTK interface.
Here is the script,


#!/bin/bash

testyad=`which yad`

if [ "$testyad" = "" ]; then
sudo apt-get -y -q install yad
fi

if [ "$testyad" != "" ]; then
DIALOGMENU="`which yad` --window-icon=vsido-start --width=420 --height=393 --center"
DIALOG="`which yad` --window-icon=vsido-start --width=420 --height=393 --center"
TITLE="--always-print-result --dialog-sep --image=vsido-start --title="
TEXT="--text="
ENTRY="--entry "
ENTRYTEXT="--entry-text "
MENU="--list --expand-column=0 --column=Pick --column=Info"
YESNO=" --button=Yes:0 --button=No:1 "
MSGBOX=" --button=Ok:0 "
TITLETEXT="Vsido Message Center"
fi

mainmenu () {

CHOICES=`$DIALOGMENU $TITLE"$TITLETEXT" --button=Ok:0 --button=Exit:1 $MENU $TEXT"Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates.

It is recommended that you run Ceni or WICD to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options.

Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established.

Please select an option:
" \
Ceni "Run Ceni" \
Wicd "Run Wicd"`

if [ "$?" = "0" ]; then
CHOICE=`echo $CHOICES | cut -d "|" -f 1`
else
exit 0
fi

if [ "$CHOICE" = "Ceni" ]; then
cenimenu
elif [ "$CHOICE" = "Wicd" ]; then
wicdmenu
else
exit 0
fi
}

cenimenu () {

wistatus=$(sudo systemctl status wicd | grep "dead")
wiboot=$(sudo systemctl status wicd | grep "disabled")

if [[ -z "$wistatus" ]]; then
CHOICES=`$DIALOGMENU $TITLE"$TITLETEXT" --button=Ok:0 --button=Exit:1 $MENU $TEXT"You have decided to use Ceni. Wicd is no longer needed. Stop Wicd?
" \
Stop "Stop Wicd" \
Cancel "Leave Wicd Running"`

if [ "$?" = "0" ]; then
CHOICE=`echo $CHOICES | cut -d "|" -f 1`
else
exit 0
fi

if [ "$CHOICE" = "Stop" ]; then
sudo systemctl stop wicd
$DIALOG $TITLE"Vsido Mesage Center" $MSGBOX $TEXT"Wicd service has been stopped. \nClick OK to proceed."
fi

if [ "$CHOICE" = "Cancel" ]; then
$DIALOG $TITLE"Vsido Mesage Center" $MSGBOX $TEXT"Wicd service is kept running. \nClick OK to proceed."
fi
fi

if [[ -z "$wiboot" ]]; then
CHOICES=`$DIALOGMENU $TITLE"$TITLETEXT" --button=Ok:0 --button=Exit:1 $MENU $TEXT"You have decided to use Ceni. Would you like to disable Wicd from autostarting?
" \
Disable "Disable Wicd Autostart" \
Cancel "Keep Wicd Autostart Enabled"`

if [ "$?" = "0" ]; then
CHOICE=`echo $CHOICES | cut -d "|" -f 1`
else
exit 0
fi

if [ "$CHOICE" = "Disable" ]; then
sudo systemctl disable wicd
$DIALOG $TITLE"Vsido Mesage Center" $MSGBOX $TEXT"Wicd autostart has been disabled. \nClick OK to proceed."
xfce4-terminal -e 'sudo ceni'
fi

if [ "$CHOICE" = "Cancel" ]; then
$DIALOG $TITLE"Vsido Mesage Center" $MSGBOX $TEXT"Wicd autostart is kept enabled. \nClick OK to proceed."
xfce4-terminal -e 'sudo ceni'
fi
else
xfce4-terminal -e 'sudo ceni'
fi
exit 0
}

wicdmenu () {

wistatus=$(sudo systemctl status wicd | grep "dead")
wiboot=$(sudo systemctl status wicd | grep "disabled")

if [[ -n "$wistatus" ]]; then
$DIALOG $TITLE"Vsido Mesage Center" $MSGBOX $TEXT"Wicd service is not running. \nClick OK to start Wicd."
sudo systemctl start wicd
fi

if [[ -n "$wiboot" ]]; then
$DIALOG $TITLE"Vsido Mesage Center" $MSGBOX $TEXT"Wicd service is disabled from autostarting. \nClick OK to autostart Wicd."
sudo systemctl enable wicd
wicd-gtk --no-tray
else
wicd-gtk --no-tray
fi
exit 0
}

mainmenu



Waiting for the views-reviews especially from VastOne and PackRat.
Cheers!!!
Title: Re: (SOLVED) Yad startup script for ceni
Post by: PackRat on July 19, 2015, 09:05:35 PM
The wicd selection is working.

The ceni selection goes through the wicd options, then fails to start ceni.

This command:

xfce4-terminal -e sudo ceni

yields the error message "unknown option "ceni"

In a terminal, this will start ceni

xfce4-terminal -e 'sudo ceni'

I made the changes in the script and ceni will start; I don't know if that is the proper syntax for your script though.

Well done.
Title: Re: (SOLVED) Yad startup script for ceni
Post by: hakerdefo on July 20, 2015, 08:14:01 AM
PackRat you are being too modest here! That little change is critical! Actually I tested the script on Sakura terminal and it didn't complain about anything but it seems xfce4 terminal has it's own ways to handle commands.
Thanks again from the bottom of my heart, really! Without your testing and support nothing would have been possible!
Cheers to you PackRat  8)
Title: Re: (SOLVED) Yad startup script for ceni
Post by: hakerdefo on July 20, 2015, 08:45:57 AM
Taking cues from VastOne. This one is for PackRat,

(http://i.imgur.com/OWl8IkVm.jpg)
Title: Re: (SOLVED) Yad startup script for ceni
Post by: PackRat on July 20, 2015, 12:41:24 PM
@hackerdefo -

no problem.

nice to see sakura getting some love; nice terminal app that flies under the radar.

As a test, I changed:

xfce4-terminal -e 'sudo ceni'

to

xterm -fa fixed-11 -e sudo ceni

and it works - that should make it disto agnostic for any non-vsido users who are lurking about.
Title: Re: (SOLVED) Yad startup script for ceni
Post by: hakerdefo on July 20, 2015, 07:21:59 PM
'xterm -fa fixed-11 -e'
I didn't know about this one! This is great for scripting! Thanks a metric ton for this tip PackRat!
Cheers!!!
Title: Re: Yad startup script for ceni
Post by: misko_2083 on July 28, 2015, 01:13:41 AM
Quote from: VastOne on July 15, 2015, 04:32:22 AM
@ misko_2083

Thanks for that!  I will look more into making the script a cosmetic makeover
I see you've managed to make Yad script working the way you want.
In the meantime I made vsido-start.py Not as fancy as YAD though.  :P Some python and gtk3+.

#!/usr/bin/env python3
#vsido-start.py
from gi.repository import Gtk
from subprocess import Popen
from gi.repository.GdkPixbuf import Pixbuf

icon="/usr/local/bin/images/vsidologo.png"

class LabelWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="VSIDO Message Center")

        self.set_default_size(-1, 450)


        self.grid = Gtk.Grid()
        self.add(self.grid)


        self.create_label()
        self.create_buttons()


    def create_label(self):
        label = Gtk.Label()
        label.set_markup("Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates"
                          "\n\n"
                          "It is recommended that you run Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options"
                          "\n\n"
                          "Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established")
        label.set_line_wrap(True)
        label.set_size_request(450, -1)


        table = Gtk.Table(1, 1, False)
        table.attach(label, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)
        self.grid.attach(table, 1, 0, 2, 1)

    def create_buttons(self):

        button1 = Gtk.Button(label="Run Ceni")
        button1.connect("clicked", self.on_open_clicked)
        self.grid.attach(button1, 1, 2, 1, 1)

        button2 = Gtk.Button(label="Run Wicd")
        button2.connect("clicked", self.on_click_me_clicked)
        self.grid.attach_next_to(button2, button1, Gtk.PositionType.RIGHT, 1, 1)

        button3 = Gtk.Button(label="_Close", use_underline=True)
        button3.connect("clicked", self.on_close_clicked)
        self.grid.attach(button3,  1, 3, 3, 1)

    def on_click_me_clicked(self, button):
        Popen('/bin/bash -c "wicd-gtk -n &>/dev/null &"', shell=True, stdin=None, stdout=None, stderr=None, close_fds=True)
        Gtk.main_quit()
    def on_open_clicked(self, button):
        Popen('/bin/bash -c "xfce4-terminal -e ceni &>/dev/null &"', shell=True, stdin=None, stdout=None, stderr=None, close_fds=True)
        Gtk.main_quit()
    def on_close_clicked(self, button):
        print("Closing VSIDO Message Center")
        Gtk.main_quit()

window = LabelWindow()     
window.connect("delete-event", Gtk.main_quit)
window.set_resizable(False)
window.set_position(Gtk.WindowPosition.CENTER),
window.set_icon(Pixbuf.new_from_file("{0}".format(icon)))
window.show_all()
Gtk.main()

It looks like this:
(http://i.imgur.com/RGXyCkB.png)
Title: Re: (SOLVED) Yad startup script for ceni
Post by: VastOne on July 28, 2015, 03:58:41 AM
Wow, very nice work misko_2083!

Any reason as to why python would be a better choice? 

Thank you
Title: Re: (SOLVED) Yad startup script for ceni
Post by: misko_2083 on July 30, 2015, 12:16:06 PM
Quote from: VastOne on July 28, 2015, 03:58:41 AM
Wow, very nice work misko_2083!

Any reason as to why python would be a better choice? 

Thank you
It's all the same.
For example this is the equivalent of hakerdefo's script:
#!/usr/bin/env python3
#vsido-start.py
from gi.repository import Gtk, Gdk
import os
import sys
import subprocess
from subprocess import Popen
from gi.repository.GdkPixbuf import Pixbuf


icon="/usr/local/bin/images/vsidoorb_blk.png"

# Which
def which(program):
    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file
    return None

class VsidoStartWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="VSIDO Message Center")

        self.set_default_size(-1, 450)


        self.grid = Gtk.Grid()
        self.add(self.grid)


        self.create_label()
        self.create_buttons()


    def create_label(self):
        label = Gtk.Label()
        label.set_markup("Welcome to VSIDO. Due to changes from Debian, systemd and udev, it is not possible to see every Network Interface that systemd/udev now creates"
                          "\n\n"
                          "It is recommended that you run Ceni to establish your network before you begin. Ceni is a Curses user interface for configuring network interfaces with ifupdown developed by Kel Modderman and used for setting up networks on several distros. You can also select and use the WICD GUI that has more robust WIFI connectivity options"
                          "\n\n"
                          "Simply select your Network Interface and then Accept-Enter and finally Yes to exit Ceni.  Your network is then ready to go and connectivity to the Internet established")
        label.set_line_wrap(True)
        label.set_size_request(450, -1)


        table = Gtk.Table(1, 1, False)
        table.attach(label, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)
        self.grid.attach(table, 1, 0, 2, 1)

    def create_buttons(self):

        button1 = Gtk.Button(label="Run Ceni")
        button1.connect("clicked", self.on_open_clicked)
        self.grid.attach(button1, 1, 2, 1, 1)

        button2 = Gtk.Button(label="Run Wicd")
        button2.connect("clicked", self.on_click_me_clicked)
        self.grid.attach_next_to(button2, button1, Gtk.PositionType.RIGHT, 1, 1)

        button3 = Gtk.Button(label="_Close", use_underline=True)
        button3.connect("clicked", self.on_close_clicked)
        self.grid.attach(button3,  1, 3, 3, 1)

    def on_click_me_clicked(self, button):
        checking = which("wicd-gtk")
        if checking == None:
           print("wicd-gtk not found")
           dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.INFO,
              Gtk.ButtonsType.OK, "VSIDO Message Center")
           dialog.format_secondary_text(
              "'wicd-gtk' can not be found.\nNothing to execute.")
           dialog.set_name('VsidoStart')
           dialog.run()
           dialog.destroy()
        else:
           cmd = "sudo systemctl status wicd | grep -c dead"
           wicdd = os.popen(cmd)
           wicdd = wicdd.readline()

   
           cmd = "sudo systemctl is-enabled wicd | grep -c disabled"
           wicdb = os.popen(cmd)
           wicdb = wicdb.readline()

           if int(wicdd) == 1:
              dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.QUESTION,
                 Gtk.ButtonsType.YES_NO, "VSIDO Message Center", title="VSIDO Message Center")
              dialog.format_secondary_text(
               "You have decided to use Wicd. Wicd service is not running. \nDo you want to start Wicd service?")
              response = dialog.run()

              if response == Gtk.ResponseType.YES:
                os.system('sudo systemctl start wicd')
                dialog.destroy()
              elif response == Gtk.ResponseType.NO:
                dialog.destroy()

           if int(wicdb) == 1:
              dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.QUESTION,
                 Gtk.ButtonsType.YES_NO, "VSIDO Message Center")
              dialog.format_secondary_text(
                 "Wicd service is disabled from autostarting.\nDo you want to enable Wicd autostart?")
              response_disable = dialog.run()
              if response_disable == Gtk.ResponseType.YES:
                 os.system('sudo systemctl enable wicd')
                 dialog.destroy()
              elif response_disable == Gtk.ResponseType.NO:
                 print("wicd not enabled")
              dialog.destroy()
           Popen('/bin/bash -c "wicd-gtk -n &>/dev/null &"', shell=True, stdin=None, stdout=None, stderr=None, close_fds=True)
           Gtk.main_quit()
    def on_open_clicked(self, button):
        #check if ceni exists
        checking = which("ceni")
        if checking == None:
           print("ceni not found")
           dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.INFO,
              Gtk.ButtonsType.OK, "VSIDO Message Center")
           dialog.format_secondary_text(
              "'ceni' can not be found.\nNothing to execute.")
           dialog.set_name('VsidoStart')
           dialog.run()
           dialog.destroy()
        else:
           cmd = "sudo systemctl status wicd | grep -c dead"
           wicdd = os.popen(cmd)
           wicdd = wicdd.readline()

   
           cmd = "sudo systemctl is-enabled wicd | grep -c disabled"
           wicdb = os.popen(cmd)
           wicdb = wicdb.readline()

           if int(wicdd) < 1:
              dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.QUESTION,
                 Gtk.ButtonsType.YES_NO, "VSIDO Message Center", title="VSIDO Message Center")
              dialog.format_secondary_text(
               "You have decided to use Ceni. Wicd is no longer needed. Stop Wicd?")
              response = dialog.run()

              if response == Gtk.ResponseType.YES:
                os.system('sudo systemctl stop wicd')
                dialog.destroy()
              elif response == Gtk.ResponseType.NO:
                dialog.destroy()

           if int(wicdb) < 1:
              dialog = Gtk.MessageDialog(self, 0, Gtk.MessageType.QUESTION,
                 Gtk.ButtonsType.YES_NO, "VSIDO Message Center")
              dialog.format_secondary_text(
                 "You have decided to use Ceni. Wicd is no longer needed. Disable Wicd?")
              response_disable = dialog.run()
              if response_disable == Gtk.ResponseType.YES:
                 os.system('sudo systemctl disable wicd')
              elif response_disable == Gtk.ResponseType.NO:
                dialog.destroy()

           Popen('/bin/bash -c "xfce4-terminal -e ceni &>/dev/null &"', shell=True, stdin=None, stdout=None, stderr=None, close_fds=True)
           Gtk.main_quit()
    def on_close_clicked(self, button):
        print("Closing VSIDO Message Center")
        Gtk.main_quit()

window = VsidoStartWindow()     
window.connect("delete-event", Gtk.main_quit)
window.set_resizable(False)
window.set_position(Gtk.WindowPosition.CENTER),
window.set_icon(Pixbuf.new_from_file("{0}".format(icon)))
window.set_name('VsidoStart')
style_provider = Gtk.CssProvider()
css = """
#VsidoStart {
    background: black;
    background-repeat: no-repeat;
    background-position: 0px 0px;
    color: #FFF;
    font: 20px sans-serif;

}
.button {
    font: 15px sans-serif;
    background: teal;
    -webkit-transition: color 1s;
    transition: color 1s;
    border: 1px solid #000;
    color: white;
    padding-top: 10px;
    padding-right: 20px;
    padding-bottom: 10px;
    padding-left: 20px;
}
.button:hover{
    background-color: #E3E1B8;
    font: 15px sans-serif;
    border: 1px solid #000;
    color: navy;
}
.dialog {
    background-repeat: no-repeat;
    background-position: 0px 0px;
    color: #FFF;
}
"""

style_provider.load_from_data(css.encode())

Gtk.StyleContext.add_provider_for_screen(
    Gdk.Screen.get_default(),
    style_provider,     
    Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
window.show_all()
Gtk.main()

I assume he intended to run it with sudo. Same problem here, it starts Wicd GTK interface with elevated privileges.
Just played a little with css here. Python and Css are a great combo.
(http://i.imgur.com/r6aFtS8.png)
Edit.............................................................
Perhaps it's better to stick with yad. I'd like to help but who knows wheater I will have the time.
I have a few other things on my mind. We are making a control center and Ubuntu 14.04.3 will be out in a few days so I'll be busy next month as we prepareing a new release.
Cheers :)