Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions include/modules/wwan.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include <fmt/format.h>
#include <libmm-glib/libmm-glib.h>
#include <sys/statvfs.h>

#include <fstream>

#include "ALabel.hpp"
#include "util/format.hpp"
#include "util/sleeper_thread.hpp"

namespace waybar::modules {

class Wwan : public ALabel {
public:
Wwan(const std::string&, const Json::Value&);
virtual ~Wwan();
auto update() -> void override;

private:
void updateCurrentModem();

util::SleeperThread thread_;
std::string state_;
GDBusConnection* connection;
MMManager* manager;
MMModem* current_modem;

bool hideDisconnected = true;

const std::string dbus_name = "org.freedesktop.ModemManager1";
const std::string dbus_obj_path = "/org/freedesktop/ModemManager1/";
const std::string dbus_modems_path = "/org/freedesktop/ModemManager1/Modems/";
};

} // namespace waybar::modules
166 changes: 166 additions & 0 deletions man/waybar-wwan.5.scd
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
waybar-wwan(5) "waybar-wwan" "User Manual"

# NAME

waybar - wwan module

# DESCRIPTION

*wwan* module for ModemManager.


# FILES

$XDG_CONFIG_HOME/waybar/config ++
Per user configuration file

# ADDITIONAL FILES

libmm-glib lives in:

. /usr/lib/libmm-glib.so or /usr/lib64/libmm-glib.so
. /usr/lib/pkgconfig/libmm-glib.pc or /usr/lib64/pkgconfig/libmm-glib.pc
. /usr/include/libmm-glib

# CONFIGURATION

*format*: ++
typeof: string ++
default: *{state}* ++
The format, how information should be displayed. This format is used when other formats aren't specified.

*format-failed*: ++
typeof: string ++
This format is used when the modem cannot start.

*format-locked*: ++
typeof: string ++
This format is used when the SIM on the modem is locked.

*format-disabled*: ++
typeof: string ++
This format is used when the modem is disabled.

*format-enabled*: ++
typeof: string ++
This format is used when the modem is enabled, but isn't registered to any carrier network.

*format-searching*: ++
typeof: string ++
This format is used when the modem is looking for a carrier network to register to.

*format-registered*: ++
typeof: string ++
This format is used when the modem is registered to a network, but no data connection is active.

*format-connected*: ++
typeof: string ++
This format is used when the modem is registered to a network, and there is an active data connection.

*format-icons*: ++
typeof: array/object ++
Based on the current signal strength, the corresponding icon gets selected. ++
The order is *low* to *high*. Or by the state if it is an object.

*tooltip*: ++
typeof: bool ++
default: true ++
Option to disable tooltip on hover.

*tooltip-format*: ++
typeof: strirng ++
default: {state} ++
The format, how information should be displayed in the tooltip. This format is used when other formats aren't specified.

*tooltip-format-failed*: ++
typeof: string ++
This format is used when the modem cannot start.

*tooltip-format-locked*: ++
typeof: string ++
This format is used when the SIM on the modem is locked.

*tooltip-format-disabled*: ++
typeof: string ++
This format is used when the modem is disabled.

*tooltip-format-enabled*: ++
typeof: string ++
This format is used when the modem is enabled, but isn't registered to any carrier network.

*tooltip-format-searching*: ++
typeof: string ++
This format is used when the modem is looking for a carrier network to register to.

*tooltip-format-registered*: ++
typeof: string ++
This format is used when the modem is registered to a network, but no data connection is active.

*tooltip-format-connected*: ++
typeof: string ++
This format is used when the modem is registered to a network, and there is an active data connection.

*interval*: ++
typeof: integer ++
default: 5 ++
The interval in which the WWAN information gets polled (e.g. carrier name).

*imei*: ++
typeof: string ++
Select only the modem with the corresponding imei.

*path*: ++
typeof: string ++
Select only the modem with the corresponding hardware path.

