greshake / i3status-rust

Very resourcefriendly and feature-rich replacement for i3status, written in pure Rust
GNU General Public License v3.0
2.86k stars 472 forks source link

v0.30: kdeconnect fails if device not found #1499

Closed ammgws closed 2 years ago

ammgws commented 2 years ago

v0.22

>i3status-rs test_kdeconnect.toml
{"version": 1, "click_events": true}
[
Icon bat_10 not found in your icons file. Please check NEWS.md
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":" PHONE Pixel4 EMP 0% NOTIF 1 ","color":"#DC322FFF","background":"#000000FF","name":"0","instance":"0","separator":false,"separator_block_width":0,"markup":"pango"}],
^C⏎

v0.30

>cargo run test_kdeconnect.toml
{"version": 1, "click_events": true}
[
[{"full_text":" ","name":"0","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"Failed to read charge ","name":"0","markup":"pango"}],
ammgws commented 2 years ago

I think this is because in v0.22 we defaulted to 0 for the charge etc when the DBus method call failed in order to allow for missing devices, whereas that logic is not present in v0.30.

GladOSkar commented 2 years ago

For completeness' sake, i think this error also occurs if the device is connected but the charge can't be read, even if the charge isn't needed because it isn't used in the format string/block coloration

ammgws commented 2 years ago

So you can't even get the charge via busctl --user get-property org.kde.kdeconnect /modules/kdeconnect/devices/yourdeviceid/battery org.kde.kdeconnect.device.battery charge?

What version of kdeconnect are you using?

GladOSkar commented 2 years ago

Currently not on a LAN so i can't test but will check later

GladOSkar commented 2 years ago

Yes the bus device just doesn't have a /battery object:

$ busctl --user tree org.kde.kdeconnect
├─/MainApplication
├─/modules
│ └─/modules/kdeconnect
│   └─/modules/kdeconnect/devices
│     └─/modules/kdeconnect/devices/7814dd5c9a77a7b2
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/bigscreen
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/connectivity_report
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/contacts
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/findmyphone
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/findthisdevice
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/mprisremote
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/notifications
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/photo
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/ping
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/remotecontrol
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/remotekeyboard
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/sftp
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/share
│       ├─/modules/kdeconnect/devices/7814dd5c9a77a7b2/sms
│       └─/modules/kdeconnect/devices/7814dd5c9a77a7b2/telephony
└─/org
  └─/org/kde
    └─/org/kde/kdeconnect
      └─/org/kde/kdeconnect/daemon
ammgws commented 2 years ago

What phone is it? Wonder if it's a bug with kdeconnect itself

GladOSkar commented 2 years ago

Moto G7, about as stock as stock android gets. ¯\_(ツ)_/¯

MaxVerevkin commented 2 years ago

Does 7400195553777ec3fd9224b2c7aaf00b5a7305cc fix this issue?

GladOSkar commented 2 years ago

Yes, but as soon as the notification count drops to 0 i get

image

MaxVerevkin commented 2 years ago

Yeah, documentation is a bit out of sync with the code. Right now notif_count is not set if there are no notifications, because you might want to display something different than zero. IDK if it's practical.

Either docs or code should be changed. Not sure which behavior is better.

Sometimes I wish the config was in lua and the format was just a function (similar to lualine in neovim).

GladOSkar commented 2 years ago

Ahh makes sense. Sure why not, could be useful

GladOSkar commented 2 years ago

Another nit: After booting, the block always shows an the error failed to get is_reachable because the device isn't connected yet (no such path /modules/kdeconnect/devices/7814dd5c9a77a7b2) and then doesn't update once it does connect. Only when i reload using USR2 or reloading i3 it shows as normal.

MaxVerevkin commented 2 years ago

@GladOSkar try the latest commit

GladOSkar commented 2 years ago

Fixed. Thanks!

MaxVerevkin commented 2 years ago

Seems resolved