1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-04-19 19:34:24 +02:00

chore: refactors to volume pr #460 i forgot

whoops
This commit is contained in:
Jake Stanger 2024-03-04 20:20:36 +00:00
parent 3c7e434e52
commit 660dc81e7d
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
7 changed files with 207 additions and 181 deletions

View file

@ -4,7 +4,7 @@ the default playback device, and control application volume levels individually.
This requires PulseAudio to function (`pipewire-pulse` is supported). This requires PulseAudio to function (`pipewire-pulse` is supported).
TODO: Screenshot [!The volume widget, with its popup open. A single stream is playing audio.](https://f.jstanger.dev/github/ironbar/volume.png)
## Configuration ## Configuration

View file

@ -1,30 +1,67 @@
{ {
"anchor_to_edges": true, "anchor_to_edges": true,
"position": "bottom",
"icon_theme": "Paper",
"start": [
{
"type": "workspaces",
"all_monitors": false,
"name_map": {
"1": "󰙯",
"2": "icon:firefox",
"3": "",
"Games": "icon:steam",
"Code": ""
}
},
{
"type": "launcher",
"favorites": [
"firefox",
"discord",
"steam"
],
"show_names": false,
"show_icons": true
},
{
"type": "label",
"label": "random num: {{500:echo FIXME}}"
}
],
"end": [ "end": [
{ {
"type": "music",
"player_type": "mpd",
"music_dir": "/home/jake/Music", "music_dir": "/home/jake/Music",
"player_type": "mpd",
"truncate": { "truncate": {
"max_length": 100, "mode": "end",
"mode": "end" "max_length": 100
}, }
"type": "music"
}, },
{ {
"host": "chloe:6600", "type": "music",
"player_type": "mpd", "player_type": "mpd",
"truncate": "end", "host": "chloe:6600",
"type": "music" "truncate": "end"
}, },
{ {
"type": "script",
"cmd": "/home/jake/bin/phone-battery", "cmd": "/home/jake/bin/phone-battery",
"show_if": { "show_if": {
"cmd": "/home/jake/bin/phone-connected", "cmd": "/home/jake/bin/phone-connected",
"interval": 500 "interval": 500
}, }
"type": "script"
}, },
{ {
"type": "sys_info",
"interval": {
"memory": 30,
"cpu": 1,
"temps": 5,
"disks": 300,
"networks": 3
},
"format": [ "format": [
" {cpu_percent}% | {temp_c:k10temp_Tccd1}°C", " {cpu_percent}% | {temp_c:k10temp_Tccd1}°C",
" {memory_used} / {memory_total} GB ({memory_percent}%)", " {memory_used} / {memory_total} GB ({memory_percent}%)",
@ -33,103 +70,77 @@
"󰓢 {net_down:enp39s0} / {net_up:enp39s0} Mbps", "󰓢 {net_down:enp39s0} / {net_up:enp39s0} Mbps",
"󰖡 {load_average:1} | {load_average:5} | {load_average:15}", "󰖡 {load_average:1} | {load_average:5} | {load_average:15}",
"󰥔 {uptime}" "󰥔 {uptime}"
], ]
"interval": {
"cpu": 1,
"disks": 300,
"memory": 30,
"networks": 3,
"temps": 5
},
"type": "sys_info"
}, },
{ {
"type": "volume",
"format": "{icon} {volume}%",
"max_volume": 100,
"icons": {
"volume_high": "󰕾",
"volume_medium": "󰖀",
"volume_low": "󰕿",
"muted": "󰝟"
}
},
{
"type": "clipboard",
"max_items": 3, "max_items": 3,
"truncate": { "truncate": {
"length": 50, "mode": "end",
"mode": "end" "length": 50
}, }
"type": "clipboard"
}, },
{ {
"type": "custom",
"class": "power-menu",
"bar": [ "bar": [
{ {
"label": "", "type": "button",
"name": "power-btn", "name": "power-btn",
"on_click": "popup:toggle", "label": "",
"type": "button" "on_click": "popup:toggle"
} }
], ],
"class": "power-menu",
"popup": [ "popup": [
{ {
"orientation": "vertical",
"type": "box", "type": "box",
"orientation": "vertical",
"widgets": [ "widgets": [
{ {
"label": "Power menu", "type": "label",
"name": "header", "name": "header",
"type": "label" "label": "Power menu"
}, },
{ {
"type": "box", "type": "box",
"widgets": [ "widgets": [
{ {
"type": "button",
"class": "power-btn", "class": "power-btn",
"label": "<span font-size='40pt'></span>", "label": "<span font-size='40pt'></span>",
"on_click": "!shutdown now", "on_click": "!shutdown now"
"type": "button"
}, },
{ {
"type": "button",
"class": "power-btn", "class": "power-btn",
"label": "<span font-size='40pt'></span>", "label": "<span font-size='40pt'></span>",
"on_click": "!reboot", "on_click": "!reboot"
"type": "button"
} }
] ]
}, },
{ {
"label": "Uptime: {{30000:uptime -p | cut -d ' ' -f2-}}", "type": "label",
"name": "uptime", "name": "uptime",
"type": "label" "label": "Uptime: {{30000:uptime -p | cut -d ' ' -f2-}}"
} }
] ]
} }
], ],
"tooltip": "Up: {{30000:uptime -p | cut -d ' ' -f2-}}", "tooltip": "Up: {{30000:uptime -p | cut -d ' ' -f2-}}"
"type": "custom"
}, },
{ {
"type": "clock" "type": "clock"
} }
],
"icon_theme": "Paper",
"position": "bottom",
"start": [
{
"all_monitors": false,
"name_map": {
"1": "󰙯",
"2": "icon:firefox",
"3": "",
"Code": "",
"Games": "icon:steam"
},
"type": "workspaces"
},
{
"favorites": [
"firefox",
"discord",
"steam"
],
"show_icons": true,
"show_names": false,
"type": "launcher"
},
{
"label": "random num: {{500:echo FIXME}}",
"type": "label"
}
] ]
} }

View file

@ -1,31 +1,57 @@
anchor_to_edges = true anchor_to_edges = true
icon_theme = "Paper"
position = "bottom" position = "bottom"
icon_theme = "Paper"
[[start]]
type = "workspaces"
all_monitors = false
[start.name_map]
1 = "󰙯"
2 = "icon:firefox"
3 = ""
Games = "icon:steam"
Code = ""
[[start]]
type = "launcher"
favorites = [
"firefox",
"discord",
"steam",
]
show_names = false
show_icons = true
[[start]]
type = "label"
label = "random num: {{500:echo FIXME}}"
[[end]] [[end]]
music_dir = "/home/jake/Music"
player_type = "mpd"
type = "music" type = "music"
player_type = "mpd"
music_dir = "/home/jake/Music"
[end.truncate] [end.truncate]
max_length = 100
mode = "end" mode = "end"
max_length = 100
[[end]] [[end]]
host = "chloe:6600"
player_type = "mpd"
truncate = "end"
type = "music" type = "music"
player_type = "mpd"
host = "chloe:6600"
truncate = "end"
[[end]] [[end]]
cmd = "/home/jake/bin/phone-battery"
type = "script" type = "script"
cmd = "/home/jake/bin/phone-battery"
[end.show_if] [end.show_if]
cmd = "/home/jake/bin/phone-connected" cmd = "/home/jake/bin/phone-connected"
interval = 500 interval = 500
[[end]] [[end]]
type = "sys_info"
format = [ format = [
" {cpu_percent}% | {temp_c:k10temp_Tccd1}°C", " {cpu_percent}% | {temp_c:k10temp_Tccd1}°C",
" {memory_used} / {memory_total} GB ({memory_percent}%)", " {memory_used} / {memory_total} GB ({memory_percent}%)",
@ -35,88 +61,73 @@ format = [
"󰖡 {load_average:1} | {load_average:5} | {load_average:15}", "󰖡 {load_average:1} | {load_average:5} | {load_average:15}",
"󰥔 {uptime}", "󰥔 {uptime}",
] ]
type = "sys_info"
[end.interval] [end.interval]
cpu = 1
disks = 300
memory = 30 memory = 30
networks = 3 cpu = 1
temps = 5 temps = 5
disks = 300
networks = 3
[[end]]
type = "volume"
format = "{icon} {volume}%"
max_volume = 100
[end.icons]
volume_high = "󰕾"
volume_medium = "󰖀"
volume_low = "󰕿"
muted = "󰝟"
[[end]] [[end]]
max_items = 3
type = "clipboard" type = "clipboard"
max_items = 3
[end.truncate] [end.truncate]
length = 50
mode = "end" mode = "end"
length = 50
[[end]] [[end]]
type = "custom"
class = "power-menu" class = "power-menu"
tooltip = "Up: {{30000:uptime -p | cut -d ' ' -f2-}}" tooltip = "Up: {{30000:uptime -p | cut -d ' ' -f2-}}"
type = "custom"
[[end.bar]] [[end.bar]]
label = ""
name = "power-btn"
on_click = "popup:toggle"
type = "button" type = "button"
name = "power-btn"
label = ""
on_click = "popup:toggle"
[[end.popup]] [[end.popup]]
orientation = "vertical"
type = "box" type = "box"
orientation = "vertical"
[[end.popup.widgets]] [[end.popup.widgets]]
label = "Power menu"
name = "header"
type = "label" type = "label"
name = "header"
label = "Power menu"
[[end.popup.widgets]] [[end.popup.widgets]]
type = "box" type = "box"
[[end.popup.widgets.widgets]] [[end.popup.widgets.widgets]]
type = "button"
class = "power-btn" class = "power-btn"
label = "<span font-size='40pt'></span>" label = "<span font-size='40pt'></span>"
on_click = "!shutdown now" on_click = "!shutdown now"
type = "button"
[[end.popup.widgets.widgets]] [[end.popup.widgets.widgets]]
type = "button"
class = "power-btn" class = "power-btn"
label = "<span font-size='40pt'></span>" label = "<span font-size='40pt'></span>"
on_click = "!reboot" on_click = "!reboot"
type = "button"
[[end.popup.widgets]] [[end.popup.widgets]]
label = "Uptime: {{30000:uptime -p | cut -d ' ' -f2-}}"
name = "uptime"
type = "label" type = "label"
name = "uptime"
label = "Uptime: {{30000:uptime -p | cut -d ' ' -f2-}}"
[[end]] [[end]]
type = "clock" type = "clock"
[[start]]
all_monitors = false
type = "workspaces"
[start.name_map]
1 = "󰙯"
2 = "icon:firefox"
3 = ""
Code = ""
Games = "icon:steam"
[[start]]
favorites = [
"firefox",
"discord",
"steam",
]
show_icons = true
show_names = false
type = "launcher"
[[start]]
label = "random num: {{500:echo FIXME}}"
type = "label"

View file

@ -1,21 +1,48 @@
anchor_to_edges: true anchor_to_edges: true
position: bottom
icon_theme: Paper
start:
- type: workspaces
all_monitors: false
name_map:
'1': 󰙯
'2': icon:firefox
'3':
Games: icon:steam
Code:
- type: launcher
favorites:
- firefox
- discord
- steam
show_names: false
show_icons: true
- type: label
label: 'random num: {{500:echo FIXME}}'
end: end:
- music_dir: /home/jake/Music - type: music
player_type: mpd player_type: mpd
music_dir: /home/jake/Music
truncate: truncate:
max_length: 100
mode: end mode: end
type: music max_length: 100
- host: chloe:6600 - type: music
player_type: mpd player_type: mpd
host: chloe:6600
truncate: end truncate: end
type: music - type: script
- cmd: /home/jake/bin/phone-battery cmd: /home/jake/bin/phone-battery
show_if: show_if:
cmd: /home/jake/bin/phone-connected cmd: /home/jake/bin/phone-connected
interval: 500 interval: 500
type: script - type: sys_info
- format: interval:
memory: 30
cpu: 1
temps: 5
disks: 300
networks: 3
format:
-  {cpu_percent}% | {temp_c:k10temp_Tccd1}°C -  {cpu_percent}% | {temp_c:k10temp_Tccd1}°C
-  {memory_used} / {memory_total} GB ({memory_percent}%) -  {memory_used} / {memory_total} GB ({memory_percent}%)
- '| {swap_used} / {swap_total} GB ({swap_percent}%)' - '| {swap_used} / {swap_total} GB ({swap_percent}%)'
@ -23,65 +50,46 @@ end:
- 󰓢 {net_down:enp39s0} / {net_up:enp39s0} Mbps - 󰓢 {net_down:enp39s0} / {net_up:enp39s0} Mbps
- 󰖡 {load_average:1} | {load_average:5} | {load_average:15} - 󰖡 {load_average:1} | {load_average:5} | {load_average:15}
- 󰥔 {uptime} - 󰥔 {uptime}
interval: - type: volume
cpu: 1 format: '{icon} {volume}%'
disks: 300 max_volume: 100
memory: 30 icons:
networks: 3 volume_high: 󰕾
temps: 5 volume_medium: 󰖀
type: sys_info volume_low: 󰕿
- max_items: 3 muted: 󰝟
- type: clipboard
max_items: 3
truncate: truncate:
length: 50
mode: end mode: end
type: clipboard length: 50
- bar: - type: custom
- label:
name: power-btn
on_click: popup:toggle
type: button
class: power-menu class: power-menu
bar:
- type: button
name: power-btn
label:
on_click: popup:toggle
popup: popup:
- orientation: vertical - type: box
type: box orientation: vertical
widgets: widgets:
- label: Power menu - type: label
name: header name: header
type: label label: Power menu
- type: box - type: box
widgets: widgets:
- class: power-btn - type: button
class: power-btn
label: <span font-size='40pt'></span> label: <span font-size='40pt'></span>
on_click: '!shutdown now' on_click: '!shutdown now'
type: button - type: button
- class: power-btn class: power-btn
label: <span font-size='40pt'></span> label: <span font-size='40pt'></span>
on_click: '!reboot' on_click: '!reboot'
type: button - type: label
- label: 'Uptime: {{30000:uptime -p | cut -d '' '' -f2-}}'
name: uptime name: uptime
type: label label: 'Uptime: {{30000:uptime -p | cut -d '' '' -f2-}}'
tooltip: 'Up: {{30000:uptime -p | cut -d '' '' -f2-}}' tooltip: 'Up: {{30000:uptime -p | cut -d '' '' -f2-}}'
type: custom
- type: clock - type: clock
icon_theme: Paper
position: bottom
start:
- all_monitors: false
name_map:
'1': 󰙯
'2': icon:firefox
'3':
Code:
Games: icon:steam
type: workspaces
- favorites:
- firefox
- discord
- steam
show_icons: true
show_names: false
type: launcher
- label: 'random num: {{500:echo FIXME}}'
type: label

View file

@ -1,7 +1,7 @@
mod sink; mod sink;
mod sink_input; mod sink_input;
use crate::{arc_mut, lock, register_client, send, spawn_blocking}; use crate::{arc_mut, lock, register_client, send, spawn_blocking, APP_ID};
use libpulse_binding::callbacks::ListResult; use libpulse_binding::callbacks::ListResult;
use libpulse_binding::context::introspect::{Introspector, ServerInfo}; use libpulse_binding::context::introspect::{Introspector, ServerInfo};
use libpulse_binding::context::subscribe::{Facility, InterestMaskSet, Operation}; use libpulse_binding::context::subscribe::{Facility, InterestMaskSet, Operation};
@ -88,10 +88,7 @@ impl Client {
return; return;
}; };
if proplist if proplist.set_str("APPLICATION_NAME", APP_ID).is_err() {
.set_str("APPLICATION_NAME", "dev.jstanger.ironbar")
.is_err()
{
error!("Failed to update PA proplist"); error!("Failed to update PA proplist");
} }

View file

@ -57,7 +57,7 @@ mod popup;
mod script; mod script;
mod style; mod style;
const GTK_APP_ID: &str = "dev.jstanger.ironbar"; pub const APP_ID: &str = "dev.jstanger.ironbar";
const VERSION: &str = env!("CARGO_PKG_VERSION"); const VERSION: &str = env!("CARGO_PKG_VERSION");
fn main() { fn main() {
@ -111,7 +111,7 @@ impl Ironbar {
info!("Ironbar version {}", VERSION); info!("Ironbar version {}", VERSION);
info!("Starting application"); info!("Starting application");
let app = Application::builder().application_id(GTK_APP_ID).build(); let app = Application::builder().application_id(APP_ID).build();
let running = AtomicBool::new(false); let running = AtomicBool::new(false);

View file

@ -1,5 +1,4 @@
use crate::clients::volume; use crate::clients::volume::{self, Event};
use crate::clients::volume::Event;
use crate::config::CommonConfig; use crate::config::CommonConfig;
use crate::gtk_helpers::IronbarGtkExt; use crate::gtk_helpers::IronbarGtkExt;
use crate::modules::{ use crate::modules::{