Add config value for inhibitor default state.
parent
5da45ece9d
commit
cca5227210
|
@ -20,6 +20,7 @@ class IdleInhibitor : public ALabel {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool handleToggle(GdkEventButton* const& e);
|
bool handleToggle(GdkEventButton* const& e);
|
||||||
|
void toggleStatus();
|
||||||
|
|
||||||
const Bar& bar_;
|
const Bar& bar_;
|
||||||
struct zwp_idle_inhibitor_v1* idle_inhibitor_;
|
struct zwp_idle_inhibitor_v1* idle_inhibitor_;
|
||||||
|
|
|
@ -63,6 +63,11 @@ screensaving, also known as "presentation mode".
|
||||||
typeof: double ++
|
typeof: double ++
|
||||||
Threshold to be used when scrolling.
|
Threshold to be used when scrolling.
|
||||||
|
|
||||||
|
*start-activated*: ++
|
||||||
|
typeof: bool ++
|
||||||
|
default: *false* ++
|
||||||
|
Whether the inhibit should be activated when starting waybar.
|
||||||
|
|
||||||
*timeout*: ++
|
*timeout*: ++
|
||||||
typeof: double ++
|
typeof: double ++
|
||||||
The number of minutes the inhibit should last.
|
The number of minutes the inhibit should last.
|
||||||
|
|
|
@ -16,6 +16,13 @@ waybar::modules::IdleInhibitor::IdleInhibitor(const std::string& id, const Bar&
|
||||||
throw std::runtime_error("idle-inhibit not available");
|
throw std::runtime_error("idle-inhibit not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (waybar::modules::IdleInhibitor::modules.empty()
|
||||||
|
&& config_["start-activated"].isBool()
|
||||||
|
&& config_["start-activated"].asBool() != status
|
||||||
|
) {
|
||||||
|
toggleStatus();
|
||||||
|
}
|
||||||
|
|
||||||
event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
|
event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
|
||||||
event_box_.signal_button_press_event().connect(
|
event_box_.signal_button_press_event().connect(
|
||||||
sigc::mem_fun(*this, &IdleInhibitor::handleToggle));
|
sigc::mem_fun(*this, &IdleInhibitor::handleToggle));
|
||||||
|
@ -78,8 +85,7 @@ auto waybar::modules::IdleInhibitor::update() -> void {
|
||||||
ALabel::update();
|
ALabel::update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) {
|
void waybar::modules::IdleInhibitor::toggleStatus() {
|
||||||
if (e->button == 1) {
|
|
||||||
status = !status;
|
status = !status;
|
||||||
|
|
||||||
if (timeout_.connected()) {
|
if (timeout_.connected()) {
|
||||||
|
@ -106,6 +112,11 @@ bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) {
|
||||||
},
|
},
|
||||||
timeoutSecs);
|
timeoutSecs);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) {
|
||||||
|
if (e->button == 1) {
|
||||||
|
toggleStatus();
|
||||||
|
|
||||||
// Make all other idle inhibitor modules update
|
// Make all other idle inhibitor modules update
|
||||||
for (auto const& module : waybar::modules::IdleInhibitor::modules) {
|
for (auto const& module : waybar::modules::IdleInhibitor::modules) {
|
||||||
|
|
Loading…
Reference in New Issue