X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-tcl-applet.git;a=blobdiff_plain;f=xbatmon-simple-tray;h=135fe6a22b9943b4688661beaab938887efa4c3d;hp=9f2cdbadcc663950f825606980a5b164d11cb81b;hb=HEAD;hpb=4af7e789e3afd4b9a7afb81a6cde31c37386e5c4 diff --git a/xbatmon-simple-tray b/xbatmon-simple-tray index 9f2cdba..1c9c864 100755 --- a/xbatmon-simple-tray +++ b/xbatmon-simple-tray @@ -1,13 +1,20 @@ #!/usr/bin/wish -f # -*- Tcl -*- +# Copyright 2016,2020 Ian Jackson +# SPDX-License-Identifier: GPL-3.0-or-later +# There is NO WARRANTY. + # usage: # xbatmon-simple-tray # [WISH-OPTIONS... [-- TRAY-EMBED-OPTIONS... [-- XBATMON-SIMPLE-OPTIONS...]]] -source subproc.tcl -source utils.tcl -source args.tcl +set lib . + +source $lib/subproc.tcl +source $lib/utils.tcl +source $lib/args.tcl +source $lib/applet.tcl proc cmdline {id orientation} { global argv @@ -141,7 +148,18 @@ proc tt-info {chan} { } } debug::debug "GOT [array names a]" + if {![info exists a(TYPE)]} { + set op {} + foreach k {ONLINE PRESENT} { append op [info exists a($k)] } + switch -exact $op { + 10 { set a(TYPE) Mains } + 01 { set a(TYPE) Battery } + default { error "no type and bad op $op" } + } + debug::debug " guessed type $a(TYPE) from ONLINE PRESENT $op" + } set o "$a(TYPE)" + set nbatts 0 switch -exact -- $a(TYPE) { Mains { @@ -184,7 +202,7 @@ proc tt-info {chan} { #----- modes ----- proc mode/normal {} { - uplevel #0 source applet.tcl + uplevel #0 { applet::become } applet::setup-subproc cmdline applet::setup-tooltip tt-show tt-invisible } @@ -197,6 +215,7 @@ proc mode/-tooltip-string {} { #----- command line parsing ----- set mode normal +set usersettings $env(HOME)/.config/xbatmon-simple-tray while {[args::next_special arg]} { switch -exact -- $arg { @@ -206,4 +225,8 @@ while {[args::next_special arg]} { } } +if {[file exists $usersettings]} { + source $usersettings +} + mode/$mode