*hide-failed*: ++
typeof: bool ++
default: true ++
Defines if the module should be hidden if the modem cannot start.

*hide-disabled*: ++
typeof: bool ++
default: false ++
Defines if the module should be hidden if the modem is disabled.

*hide-not-registered*: ++
typeof: bool ++
default: false ++
Defines if the module should be hidden if the modem isn't registered with any carrier network.


# FORMAT REPLACEMENTS

*{state}*: Modem state.

*{current_modes}*: List of all the currently active connection modes.

*{preferred_mode}*: The preferred connection mode in use.

*{signal_quality}*: Signal quality (0-100).

*{operator_name}*: Name of the network operator.

# EXAMPLES

```
"wwan": {
"format": "{state}",
"format-disabled": "", // an empty format will hide the module
"format-locked": "SIM Locked",
"format-connected": "{operator_name} {preferred_mode} | {signal_quality}%"
"tooltip-format": "{mode}",
"tooltip-format-connected": "{current_modes}",
"hide-disconnected": false
}
```
# STYLE

- *#wwan*
- *#wwan.failed* Applied when the modem cannot start.
- *#wwan.locked* Applied when the SIM on the modem is locked.
- *#wwan.disabled* Applied when the modem is disabled.
- *#wwan.enabled* Applied when the modem is enabled, but isn't registered to any carrier network.
- *#wwan.searching* Applied when the modem is looking for a carrier network to register to.
- *#wwan.registered* Applied when the modem is registered to a network, but no data connection is active.
- *#wwan.connected* Applied when the modem is registered to a network, and there is an active data connection.
11 changes: 10 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ xkbregistry = dependency('xkbregistry')
libjack = dependency('jack', required: get_option('jack'))
libwireplumber = dependency('wireplumber-0.5', required: get_option('wireplumber'))
libgps = dependency('libgps', required: get_option('gps'))
libmm_glib = dependency('libmm-glib', required: get_option('wwan'))

libsndio = compiler.find_library('sndio', required: get_option('sndio'))
if libsndio.found()
Expand Down Expand Up @@ -515,6 +516,12 @@ if libgps.found()
man_files += files('man/waybar-gps.5.scd')
endif

if libmm_glib.found()
add_project_arguments('-DHAVE_LIBMM_GLIB', language: 'cpp')
src_files += files('src/modules/wwan.cpp')
#man_files += files('man/waybar-wwan.5.scd')
endif

subdir('protocol')

app_resources = []
Expand Down Expand Up @@ -554,7 +561,9 @@ executable(
tz_dep,
xkbregistry,
cava,
libgps
libgps,
libmm_glib

],
include_directories: inc_dirs,
install: true,
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ option('cava', type: 'feature', value: 'auto', description: 'Enable support for
option('niri', type: 'boolean', description: 'Enable support for niri')
option('login-proxy', type: 'boolean', description: 'Enable interfacing with dbus login interface')
option('gps', type: 'feature', value: 'auto', description: 'Enable support for gps')
option('wwan', type: 'feature', value: 'auto', description: 'Enable support for WWAN')
8 changes: 8 additions & 0 deletions src/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
#ifdef HAVE_LIBGPS
#include "modules/gps.hpp"
#endif
#ifdef HAVE_LIBMM_GLIB
#include "modules/wwan.hpp"
#endif
#include "modules/cffi.hpp"
#include "modules/custom.hpp"
#include "modules/image.hpp"
Expand Down Expand Up @@ -355,6 +358,11 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
if (ref == "gps") {
return new waybar::modules::Gps(id, config_[name]);
}
#endif
#ifdef HAVE_LIBMM_GLIB
if (ref == "wwan") {
return new waybar::modules::Wwan(id, config_[name]);
}
#endif
if (ref == "temperature") {
return new waybar::modules::Temperature(id, config_[name]);
Expand Down
Loading
Loading