Hide battery info

Forums Desktop Info Hide battery info

This topic contains 5 replies, has 2 voices, and was last updated by Glenn Glenn 1 week, 1 day ago.

  • Author
    Posts
  • #1126 Reply

    Chris

    Hi,

    we are using version 1.10.2.1765 and we are using the battery command like so:
    BATTERY=active:1,interval:15,chart:0, display:%3\, %1%,threshold1:1 -20 0000ff

    However, when this line is used on a desktop computer (which has no battery), the text is red und the state is Unknown.

    Is there a way to hide the line if there is no battery available on the current device?

  • #1127 Reply
    Glenn
    Glenn
    Keymaster

    not currently. once that item is active it’s guaranteed to display a line one way or another.

    A number of people have asked a similar question so it is probably worth pondering. For example, I can imagine a special option that would deactivate the item if it returns no data.

    For example: battery=active:1,no-result:1,display: ….. etc

    where the no-result:1 would effectively be saying switch off this item if it returns no result. The value could be a number of possibilities like 1=deactivate, 2=??????

  • #1129 Reply

    Chris

    I don’t know how the parsing of the configuration file currently work, but it might be worth to implement something like conditional statements with some basic comparison operators.

    e.g.:

    
    HOST=active:2,interval:0,set:hostname
    
    IF=value=%hostname%,comparator=ne,target=foo
    TEXT=active:1,interval:0,text:Host,display:%hostname%
    

    That would allow a much more flexible manner of displaying or hiding lines.

    The comparator can be one of

    -eq Equal
    -ne Not equal
    -ge Greater than or equal
    -gt Greater than
    -lt Less than
    -le Less than or equal
    -like Wildcard comparison
    -notlike Wildcard comparison
    -match Regular expression comparison
    -notmatch Regular expression comparison
    -replace Replace operator
    -contains Containment operator
    -notcontains Containment operator
    -in Like –contains, but with the operands reversed.(PowerShell 3.0)
    -notin Like –notcontains, but with the operands reversed.(PowerShell 3.0)
    (see powershell comparison operators: https://ss64.com/ps/syntax-compare.html)

    So the example from above (IF=value=%hostname%,comparator=ne,target=foo) would evaluate to if(%hostname% != 'foo')

    If this comparison evaluates to false, the next not empty line is skipped. Else, the following line is processed like usual.

    In this way also AND/OR are possible:

    AND:

    
    HOST=active:2,interval:0,set:hostname
    
    IF=value=%hostname%,comparator=ne,target=foo
    IF=value=%hostname%,comparator=ne,target=bar
    TEXT=active:1,interval:0,text:Host,display:%hostname%
    

    if(%hostname% != 'foo' && %hostname% != 'bar')

    OR:

    
    HOST=active:2,interval:0,set:hostname
    
    IF=value=%hostname%,comparator=ne,target=foo
    IF=value=%hostname%,comparator=ne,target=bar,or=1
    TEXT=active:1,interval:0,text:Host,display:%hostname%
    

    if(%hostname% != 'foo' or %hostname% != 'bar')

  • #1135 Reply
    Glenn
    Glenn
    Keymaster

    Ok. I like your ideas although I’m not sure I’d want to go that far. An IF statement prior to the item in question is probably do-able.

  • #1139 Reply

    Chris

    Is the source code of Desktop Info available?

    I think it would be great fun for me to implement the IF statement.

  • #1142 Reply
    Glenn
    Glenn
    Keymaster

    Sorry no. Yeah I know, I’m a real party killer…… 🙂

Reply To: Hide battery info
Your information:




Do NOT follow this link or you will be banned from the site!