almost done
This commit is contained in:
@@ -22,18 +22,6 @@ namespace waybar::modules {
|
||||
private:
|
||||
|
||||
const void updateCurrentModem();
|
||||
const MMModemState getModemState() const;
|
||||
const std::string getModemStateString() const;
|
||||
const std::string getModemStateFormatString() const;
|
||||
const std::string getAccessTechnologiesString() const;
|
||||
const int getSignalQuality() const;
|
||||
const std::string getPowerStateString() const;
|
||||
const std::string getImeiString() const;
|
||||
|
||||
const MMModemModeCombination getCurrentModes() const;
|
||||
const std::string getPreferredModeString() const;
|
||||
const std::string getCurrentModesString() const;
|
||||
const std::string getOperatorNameString() const;
|
||||
|
||||
util::SleeperThread thread_;
|
||||
std::string state_;
|
||||
|
||||
+21
-13
@@ -19,7 +19,7 @@ $XDG_CONFIG_HOME/waybar/config ++
|
||||
libmm-glib lives in:
|
||||
|
||||
. /usr/lib/libmm-glib.so or /usr/lib64/libmm-glib.so
|
||||
. /usr/lib/pkgconfig/libgps.pc or /usr/lib64/pkgconfig/libgps.pc
|
||||
. /usr/lib/pkgconfig/libmm-glib.pc or /usr/lib64/pkgconfig/libmm-glib.pc
|
||||
. /usr/include/libmm-glib
|
||||
|
||||
# CONFIGURATION
|
||||
@@ -35,7 +35,7 @@ libmm-glib lives in:
|
||||
Option to disable tooltip on hover.
|
||||
|
||||
*tooltip-format*: ++
|
||||
typeof: string ++
|
||||
typeof: strirng ++
|
||||
default: Games running: {glyph} ++
|
||||
The text format of the tooltip.
|
||||
|
||||
@@ -44,6 +44,16 @@ libmm-glib lives in:
|
||||
default: 5 ++
|
||||
The interval in which the WWAN information gets polled (e.g. carrier name).
|
||||
|
||||
*imei*: ++
|
||||
typeof: string ++
|
||||
default: {glyph} ++
|
||||
Select only the modem with the corresponding imei.
|
||||
|
||||
*path*: ++
|
||||
typeof: string ++
|
||||
default: {glyph} ++
|
||||
Select only the modem with the corresponding hardware path.
|
||||
|
||||
*hide-failed*: ++
|
||||
typeof: bool ++
|
||||
default: true ++
|
||||
@@ -62,25 +72,23 @@ libmm-glib lives in:
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{mode}*: Fix mode
|
||||
*{state}*: Modem state.
|
||||
|
||||
*{status}*: Technology used for GPS fix. Not all GPS receivers report this.
|
||||
*{access_technologies}*: List of all the supported access technologies.
|
||||
|
||||
*{latitude}*: Latitude, decimal degrees. Can be NaN.
|
||||
*{current_modes}*: List of all the currently active connection modes.
|
||||
|
||||
*{latitude_error}*: Latitude uncertainty, meters. Can be NaN.
|
||||
*{preferred_mode}*: The preferred connection mode in use.
|
||||
|
||||
*{longitude}*: Longitude, decimal degrees. Can be NaN.
|
||||
*{supported_modes}*: List of all the supported connection modes.
|
||||
|
||||
*{longitude_error}*: Longitude uncertainty, meters. Can be NaN.
|
||||
*{current_bands}*: List of all the currently active frequency bands.
|
||||
|
||||
*{altitude_hae}*: Altitude, height above ellipsoid, meters. Can be NaN.
|
||||
*{supported_bands}*: List of all the supported frequency bands.
|
||||
|
||||
*{altitude_msl}*: Longitude, MSL, meters. Can be NaN.
|
||||
*{signal_quality}*: Signal quality (0-100).
|
||||
|
||||
*{altitude_error}*: Altitude uncertainty, meters. Can be NaN.
|
||||
|
||||
*{speed}*: Speed over ground, meters/sec. Can be NaN.
|
||||
*{operator_name}*: Name of the network operator.
|
||||
|
||||
*{speed_error}*: Speed uncertainty, meters/sec. Can be NaN.
|
||||
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
waybar-gps(5) "waybar-gps" "User Manual"
|
||||
|
||||
# NAME
|
||||
|
||||
waybar - gps module
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
*gps* module for gpsd.
|
||||
|
||||
|
||||
# FILES
|
||||
|
||||
$XDG_CONFIG_HOME/waybar/config ++
|
||||
Per user configuration file
|
||||
|
||||
# ADDITIONAL FILES
|
||||
|
||||
libgps lives in:
|
||||
|
||||
. /usr/lib/libgps.so or /usr/lib64/libgps.so
|
||||
. /usr/lib/pkgconfig/libgps.pc or /usr/lib64/pkgconfig/libgps.pc
|
||||
. /usr/include/gps
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
*format*: ++
|
||||
typeof: string ++
|
||||
default: {glyph} ++
|
||||
The text format.
|
||||
|
||||
*tooltip*: ++
|
||||
typeof: bool ++
|
||||
default: true ++
|
||||
Option to disable tooltip on hover.
|
||||
|
||||
*tooltip-format*: ++
|
||||
typeof: string ++
|
||||
default: Games running: {glyph} ++
|
||||
The text format of the tooltip.
|
||||
|
||||
*interval*: ++
|
||||
typeof: integer ++
|
||||
default: 5 ++
|
||||
The interval in which the GPS information gets polled (e.g. current speed).
|
||||
Significant updates (e.g. the current fix mode) are updated immediately.
|
||||
|
||||
*hide-disconnected*: ++
|
||||
typeof: bool ++
|
||||
default: true ++
|
||||
Defines if the module should be hidden if there is no GPS receiver.
|
||||
|
||||
*hide-no-fix*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
Defines if the module should be hidden if there is no GPS fix.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{mode}*: Fix mode
|
||||
|
||||
*{status}*: Technology used for GPS fix. Not all GPS receivers report this.
|
||||
|
||||
*{latitude}*: Latitude, decimal degrees. Can be NaN.
|
||||
|
||||
*{latitude_error}*: Latitude uncertainty, meters. Can be NaN.
|
||||
|
||||
*{longitude}*: Longitude, decimal degrees. Can be NaN.
|
||||
|
||||
*{longitude_error}*: Longitude uncertainty, meters. Can be NaN.
|
||||
|
||||
*{altitude_hae}*: Altitude, height above ellipsoid, meters. Can be NaN.
|
||||
|
||||
*{altitude_msl}*: Longitude, MSL, meters. Can be NaN.
|
||||
|
||||
*{altitude_error}*: Altitude uncertainty, meters. Can be NaN.
|
||||
|
||||
*{speed}*: Speed over ground, meters/sec. Can be NaN.
|
||||
|
||||
*{speed_error}*: Speed uncertainty, meters/sec. Can be NaN.
|
||||
|
||||
*{climb}*: Vertical speed, meters/sec. Can be NaN.
|
||||
|
||||
*{climb_error}*: Vertical speed uncertainty, meters/sec. Can be NaN.
|
||||
|
||||
*{satellites_visible}*: Number of satellites visible from the GPS receiver.
|
||||
|
||||
*{satellites_used}*: Number of satellites used for the GPS fix.
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
"gps": {
|
||||
"format": "{mode}",
|
||||
"format-disabled": "", // an empty format will hide the module
|
||||
"format-no-fix": "No fix",
|
||||
"format-fix-3d": "{status}",
|
||||
"tooltip-format": "{mode}",
|
||||
"tooltip-format-no-fix": "{satellites_visible} satellites visible",
|
||||
"tooltip-format-fix-2d": "{satellites_used}/{satellites_visible} satellites used",
|
||||
"tooltip-format-fix-3d": "Altitude: {altitude_hae}m",
|
||||
"hide-disconnected": false
|
||||
}
|
||||
```
|
||||
# STYLE
|
||||
|
||||
- *#gps*
|
||||
- *#gps.disabled* Applied when GPS is disabled.
|
||||
- *#gps.fix-none* Applied when GPS is present, but there is no fix.
|
||||
- *#gps.fix-2d* Applied when there is a 2D fix.
|
||||
- *#gps.fix-3d* Applied when there is a 3D fix.
|
||||
+48
-100
@@ -52,7 +52,6 @@ waybar::modules::Wwan::Wwan(const std::string& id, const Json::Value& config)
|
||||
|
||||
updateCurrentModem();
|
||||
|
||||
|
||||
if (config_["hide-disconnected"].isBool()) {
|
||||
hideDisconnected = config_["hide-disconnected"].asBool();
|
||||
}
|
||||
@@ -64,9 +63,6 @@ const void waybar::modules::Wwan::updateCurrentModem(){
|
||||
|
||||
GList* modems = g_dbus_object_manager_get_objects(G_DBUS_OBJECT_MANAGER(manager));
|
||||
if (!modems) {
|
||||
spdlog::warn("No modems found");
|
||||
g_object_unref(manager);
|
||||
g_object_unref(connection);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,10 +73,11 @@ const void waybar::modules::Wwan::updateCurrentModem(){
|
||||
|
||||
if (config_["path"].isString()) {
|
||||
std::string path = config_["path"].asString();
|
||||
std::string other = mm_modem_dup_path(modem);
|
||||
std::string other = mm_modem_dup_physdev(modem);
|
||||
|
||||
if(path != other) {
|
||||
g_object_unref(modem);
|
||||
modem = nullptr;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -91,6 +88,7 @@ const void waybar::modules::Wwan::updateCurrentModem(){
|
||||
|
||||
if(imei != other) {
|
||||
g_object_unref(modem);
|
||||
modem = nullptr;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -98,51 +96,45 @@ const void waybar::modules::Wwan::updateCurrentModem(){
|
||||
current_modem = modem;
|
||||
g_list_free_full(modems, g_object_unref);
|
||||
return;
|
||||
}
|
||||
// no modems found
|
||||
g_list_free_full(modems, g_object_unref);
|
||||
}
|
||||
|
||||
const MMModemState waybar::modules::Wwan::getModemState() const {
|
||||
if(current_modem == nullptr) {
|
||||
return MMModemState::MM_MODEM_STATE_UNKNOWN;
|
||||
}
|
||||
return mm_modem_get_state(current_modem);
|
||||
// no modems found
|
||||
current_modem = nullptr;
|
||||
g_list_free_full(modems, g_object_unref);
|
||||
}
|
||||
|
||||
const std::string waybar::modules::Wwan::getModemStateString() const {
|
||||
switch (getModemState()) {
|
||||
const std::string getModemStateString(MMModem* modem) {
|
||||
switch (mm_modem_get_state(modem)) {
|
||||
case MMModemState::MM_MODEM_STATE_FAILED:
|
||||
return "Failed";
|
||||
return "Failed";
|
||||
case MMModemState::MM_MODEM_STATE_INITIALIZING:
|
||||
return "Initializing";
|
||||
return "Initializing";
|
||||
case MMModemState::MM_MODEM_STATE_LOCKED:
|
||||
return "Locked";
|
||||
return "Locked";
|
||||
case MMModemState::MM_MODEM_STATE_DISABLED:
|
||||
return "Disabled";
|
||||
return "Disabled";
|
||||
case MMModemState::MM_MODEM_STATE_DISABLING:
|
||||
return "Disabling";
|
||||
return "Disabling";
|
||||
case MMModemState::MM_MODEM_STATE_ENABLED:
|
||||
return "Enabled";
|
||||
return "Enabled";
|
||||
case MMModemState::MM_MODEM_STATE_ENABLING:
|
||||
return "Enabling";
|
||||
return "Enabling";
|
||||
case MMModemState::MM_MODEM_STATE_SEARCHING:
|
||||
return "Searching";
|
||||
return "Searching";
|
||||
case MMModemState::MM_MODEM_STATE_REGISTERED:
|
||||
return "Registered";
|
||||
return "Registered";
|
||||
case MMModemState::MM_MODEM_STATE_DISCONNECTING:
|
||||
return "Disconnecting";
|
||||
return "Disconnecting";
|
||||
case MMModemState::MM_MODEM_STATE_CONNECTING:
|
||||
return "Connecting";
|
||||
return "Connecting";
|
||||
case MMModemState::MM_MODEM_STATE_CONNECTED:
|
||||
return "Connected";
|
||||
return "Connected";
|
||||
default:
|
||||
return "Unknown";
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const std::string waybar::modules::Wwan::getModemStateFormatString() const {
|
||||
switch (getModemState()) {
|
||||
const std::string getModemStateFormatString(MMModem* modem) {
|
||||
switch (mm_modem_get_state(modem)) {
|
||||
case MMModemState::MM_MODEM_STATE_FAILED:
|
||||
return "failed";
|
||||
case MMModemState::MM_MODEM_STATE_LOCKED:
|
||||
@@ -162,17 +154,9 @@ const std::string waybar::modules::Wwan::getModemStateFormatString() const {
|
||||
}
|
||||
}
|
||||
|
||||
const int waybar::modules::Wwan::getSignalQuality() const {
|
||||
if(current_modem == nullptr) {
|
||||
return MMModemState::MM_MODEM_STATE_UNKNOWN;
|
||||
}
|
||||
const std::string getAccessTechnologiesString(MMModem* modem) {
|
||||
MMModemAccessTechnology technologies = mm_modem_get_access_technologies(modem);
|
||||
|
||||
gboolean recent;
|
||||
|
||||
return mm_modem_get_signal_quality(current_modem, &recent);
|
||||
}
|
||||
|
||||
const std::string stringifyAccessTechnologies(MMModemAccessTechnology technologies) {
|
||||
std::string buffer;
|
||||
|
||||
if(technologies & MMModemAccessTechnology::MM_MODEM_ACCESS_TECHNOLOGY_POTS)
|
||||
@@ -219,7 +203,7 @@ const std::string stringifyAccessTechnologies(MMModemAccessTechnology technologi
|
||||
|
||||
}
|
||||
|
||||
const std::string stringifyModemMode(MMModemMode mmode){
|
||||
const std::string stringifyModemMode(MMModemMode mmode) {
|
||||
|
||||
switch (mmode) {
|
||||
case MM_MODEM_MODE_CS:
|
||||
@@ -237,57 +221,33 @@ const std::string stringifyModemMode(MMModemMode mmode){
|
||||
}
|
||||
}
|
||||
|
||||
const std::string waybar::modules::Wwan::getAccessTechnologiesString() const {
|
||||
|
||||
if(current_modem == nullptr) {
|
||||
return "";
|
||||
}
|
||||
|
||||
MMModemAccessTechnology technologies = mm_modem_get_access_technologies(current_modem);
|
||||
|
||||
return stringifyAccessTechnologies(technologies);
|
||||
}
|
||||
|
||||
const MMModemModeCombination waybar::modules::Wwan::getCurrentModes() const {
|
||||
const MMModemModeCombination getCurrentModes(MMModem* modem) {
|
||||
|
||||
MMModemModeCombination combination;
|
||||
|
||||
mm_modem_get_current_modes(current_modem, &combination.allowed, &combination.preferred);
|
||||
mm_modem_get_current_modes(modem, &combination.allowed, &combination.preferred);
|
||||
|
||||
return combination;
|
||||
}
|
||||
|
||||
const std::string waybar::modules::Wwan::getPreferredModeString() const {
|
||||
const std::string getPreferredModeString(MMModem* modem) {
|
||||
|
||||
if(current_modem == nullptr) {
|
||||
return "";
|
||||
}
|
||||
|
||||
MMModemModeCombination combination = getCurrentModes();
|
||||
MMModemModeCombination combination = getCurrentModes(modem);
|
||||
|
||||
return stringifyModemMode(combination.preferred);
|
||||
}
|
||||
|
||||
|
||||
const std::string waybar::modules::Wwan::getCurrentModesString() const {
|
||||
const std::string getCurrentModesString(MMModem* modem) {
|
||||
|
||||
if(current_modem == nullptr) {
|
||||
return "";
|
||||
}
|
||||
|
||||
MMModemModeCombination combination = getCurrentModes();
|
||||
MMModemModeCombination combination = getCurrentModes(modem);
|
||||
|
||||
// TODO: fix
|
||||
return stringifyModemMode(combination.allowed);
|
||||
}
|
||||
|
||||
const std::string waybar::modules::Wwan::getPowerStateString() const {
|
||||
|
||||
if(current_modem == nullptr) {
|
||||
return "";
|
||||
}
|
||||
|
||||
MMModemPowerState state = mm_modem_get_power_state(current_modem);
|
||||
const std::string getPowerStateString(MMModem* modem) {
|
||||
MMModemPowerState state = mm_modem_get_power_state(modem);
|
||||
|
||||
switch (state) {
|
||||
case MM_MODEM_POWER_STATE_ON:
|
||||
@@ -301,22 +261,9 @@ const std::string waybar::modules::Wwan::getPowerStateString() const {
|
||||
}
|
||||
}
|
||||
|
||||
const std::string waybar::modules::Wwan::getImeiString() const {
|
||||
const std::string getOperatorNameString(MMModem* modem) {
|
||||
|
||||
if(current_modem == nullptr) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return mm_modem_dup_equipment_identifier(current_modem);
|
||||
}
|
||||
|
||||
const std::string waybar::modules::Wwan::getOperatorNameString() const {
|
||||
|
||||
if(current_modem == nullptr) {
|
||||
return "";
|
||||
}
|
||||
|
||||
MMSim* sim = mm_modem_get_sim_sync(current_modem, nullptr, nullptr);
|
||||
MMSim* sim = mm_modem_get_sim_sync(modem, nullptr, nullptr);
|
||||
|
||||
if (sim == nullptr) {
|
||||
return "No SIM";
|
||||
@@ -328,7 +275,6 @@ const std::string waybar::modules::Wwan::getOperatorNameString() const {
|
||||
}
|
||||
|
||||
auto waybar::modules::Wwan::update() -> void {
|
||||
|
||||
if (current_modem == nullptr) {
|
||||
event_box_.set_visible(false);
|
||||
updateCurrentModem();
|
||||
@@ -347,7 +293,7 @@ auto waybar::modules::Wwan::update() -> void {
|
||||
std::string tooltip_format;
|
||||
|
||||
if (!alt_) {
|
||||
std::string state = getModemStateFormatString();
|
||||
std::string state = getModemStateFormatString(current_modem);
|
||||
if (!state_.empty() && label_.get_style_context()->has_class(state_)) {
|
||||
label_.get_style_context()->remove_class(state_);
|
||||
}
|
||||
@@ -372,23 +318,22 @@ auto waybar::modules::Wwan::update() -> void {
|
||||
auto format = format_;
|
||||
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> store;
|
||||
store.push_back(fmt::arg("state", getModemStateString()));
|
||||
store.push_back(fmt::arg("state", getModemStateString(current_modem)));
|
||||
|
||||
store.push_back(fmt::arg("access_technologies", getAccessTechnologiesString()));
|
||||
store.push_back(fmt::arg("access_technologies", getAccessTechnologiesString(current_modem)));
|
||||
|
||||
store.push_back(fmt::arg("current_modes", getCurrentModesString()));
|
||||
store.push_back(fmt::arg("preferred_mode", getPreferredModeString()));
|
||||
store.push_back(fmt::arg("current_modes", getCurrentModesString(current_modem)));
|
||||
store.push_back(fmt::arg("preferred_mode", getPreferredModeString(current_modem)));
|
||||
//store.push_back(fmt::arg("supported_modes", getSupportedModesString()));
|
||||
|
||||
//store.push_back(fmt::arg("current_bands", getCurrentBandsString()));
|
||||
//store.push_back(fmt::arg("supported_bands", getSupportedBandsString()));
|
||||
|
||||
store.push_back(fmt::arg("signal_quality", getSignalQuality()));
|
||||
store.push_back(fmt::arg("power_state", getPowerStateString()));
|
||||
store.push_back(fmt::arg("imei", getImeiString()));
|
||||
store.push_back(fmt::arg("signal_quality", mm_modem_get_signal_quality(current_modem, nullptr)));
|
||||
store.push_back(fmt::arg("power_state", getPowerStateString(current_modem)));
|
||||
store.push_back(fmt::arg("imei", mm_modem_dup_equipment_identifier(current_modem)));
|
||||
|
||||
store.push_back(fmt::arg("operator_name", getOperatorNameString()));
|
||||
//store.push_back(fmt::arg("registration_state", getRegistrationStateString()));
|
||||
store.push_back(fmt::arg("operator_name", getOperatorNameString(current_modem)));
|
||||
|
||||
auto text = fmt::vformat(format, store);
|
||||
|
||||
@@ -411,4 +356,7 @@ auto waybar::modules::Wwan::update() -> void {
|
||||
}
|
||||
|
||||
waybar::modules::Wwan::~Wwan() {
|
||||
g_object_unref(current_modem);
|
||||
g_object_unref(manager);
|
||||
g_object_unref(connection);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user