ROhms
Posted: Sat 12 Jul 2014, 21:24
Program to calculate resistors by color codes.
READ-ONLY Archive
https://oldforum.puppylinux.com/
Code: Select all
#!/bin/bash
[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog
export DAT=/dev/shm/var1
echo "800" > $DAT
# Letro movil
funcion1 () {
VAR=( `cat $DAT` )
echo '<svg width="800" height="150" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<text x="'$VAR'" y="46" xml:space="preserve" style="font-family:monospace;font-size:64px;" font-weight="bold" fill="#7F0D0D" opacity="0.8">MOBILE SIGN WORKING</text>
</svg>' > /dev/shm/var2.svg
VAR=`echo "$VAR - 10" | bc -l`
echo ${VAR} > $DAT
NUM=${VAR%%}
if [ $NUM -lt -720 ]; then echo "800" > $DAT; else deci=0; fi
}
export -f funcion1
export MAIN='
<window title="Mobile sign" resizable="false">
<vbox>
<pixmap>
<variable>IMG</variable>
<input file>/dev/shm/var2.svg</input>
</pixmap>
<button ok></button>
<timer visible="false" milliseconds="true" interval="100">
<action>funcion1</action>
<action type="refresh">IMG</action>
</timer>
</vbox>
</window>
'
case $1 in
-d | --dump) echo "$MAIN" ;;
*) $GTKDIALOG -cp MAIN ;;
esac
unset mobile_sign
unset funcion1
killall -9 mobile_sign.sh
Code: Select all
<notebook tab-height=\"xx\"...</notebook>
Code: Select all
A text widget that has space-expand and space-fill set to true can be used as a spacer to push neighbouring widgets in certain directions.
Here the spacer text is "[]" so you can see it -- drag the window out and watch the button.
#!/bin/sh
GTKDIALOG=gtkdialog
Spacer="[]"
MAIN_DIALOG='
<window title="Spacer Test" window-position="1">
<vbox>
<hbox>
<button space-expand="false" space-fill="false">
<label>This button will stay put</label>
<input file stock="gtk-about"></input>
</button>
<text space-expand="true" space-fill="true">
<label>"'$Spacer'"</label>
</text>
</hbox>
</vbox>
</window>
'
export MAIN_DIALOG
case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac
Regards,
Thunor
__________________________________________
gtkdialog wrote: #summary notebook widget reference
= notebook widget =
A [http://developer.gnome.org/gtk2/2.24/GtkNotebook.html GtkNotebook]
----
== Definition ==
{{{
<notebook tag_attr="value"...>
widget...
<variable>varname</variable>
<input>command</input>
<input file>filename</input>
<sensitive>state</sensitive>
<action signal="type">activity</action>...
<output file>filename</output>
</notebook>
}}}
"..." denotes acceptance of multiples of the same thing.
== Tag Attributes ==
See the [http://developer.gnome.org/gtk2/2.24/Gt ... -hierarchy GtkNotebook] widget and ancestor class properties.
The following custom tag attributes are available:
<wiki:comment>ExportTableStart</wiki:comment>
|| *Name* || *Description* || *Value* || *Since* ||
|| space-expand || Pack widget expanding into space || {{{true}}} or {{{false}}} || 0.7.21 ||
|| space-fill || Pack widget filling space || {{{true}}} or {{{false}}} || 0.7.21 ||
|| block-function-signals || Block signal emissions from functions || {{{true}}} or {{{false}}} || 0.7.21 ||
|| file-monitor || Emit signal when input file(s) change || {{{true}}} or {{{false}}} || 0.8.1 ||
|| auto-refresh || Auto refresh when input file(s) change || {{{true}}} or {{{false}}} || 0.8.1 ||
|| tab-base-index || Tab label start page number || Integer || 0.7.21 ||
|| tab-labels || Tab labels || _label0_ {{{|}}} _label1_ {{{|}}} ... || 0.7.21 ||
|| tab-prefix || Tab label prefix || || 0.7.21 ||
|| tab-suffix || Tab label suffix || || 0.7.21 ||
<wiki:comment>ExportTableEnd</wiki:comment>
== Directives ==
Some of these may have tag attribute equivalents.
<wiki:comment>ExportTableStart</wiki:comment>
|| *Name* || *Description* || *Contents* || *Since* ||
|| variable || Variable name || || 0.7.21 ||
|| variable export="false" || Variable name, not exported to shell || || 0.8.3 ||
|| input^[1]^ || Data input source || Shell command || 0.7.21 ||
|| input file^[1]^ || Data input source || Filename || 0.7.21 ||
|| sensitive || Sensitive state || {{{true}}} or {{{false}}} || 0.7.21 ||
|| action signal="_type_" || Execute command on signal || Shell command || ||
|| action signal="_type_" || Perform function on signal || _function_:_parameter_ || ||
|| action signal="_type_" condition="_type_" || Execute command on signal conditionally || Shell command || 0.8.3 ||
|| action signal="_type_" condition="_type_" || Perform function on signal conditionally || _function_:_parameter_ || 0.8.3 ||
|| output file || Data output target || Filename || 0.7.21 ||
<wiki:comment>ExportTableEnd</wiki:comment>
== Signals ==
There is no default signal for this widget.
The "file-changed" signal is emitted if file-monitor is true and the input file being monitored has changed.
The following signals are connected-up for all widgets:
[http://developer.gnome.org/gtk2/2.24/Gt ... ress-event button-press-event], [http://developer.gnome.org/gtk2/2.24/Gt ... ease-event button-release-event], [http://developer.gnome.org/gtk2/2.24/Gt ... gure-event configure-event], [http://developer.gnome.org/gtk2/2.24/Gt ... tify-event enter-notify-event], [http://developer.gnome.org/gtk2/2.24/Gt ... tify-event leave-notify-event], [http://developer.gnome.org/gtk2/2.24/Gt ... s-in-event focus-in-event], [http://developer.gnome.org/gtk2/2.24/Gt ... -out-event focus-out-event], [http://developer.gnome.org/gtk2/2.24/Gt ... idget-hide hide], [http://developer.gnome.org/gtk2/2.24/Gt ... idget-show show], [http://developer.gnome.org/gtk2/2.24/Gt ... et-realize realize], [http://developer.gnome.org/gtk2/2.24/Gt ... ress-event key-press-event], [http://developer.gnome.org/gtk2/2.24/Gt ... ease-event key-release-event], [http://developer.gnome.org/gtk2/2.24/Gt ... -map-event map-event], [http://developer.gnome.org/gtk2/2.24/Gt ... nmap-event unmap-event]
== Functions ==
The following functions can be performed upon this widget by any widget capable of emitting signals:
<wiki:comment>ExportTableStart</wiki:comment>
|| *Type* || *Description* || *Parameter* || *Since* ||
|| enable || Sensitise widget || Variable name || ||
|| disable || Desensitise widget || Variable name || ||
|| show || Show widget || Variable name || 0.8.1 ||
|| hide || Hide widget || Variable name || 0.8.1 ||
|| grabfocus || Grab input focus || Variable name || 0.8.1 ||
|| refresh || Reload input data || Variable name || 0.7.21 ||
|| save || Save widget data || Variable name || 0.7.21 ||
<wiki:comment>ExportTableEnd</wiki:comment>
The following general functions can be performed by any widget capable of emitting signals:
<wiki:comment>ExportTableStart</wiki:comment>
|| *Type* || *Description* || *Parameter* || *Since* ||
|| break || Break out of actions list || None || 0.8.3 ||
|| command || Execute command || Shell command || ||
|| exit || Exit dialog || A value for the {{{EXIT}}} variable || ||
|| closewindow || Close dialog || Variable name || ||
|| launch || Launch dialog || Variable name || ||
|| presentwindow || [http://developer.gnome.org/gtk2/2.24/Gt ... ow-present Present] dialog || Variable name || 0.8.1 ||
<wiki:comment>ExportTableEnd</wiki:comment>
== Conditions ==
The following conditions can be used within the condition attribute of action directives:
<wiki:comment>ExportTableStart</wiki:comment>
|| *Type* || *Description* || *Argument* || *Since* ||
|| active_is_true(_argument_) || Active state of toggle widget || Variable name || 0.8.3 ||
|| active_is_false(_argument_) || Active state of toggle widget || Variable name || 0.8.3 ||
|| command_is_true(_argument_) || Output of shell command || Shell command || 0.8.3 ||
|| command_is_false(_argument_) || Output of shell command || Shell command || 0.8.3 ||
|| file_is_true(_argument_) || Contents of a file || Filename || 0.8.3 ||
|| file_is_false(_argument_) || Contents of a file || Filename || 0.8.3 ||
|| sensitive_is_true(_argument_) || Sensitive state of widget || Variable name || 0.8.3 ||
|| sensitive_is_false(_argument_) || Sensitive state of widget || Variable name || 0.8.3 ||
|| visible_is_true(_argument_) || Visible state of widget || Variable name || 0.8.3 ||
|| visible_is_false(_argument_) || Visible state of widget || Variable name || 0.8.3 ||
<wiki:comment>ExportTableEnd</wiki:comment>
true means "true", "yes" or a non-zero value, false means "false", "no" or zero, therefore the shell command is expected to echo one of these values to stdout.
== Notes ==
1. This widget does not accept setting a default page before being shown (there's a note about it [http://developer.gnome.org/gtk2/2.24/Gt ... rrent-page here]) which will result in input data being discarded at start-up. This issue can be overcome by using the "[http://developer.gnome.org/gtk2/2.24/Gt ... book--page page]" tag attribute which will be applied after the widget is shown.
All the same...Looking at the info on the notebook widget it says that it supports
space-expand and space-fill but I'm not sure what part of notebook
widget is affected.
Code: Select all
#!/bin/sh
export MAIN_DIALOG='<window title="Examples" icon-name="gtk-info" resizable="false">
<vbox width-request="200">
<hbox>
<text space-expand="false" use-markup="true"><label>"<u><span size='"'large'"' color='"'red'"'>Heading</span></u>"</label></text>
<text space-expand="true" space-fill="true"><label>""</label> </text>
</hbox>
<edit editable="false">
<variable>EDITOR</variable>
<height>150</height>
<width>350</width>
<default>
"This is the default
text of the editor."
</default>
</edit>
</vbox>
</window>
'
gtkdialog --program=MAIN_DIALOG
Code: Select all
#!/bin/sh
export COLOUR=3272C0
[ "`egrep "Stardust_dark_mouse|Stardust_dark_touch|Azenis|TerraNova-Aquarius|terminus|Murrina-Black|DarkRoomCompact|PenOSmaster" /root/.gtkrc-2.0`" ] && COLOUR=FFD900
export MAIN_DIALOG='
<window title="Example" window-position="1">
<vbox>
<text use-markup="true"><label>"<b><span size='"'x-large'"'>p</span><span size='"'x-large'"' color='"'#$COLOUR'"'>Archive</span></b>"</label></text>
</vbox>
</window>'
gtkdialog -p MAIN_DIALOG
I tried <window skip-taskbar-hint="true"> and it works.Override JWM-settings - skip taskbar, sticky, layer, border
This is how to override default settings in your JWM configuration.
Your gtkdialog gui must be called with the --class parameter
Code:
gtkdialog --class=APPLET -f myfile
Then this code must be in your jwm configuration file - $HOME/.jwmrc (to be set permanently, it must be added to /etc/xdg/templates/_root_.jwmrc)
Code:
<Group>
<Class>APPLET</Class>
<Option>nolist</Option>
<Option>sticky</Option>
<Option>noborder</Option>
<Option>layer:12</Option>
</Group>
Code: Select all
<action>echo "$SAVEFOLDER" > $WORKDIR/destination</action>
Code: Select all
#!/bin/sh
# example to define a destination folder
mkdir -p /root/.config/example
export WORKDIR=/root/.config/example # export is needed for input directive
[ ! -e $WORKDIR/destination ] && echo "/root" > $WORKDIR/destination # set initial
export EXAMPLE='<window>
<vbox width-request="390">
<frame Destination Folder>
<hbox>
<entry accept="directory" tooltip-text="Choose Directory to save your data">
<input>cat $WORKDIR/destination</input>
<variable>SAVEFOLDER</variable>
</entry>
<button tooltip-text="Choose Directory to save your data">
<input file stock="gtk-directory"></input>
<action type="fileselect">SAVEFOLDER</action>
</button>
</hbox>
<hbox>
<button use-stock="true" label="gtk-save">
<action>gxmessage My save folder is now $SAVEFOLDER</action>
<action>echo "$SAVEFOLDER" > $WORKDIR/destination</action>
</button>
</hbox>
</frame>
</vbox>
</window>'
gtkdialog -c --program=EXAMPLE
Code: Select all
#!/bin/sh
DESTINATION=/root
export SCRIPTPATH="$0"
function save_folder { sed -i "s|^DESTINATION=.*$|DESTINATION=\"$SAVEFOLDER\"|" "$SCRIPTPATH";}
export -f save_folder
export EXAMPLE='<window>
<vbox width-request="390">
<frame Destination Folder>
<hbox>
<entry accept="directory" tooltip-text="Choose Directory to save your data">
<default>'$DESTINATION'</default>
<variable>SAVEFOLDER</variable>
</entry>
<button tooltip-text="Choose Directory to save your data">
<input file stock="gtk-directory"></input>
<action type="fileselect">SAVEFOLDER</action>
</button>
</hbox>
<hbox>
<button use-stock="true" label="gtk-save">
<action>gxmessage My save folder is now $SAVEFOLDER</action>
<action>save_folder</action>
</button>
</hbox>
</frame>
</vbox>
</window>'
gtkdialog -c --program=EXAMPLE
Code: Select all
[ ! -d $WORKDIR/destination ] && echo "/root" > $WORKDIR/destination
??? The way you wrote your script the folder and the file is created at each start of the script. How could the folder "disappear" and the file it contains still exist? And how does your new code fit into the original file? The test [ ! -d $WORKDIR/destination ] is always true since a folder $WORKDIR/destination is never created and therefore never exists.don570 wrote:I think there is a situation that I didn't perceive when writing my script.
i.e. if the file 'destination' exists but somehow the folder has disappeared
What was wrong with your script? You had that already. It would be even better if the script uses a default path hard coded in the script and creates $WORKDIR/destination only if this default path was actually changed by the user. This way the system keeps clean as long as possible. If the user shortly tests the script and decides not to keep it, no zombie config files are left.I should have a default folder to open when first launching.