diff options
-rw-r--r-- | modules/workstation/windowing/sway/status.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/modules/workstation/windowing/sway/status.cpp b/modules/workstation/windowing/sway/status.cpp index f39b13b079d1..f6340f9f8e64 100644 --- a/modules/workstation/windowing/sway/status.cpp +++ b/modules/workstation/windowing/sway/status.cpp @@ -141,8 +141,16 @@ int main(void) } batdisplay = true; } catch (const system_error& ex) { - if (ex.code().value() != ENOENT) + switch (ex.code().value()) { + case ENOENT: + break; + case ENODEV: + out << "? "; + batdisplay = true; + break; + default: throw ex; + } } try { @@ -150,16 +158,32 @@ int main(void) out << capacity << "%"; batdisplay = true; } catch (const system_error& ex) { - if (ex.code().value() != ENOENT) + switch (ex.code().value()) { + case ENOENT: + break; + case ENODEV: + out << "??%"; + batdisplay = true; + break; + default: throw ex; + } try { int charge_now = battery.charge_now(); out << charge_now; batdisplay = true; } catch (const system_error& ex) { - if (ex.code().value() != ENOENT) + switch (ex.code().value()) { + case ENOENT: + break; + case ENODEV: + out << "??????"; + batdisplay = true; + break; + default: throw ex; + } } } |