diff options
| author | Max Verevkin <34583604+MaxVerevkin@users.noreply.github.com> | 2023-08-26 17:19:29 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-26 17:19:29 +0300 |
| commit | 85f837ae706d6f64769597158a39c49259c8b189 (patch) | |
| tree | cc3c58c9fdfc42454e85b98372bb9ab5eb496e24 /src/wm_info_provider/river.rs | |
| parent | 6aeb76407a30309326a04b29d19e5390a4b96248 (diff) | |
| download | i3bar-mango-85f837ae706d6f64769597158a39c49259c8b189.tar.gz | |
show current mode on river (can be turned off) (#15)
Diffstat (limited to 'src/wm_info_provider/river.rs')
| -rw-r--r-- | src/wm_info_provider/river.rs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/wm_info_provider/river.rs b/src/wm_info_provider/river.rs index c9778bc..e9904bd 100644 --- a/src/wm_info_provider/river.rs +++ b/src/wm_info_provider/river.rs @@ -11,6 +11,7 @@ pub struct RiverInfoProvider { control: ZriverControlV1, output_statuses: Vec<OutputStatus>, max_tag: u8, + seat_status: SeatStatus, } struct OutputStatus { @@ -22,17 +23,32 @@ struct OutputStatus { layout_name: Option<String>, } +struct SeatStatus { + _status: ZriverSeatStatusV1, + mode: Option<String>, +} + impl RiverInfoProvider { pub fn bind( conn: &mut Connection<State>, globals: &Globals, config: &WmConfig, ) -> Option<Self> { + let status_manager = globals.bind(conn, 1..=4).ok()?; + let wl_seat: WlSeat = globals.bind(conn, ..).ok()?; // river supports just one seat Some(Self { - status_manager: globals.bind(conn, 1..=4).ok()?, + status_manager, control: globals.bind(conn, 1..=1).ok()?, output_statuses: Vec::new(), max_tag: config.river.max_tag, + seat_status: SeatStatus { + _status: status_manager.get_river_seat_status_with_cb( + conn, + wl_seat, + seat_status_cb, + ), + mode: None, + }, }) } } @@ -81,6 +97,10 @@ impl WmInfoProvider for RiverInfoProvider { status.layout_name.clone() } + fn get_mode_name(&self, _output: WlOutput) -> Option<String> { + self.seat_status.mode.clone() + } + fn click_on_tag( &mut self, conn: &mut Connection<State>, @@ -149,6 +169,20 @@ fn output_status_cb( } } +fn seat_status_cb( + conn: &mut Connection<State>, + state: &mut State, + _: ZriverSeatStatusV1, + event: zriver_seat_status_v1::Event, +) { + if let zriver_seat_status_v1::Event::Mode(mode) = event { + let river = state.shared_state.get_river().unwrap(); + let mode = mode.to_string_lossy().into_owned(); + river.seat_status.mode = (mode != "normal").then_some(mode); + state.mode_name_updated(conn, None); + } +} + fn river_command_cb( conn: &mut Connection<State>, state: &mut State, |
