Re: gtkdialog getting started
Posted: 28 Nov 2012, 16:14
double post removed
Code: Select all
#!/bin/bash
# description of script:
# control Modem service on and off
# script name modem_control
# Nov 28,2012 Joe Arose "bigbass"
# this is an administrative script
# written to show what is happening with the service
# without obscuring the processes involved
# keeping everything transparent
rm /tmp/modem_status
# lets run this first to get the modem status before gtkdialog is run
ps -A| grep dhcpcd > /dev/null 2>&1 ;RETVAL=${PIPESTATUS[1]};[ $RETVAL -eq 0 ] && RESULT_="Modem running";[ $RETVAL -ne 0 ] && RESULT_="Modem not running"
echo $RESULT_ >/tmp/modem_status
export MODEM_DIALOG='
<window title="Modem Service Control">
<vbox>
<frame Start / stop modem>
<pixmap icon_size="6">
<input file stock= "gtk-connect"></input>
</pixmap>
</frame>
<frame Wait on status to change... >
<entry>
<input file>/tmp/modem_status</input>
<variable>ENTRY</variable>
</entry>
</frame>
<frame "Enable" starts modem "Disable" stops modem >
<hbox>
<button>
<label>Enable</label>
<action type="enable">ENTRY</action>
<action type="enable">CHECKBOX</action>
<action>/sbin/dhcpcd </action>
<action>ps -A| grep dhcpcd > /dev/null 2>&1 ;RETVAL=${PIPESTATUS[1]};[ $RETVAL -eq 0 ] && RESULT_="Modem running";[ $RETVAL -ne 0 ] && RESULT_="Modem not running" ;echo Modem running >/tmp/modem_status </action>
<action type="refresh">ENTRY</action>
</button>
<button>
<label>Disable</label>
<action type="enable">ENTRY</action>
<action type="enable">CHECKBOX</action>
<action>/sbin/dhcpcd -x</action>
<action>ps -A| grep dhcpcd > /dev/null 2>&1 ;RETVAL=${PIPESTATUS[1]};[ $RETVAL -eq 0 ] && RESULT_="Modem running";[ $RETVAL -ne 0 ] && RESULT_="Modem not running" ;echo Modem not running >/tmp/modem_status </action>
<action type="refresh">ENTRY</action>
</button>
</hbox>
</frame>
<hbox>
<button cancel></button>
</hbox>
</vbox>
</window>
'
gtkdialog --center --program MODEM_DIALOG
Code: Select all
kdialog --getopenfilename /etc/openvpn/. "*.ovpn"
Code: Select all
#!/bin/bash
echo '<window title="'$(gettext "Open a file")'" icon-name="gtk-open" width-request="350">
<vbox>
<text><label>Please select a file:</label></text>
<hbox>
<entry fs-action="file"
fs-title="Select a file"
fs-filters="*.'$2'"
fs-folder="'$1'"
editable="false">
<variable>entselFile</variable>
</entry>
<button space-expand="false" space-fill="false">
<label>Select</label>
<variable>butselFile</variable>
<action function="fileselect">entselFile</action>
</button>
</hbox>
</vbox>
</window>
'|gtkdialog -s -c
Code: Select all
choose_file(){
place_above_code_in_here
}
choose_file /etc/openvpn ovpn
Code: Select all
sh: term: command not found
Code: Select all
function term(){
exec xterm -e "openvpn --config $entselFile"
}
Code: Select all
<button>
<label>Start</label>
<action>term</action></button>
<button>
Code: Select all
export -f term