yambar/examples/configurations/laptop.conf
Daniel Eklöf 6c10eb2153
module/alsa: use channel’s dB range instead of raw volume, if available
For channels that have a defined dB range, use that instead of the raw
volume range when calculating the volume percent.

Also use the same logic as alsamixer when calculating the percent from
the dB values: assume a linear scale if the dB range is “small
enough”, and otherwise normalize it against a logarithmic scale.

With this, yambar’s “percent” value matches alsamixer’s exactly.

The ‘volume’ tag remains unchanged - it always reflects the raw volume
values.

Instead, we add a new tag ‘dB’, that reflects the dB values.

Closes #202
2022-06-21 19:49:06 +02:00

287 lines
11 KiB
Text

# Typical laptop setup, with wifi, brightness, battery etc, for
# i3/Sway.
# For X11/i3, you'll want to replace calls to swaymsg with i3-msg, and
# the sway-xkb module with the xkb module.
# fonts we'll be re-using here and there
awesome: &awesome Font Awesome 5 Free:style=solid:pixelsize=14
awesome_brands: &awesome_brands Font Awesome 5 Brands:pixelsize=16
std_underline: &std_underline {underline: { size: 2, color: ff0000ff}}
# This is THE bar configuration
bar:
height: 26
location: top
spacing: 5
margin: 7
# Default font
font: Adobe Helvetica:pixelsize=12
foreground: ffffffff
background: 111111cc
border:
width: 1
color: 999999cc
margin: 5
top-margin: 0
left:
- i3:
anchors: # Not used (directly) by f00bar; used here to avoid duplication
- string: &i3_common {margin: 5, on-click: "swaymsg --quiet workspace {name}"}
- string: &default {<<: *i3_common, text: "? {name}"}
- string: &main {<<: *i3_common, text: , font: *awesome}
- string: &surfing {<<: *i3_common, text: , font: *awesome_brands}
- string: &misc {<<: *i3_common, text: , font: *awesome}
- string: &mail {<<: *i3_common, text: , font: *awesome}
- string: &music {<<: *i3_common, text: , font: *awesome}
- focused: &focused
deco: {stack: [background: {color: ffa0a04c}, <<: *std_underline]}
- invisible: &invisible {foreground: ffffff55}
- urgent: &urgent
foreground: 000000ff
deco: {stack: [background: {color: bc2b3fff}, <<: *std_underline]}
- map: &i3_mode
default:
- string:
margin: 5
text: "{mode}"
deco: {background: {color: cc421dff}}
- empty: {right-margin: 7}
conditions:
mode == default: {empty: {}}
content:
"":
map:
conditions:
state == focused: {string: {<<: [*default, *focused]}}
state == unfocused: {string: {<<: *default}}
state == invisible: {string: {<<: [*default, *invisible]}}
state == urgent: {string: {<<: [*default, *urgent]}}
main:
map:
conditions:
state == focused: {string: {<<: [*main, *focused]}}
state == unfocused: {string: {<<: *main}}
state == invisible: {string: {<<: [*main, *invisible]}}
state == urgent: {string: {<<: [*main, *urgent]}}
surfing:
map:
conditions:
state == focused: {string: {<<: [*surfing, *focused]}}
state == unfocused: {string: {<<: *surfing}}
state == invisible: {string: {<<: [*surfing, *invisible]}}
state == urgent: {string: {<<: [*surfing, *urgent]}}
misc:
map:
conditions:
state == focused: {string: {<<: [*misc, *focused]}}
state == unfocused: {string: {<<: *misc}}
state == invisible: {string: {<<: [*misc, *invisible]}}
state == urgent: {string: {<<: [*misc, *urgent]}}
mail:
map:
conditions:
state == focused: {string: {<<: [*mail, *focused]}}
state == unfocused: {string: {<<: *mail}}
state == invisible: {string: {<<: [*mail, *invisible]}}
state == urgent: {string: {<<: [*mail, *urgent]}}
music:
map:
conditions:
state == focused: {string: {<<: [*music, *focused]}}
state == unfocused: {string: {<<: *music}}
state == invisible: {string: {<<: [*music, *invisible]}}
state == urgent: {string: {<<: [*music, *urgent]}}
- foreign-toplevel:
content:
map:
conditions:
~activated: {empty: {}}
activated:
- string: {text: "{app-id}", foreground: ffa0a0ff}
- string: {text: ": {title}"}
center:
- mpd:
host: /run/mpd/socket
anchors:
list: &artist_album_title
spacing: 0
items:
- map:
conditions:
state == playing: {string: {text: "{artist}"}}
state == paused: {string: {text: "{artist}", foreground: ffffff66}}
- string: {text: " | ", foreground: ffffff66}
- map:
conditions:
state == playing: {string: {text: "{album}"}}
state == paused: {string: {text: "{album}", foreground: ffffff66}}
- string: {text: " | ", foreground: ffffff66}
- map:
conditions:
state == playing: {string: {text: "{title}", foreground: ffa0a0ff}}
state == paused: {string: {text: "{title}", foreground: ffffff66}}
content:
map:
margin: 10
conditions:
state == offline: {string: {text: offline, foreground: ff0000ff}}
state == stopped: {string: {text: stopped}}
state == paused: {list: *artist_album_title}
state == playing: {list: *artist_album_title}
right:
- removables:
anchors:
drive: &drive { text: , font: *awesome}
optical: &optical {text: , font: *awesome}
spacing: 5
content:
map:
conditions:
~mounted:
map:
on-click: udisksctl mount -b {device}
conditions:
~optical: [{string: *drive}, {string: {text: "{label}"}}]
optical: [{string: *optical}, {string: {text: "{label}"}}]
mounted:
map:
on-click: udisksctl unmount -b {device}
conditions:
~optical:
- string: {<<: *drive, deco: *std_underline}
- string: {text: "{label}"}
optical:
- string: {<<: *optical, deco: *std_underline}
- string: {text: "{label}"}
- sway-xkb:
identifiers: [1:1:AT_Translated_Set_2_keyboard]
content:
- string: {text: , font: *awesome}
- string: {text: "{layout}"}
- network:
name: enp1s0
content:
map:
conditions:
~carrier: {empty: {}}
carrier:
map:
default: {string: {text: , font: *awesome, foreground: ffffff66}}
conditions:
state == up:
map:
default: {string: {text: , font: *awesome}}
conditions:
ipv4 == "": {string: {text: , font: *awesome, foreground: ffffff66}}
- network:
name: wlp2s0
poll-interval: 1
content:
map:
default: {string: {text: , font: *awesome, foreground: ffffff66}}
conditions:
state == down: {string: {text: , font: *awesome, foreground: ff0000ff}}
state == up:
map:
default:
- string: {text: , font: *awesome}
- string: {text: "{ssid} {dl-speed:mb}/{ul-speed:mb} Mb/s"}
conditions:
ipv4 == "":
- string: {text: , font: *awesome, foreground: ffffff66}
- string: {text: "{ssid} {dl-speed:mb}/{ul-speed:mb} Mb/s", foreground: ffffff66}
- alsa:
card: hw:PCH
mixer: Master
content:
map:
conditions:
~online: {string: {text: , font: *awesome, foreground: ff0000ff}}
online:
map:
on-click: /bin/sh -c "amixer -q sset Speaker unmute && amixer -q sset Headphone unmute && amixer -q sset Master toggle"
conditions:
muted: {string: {text: , font: *awesome, foreground: ffffff66}}
~muted:
ramp:
tag: percent
items:
- string: {text: , font: *awesome}
- string: {text: , font: *awesome}
- string: {text: , font: *awesome}
- backlight:
name: intel_backlight
content: [ string: {text: , font: *awesome}, string: {text: "{percent}%"}]
- battery:
name: BAT0
poll-interval: 30
anchors:
discharging: &discharging
list:
items:
- ramp:
tag: capacity
items:
- string: {text: , foreground: ff0000ff, font: *awesome}
- string: {text: , foreground: ffa600ff, font: *awesome}
- string: {text: , font: *awesome}
- string: {text: , font: *awesome}
- string: {text: , font: *awesome}
- string: {text: , font: *awesome}
- string: {text: , font: *awesome}
- string: {text: , font: *awesome}
- string: {text: , font: *awesome}
- string: {text: , foreground: 00ff00ff, font: *awesome}
- string: {text: "{capacity}% {estimate}"}
content:
map:
conditions:
state == unknown:
<<: *discharging
state == discharging:
<<: *discharging
state == charging:
- string: {text: , foreground: 00ff00ff, font: *awesome}
- string: {text: "{capacity}% {estimate}"}
state == full:
- string: {text: , foreground: 00ff00ff, font: *awesome}
- string: {text: "{capacity}% full"}
state == not charging:
- ramp:
tag: capacity
items:
- string: {text:  , foreground: ff0000ff, font: *awesome}
- string: {text:  , foreground: ffa600ff, font: *awesome}
- string: {text:  , foreground: 00ff00ff, font: *awesome}
- string: {text:  , foreground: 00ff00ff, font: *awesome}
- string: {text:  , foreground: 00ff00ff, font: *awesome}
- string: {text:  , foreground: 00ff00ff, font: *awesome}
- string: {text:  , foreground: 00ff00ff, font: *awesome}
- string: {text:  , foreground: 00ff00ff, font: *awesome}
- string: {text:  , foreground: 00ff00ff, font: *awesome}
- string: {text:  , foreground: 00ff00ff, font: *awesome}
- string: {text: "{capacity}%"}
- clock:
time-format: "%H:%M %Z"
content:
- string: {text: , font: *awesome}
- string: {text: "{date}", right-margin: 5}
- string: {text: , font: *awesome}
- string: {text: "{time}"}
- label:
content:
string:
on-click: systemctl poweroff
text: 
font: *awesome