Skip to content

Instantly share code, notes, and snippets.

@watatomo
Created July 16, 2022 11:01
Show Gist options
  • Save watatomo/c04b03628223e17cd839baf5327e669e to your computer and use it in GitHub Desktop.
Save watatomo/c04b03628223e17cd839baf5327e669e to your computer and use it in GitHub Desktop.
# Configuration for Yasb (Yet Another Status Bar)
# Author: @denBot
# Last updated: 08/11/2021
# General Bar Configuration Notes:
# - All bars must be defined in within the `bars` section
# - Each bar configuration should be defined using a name, e.g. 'yasb-bar', 'my-awesome-bar', etc.
# - Default bar options can be found at: https://github.com/denBot/yasb/blob/main/src/core/validation/bar.py#L1-L10
# General Widget Configuration Notes:
# - ALL configured widgets must be defined in within the `widgets` section of this config file
# - Each widget configuration should be allocated a unique name, e.g. 'my-widget', 'my-custom-clock', etc.
# > This makes it easier for you to keep track of your configured widgets and add them to your bar(s)
# - Each widget should specify a widget `type` - this points to the python class of the widget you are configuring
# > For example: type: "yasb.clock.ClockWidget"
# - Each widget supports mouse event callback functionality (left, middle, right click).
# > The callbacks "do_nothing" and "exec" can be used across any widget which allows them.
# > "exec" allows you to run programs from the command-line, where each argument is separated by a space
# > "do_nothing" allows you to override default mouse events to do nothing
# > "toggle_label" *some widgets* allow you to toggle between two label formats
# - Example callbacks:
# on_left: "exec wt.exe" -- run the windows terminal when the widget is left-clicked
# on_middle: "do_nothing" -- overrides default widget middle-click behaviour to do nothing
# on_right: "exec cmd /c Taskmg" -- open the task manager when the widget is right-clicked
# bars:
# ^ a list of your bar configurations
# yasb-bar:
# ^ the name of your bar
# enabled: true
# ^ Specify if the bar configuration should be loaded by yasb
# screens: ['*']
# ^ A list of screen names which the bar should be displayed on
# Accepts: a list of screen names
# Example: [ "\\.\DISPLAY1", "eDP-1", "HDMI-1" ]
# Wildcard '*' is used to show the bar on all screens
# class_name: 'yab-bar'
# ^ The CSS class name used to style the bar and all of its children (widgets).
# alignment:
# ^ alignment options are configured here
# position: 'top' or 'bottom'
# ^ The vertical positioning of the bar on the screen
# center: false
# ^ Specify if the bar should be horizontally centered on the screen.
# window_flags:
# ^ special window flags can be enabled here
# always_on_top: false
# ^ Forces all windows of lower window levels underneath the bar (even in full-screen).
# windows_app_bar: false
# ^ Exclusively reserve the desktop workspace area behind the bar, just like the Windows Taskbar.
# dimensions:
# ^ the dimensions of the bar can be set here
# width: "100%"
# ^ The width of the bar (in percentage or pixels). Accepts: string (percentage) or positive integer (pixels) # height: 30
# ^ The height of the bar (in pixels). Accepts: positive integer (pixels e.g. 20)
# offset:
# x: 0
# ^ The x-axis positioning offset of the bar. Accepts: integer
# y: 0
# ^ The y-axis positioning offset of the bar. Accepts: integer
# widgets:
# left: []
# ^ A list of widget names to be placed on the left side of the bar. Accepts: list of strings (widget names / types)
# center: []
# ^ A list of widget names to be placed at the center of the bar. Accepts: list of strings (widget names / types)
# right: []
# ^ A list of widget names to be placed on the right side of the bar. Accepts: list of strings (widget names / types)
watch_stylesheet: true
watch_config: true
bars:
yasb-bar:
enabled: true
screens: ["*"]
class_name: "yasb-bar"
alignment:
position: "top"
center: false
blur_effect:
enabled: true
acrylic: true
dark: true
window_flags:
always_on_top: false
windows_app_bar: true
dimensions:
width: "100%"
height: 32
padding:
top: 0
left: 0
bottom: 0
right: 0
widgets:
left: ["active_window"]
center: ["clock"]
right:
[
"explorer_button",
"terminal_button",
"ip_info",
"cpu",
"memory",
"battery",
]
# widgets:
# my-clock-widget:
# type: "yasb.clock.ClockWidget"
# options:
# label: "{%H:%M:%S}"
# ^ The label format of the widget. Accepts: string with datetime format enclosed between curly brackets
# ^ Label format options: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes
# label_alt: "{%d-%m-%y %H:%M:%S}"
# ^ The alternate label format of the widget. Accepts: string with datetime format enclosed between curly brackets
# update_interval: 1000
# ^ The interval at which the widget will update itself. Accepts: positive integer (number of milliseconds)
# timezones: []
# ^ A list of timezones to switch between. Accepts: list of strings (e.g. Europe/London, America/New_York)
# ^ Options: https://timezonedb.com/time-zones ('Time Zone' strings)
# callbacks:
# on_left: "toggle_label" - toggles between the clock and alternate clock labels
# on_middle: "do_nothing"
# on_right: "next_timezone" - cycles the next timezone to be shown by the clock
# memory-widget:
# type: "yasb.memory.MemoryWidget"
# options:
# label: "\uf538 {virtual_mem_free}/{virtual_mem_total}"
# ^ The format label for the widget. Accepts: string containing any of the below format options:
# {virtual_mem_free} : The amount of free virtual memory
# {virtual_mem_percent} : The percentage of free virtual memory
# {virtual_mem_total} : The amount of total virtual memory
# {virtual_mem_avail} : The amount of total available virtual memory
# {swap_mem_free} : The amount of free swap memory
# {swap_mem_percent} : The percentage of free swal memory
# {swap_mem_total} : The amount of total swap memory
# label_alt: "\uf538 VIRT: {virtual_mem_percent}% SWAP: {swap_mem_percent}%"
# ^ The alternate format label for the widget. Accepts: string containing any of the above format options
# update_interval: 1000
# ^ The interval at which the widget will update itself. Accepts: positive integer (number of milliseconds)
# memory_thresholds: All options accept a positive integer between 0 and 100
# low: 25
# ^ The percentage at which the .status-low CSS class is applied. Accepts integer from 0 to 100
# medium: 50
# ^ The percentage at which the .status-medium CSS class is applied. Accepts integer from 0 to 100
# high: 90
# ^ The percentage at which the .status-high CSS class is applied. Accepts integer from 0 to 100
# callbacks:
# on_left: "toggle_label" - toggles between the clock and alternate clock labels
# on_middle: "do_nothing"
# on_right:" "do_nothing"
# battery-widget:
# type: "yasb.battery.BatteryWidget"
# options:
# label: "{icon}"
# ^ The format label for the widget. Accepts: string containing any of the below format options
# {percent} : The current battery percentage
# {time_remaining} : The estimated battery duration remaining
# {is_charging} : The boolean charging status
# {icon} : The battery status icon
# label_alt: "{percent}% | remaining: {time_remaining}"
# ^ The alternate format label for the widget. Accepts: string
# update_interval: 1000
# ^ The interval at which the widget will update itself. Accepts: positive integer
# charging_options:
# icon_format: "{charging_icon} {icon}"
# ^ The charging icon position relative to the battery icon. Accepts string containing {charging_icon} and {icon}
# blink_charging_icon: True
# ^ Specify if the charging icon should blink at each update interval period
# status_thresholds:
# critical: 10
# ^ The percentage at which the .status-critical CSS class is applied Accepts: integer from 0 to 100
# low: 25
# ^ The max percentage at which the .status-low CSS class is applied Accepts: integer from 0 to 100
# medium: 75
# ^ The max percentage at which the .status-medium CSS class is applied Accepts: integer from 0 to 100
# high: 95
# ^ The max percentage at which the .status-high CSS class is applied Accepts: integer from 0 to 100
# full: 100
# ^ The max percentage at which the .status-full CSS class is applied. Accepts: integer from 0 to 100
# status_icons:
# charging: "\uf0e7"
# ^ The icon shown when the battery is charging. Accepts: string
# critical: "\uf244"
# ^ The icon shown when critical battery status threshold is reached
# low: "\uf243"
# ^ The icon shown when low battery status threshold is reached
# medium: "\uf242"
# ^ The icon shown when medium status threshold is reached
# high: "\uf241"
# ^ The icon shown when high status threshold is reached
# full: "\uf240"
# ^ The icon shown when full status threshold is reached
# callbacks:
# on_left: "toggle_label" - toggles between the clock and alternate clock labels
# on_middle: "do_nothing"
# on_right: "do_nothing"
# cpu-widget:
# type: "yasb.cpu.CpuWidget"
# options:
# label: "{info[histograms][cpu_percent]}"
# ^ The format label for the widget. Accepts: string containing any of the below format options
# {info[cores][physical]} - The total number of physical cores available to the system
# {info[cores][total]} - The total number of cores available to the system
# {info[freq][min]} - The minimum possible frequency of the CPU
# {info[freq][max]} - The maximum possible frequency of the CPU
# {info[freq][current]} - The current frequency of the CPU
# {info[stats][context_switches]} - The number of context switches performed since boot
# {info[stats][interrupts] - The number of interrupts performed since boot
# {info[stats][soft_interrupts] - The number of soft interrupts performed since boot
# {info[stats][sys_calls] - The number of system calls performed since boot
# {info[histograms][cpu_freq] - A unicode histogram representation of the lat N CPU frequency readings
# {info[histograms][cpu_percent] - A unicode histogram representation of the last N CPU percent readings
# {info[histograms][cores] - A unicode histogram representation of the percentage of all system CPU cores
# label_alt: "{percent}% | remaining: {time_remaining}"
# ^ The alternate format label for the widget. Accepts: string
# update_interval: 1000
# ^ The interval at which the CPU widget will update. Accepts: positive integer
# histogram_icons:
# ^ The unicode characters used to represent CPU the frequency/percentage histogram data. Accepts: list of 9 unicode strings.
# ^ Note: the below unicode characters require the following graph bars font: https://github.com/and3rson/graph-bars-font
# - ' ' # 0%
# - '\u2581' # 10%
# - '\u2582' # 20%
# - '\u2583' # 30%
# - '\u2584' # 40%
# - '\u2585' # 50%
# - '\u2586' # 60%
# - '\u2587' # 70%
# - '\u2588' # 80%+
# histogram_num_columns: 10
# ^ The number of columns displayed for each generated histogram. Accepts: positive integer between 0 and 128.
# callbacks:
# on_left: "toggle_label" - toggles between the cpu and alternate cpu labels
# on_middle: "do_nothing"
# on_right: "do_nothing"
# active-window-widget:
# type: "yasb.active_window.ActiveWindowWidget"
# options:
# label: "{win[title]}"
# ^ The format label for the widget. Accepts: string containing any of the below {win} format options
# win[hwnd] - the hwnd of the active window
# win[event] - the event which focused the active window
# win[title] - the active window title
# win[class_name] - the active window class_name
# win[monitor_hwnd] - the hwnd of the monitor displaying the application
# win[monitor_info][rect][x,y,width,height] - the dimensions of the screen
# win[monitor_info][rect_work_area][x,y,width,height] - the dimensions of the screen work area
# win[monitor_info][flags] - the flags assocaited with the screen
# win[monitor_info][device] - the device name of the screen
# win[process][name] - the name of the active window process
# win[process][pid] - the process id of the parent process
# win[process][ppid] - the parent process id
# win[process][cpu_num] - the number of CPUs being used
# win[process][cpu_percent] - the window cpu usage in percent
# win[process][mem_percent] - the window memory usage in percent
# win[process][num_threads] - the windows number of threads in use
# win[process][username] - the username of the user executing the window process
# win[process][status] - the status of the process
# label_alt: "[class_name='{win[class_name]}' exe='{win[process][name]}' hwnd={win[hwnd]}]"
# ^ The format label for the widget. Accepts: string containing any of the above {win} format options
# label_no_window: ""
# ^ The label shown when no window is active. Accepts: string
# max_length: None
# ^ The max length of the active window label. Accepts: positive integer or None
# max_length_ellipsis: "..."
# ^ The ellipsis string used when truncating the window label if it exceeds the max length. Accepts: string
# monitor_exclusive: true
# ^ Specifies if the active window title should be shown on all bars, or exclusively for the bars on the active window screen
# ignore_window:
# class: []
# ^ A list of class_names the widget should ignore. Accepts: list of strings
# process: []
# ^ A list of process names the widget should ignore. Accepts: list of strings
# title:
# ^ A list of titles the widget should ignore. Accepts: list of strings
# callbacks:
# on_left: "toggle_label" - toggles between the clock and alternate clock labels
# on_middle: "do_nothing"
# on_right: "do_nothing"
# komorebi_workspaces:
# type: "komorebi.workspaces.WorkspacesWidget"
# options:
# label_offline: "Komorebi Offline"
# ^ The message shown when YASB cannot connect with the komorebi window manager. Accepts: string
# label_workspace_btn: "{index}"
# ^ The label format for all workspace buttons. Accepts: string.
# Format options: {name}, {index}, {monitor_index}
# label_default_name: "{index}"
# ^ The default name value used if no workspace name is set via Komorebi. Accepts: string
# Format options: {index}, {monitor_index}
# label_zero_index: false
# ^ Specifies if the workspace and monitor index values should be zero-indexed. Accepts: boolean
# hide_empty_workspaces: False
# ^ Specifies if empty workspaces should be shown in the list of komorebi workspaces. Accepts: boolean
# komorebi_active_layout:
# type: "komorebi.active_layout.ActiveLayoutWidget"
# options:
# hide_if_offline: false
# ^ Specifies if the active layout label should be shown when komorebi is offline
# label: "{icon}"
# ^ The label shown when an active layout change is detected. Accepts: string containing format options {icon} and {layout_name}
# layout_icons:
# bsp: "[\\]"
# columns: "[||]"
# rows: "[---]"
# vertical_stack: "[]="
# horizontal_stack: "H/="
# ultrawide_vertical_stack: "[|]="
# monocle: "[M]"
# maximised: "[X]"
# floating: "><>"
# paused: "|P|"
# callbacks
# ^ callback options include:
# "next_layout" - Cycles the next layout for the active workspace
# "prev_layout" - Cycles the previous layout for the active workspace
# "flip_layout" - Flips layout of active workspace. Works for BSP tiling mode only
# "toggle_tiling" - Toggles tiling of all windows for the active workspace
# "toggle_float" - Toggles floating of active window for current workspace
# "toggle_monocle" - Toggles monocle mode for active window for current workspace
# "toggle_maximise" - Toggles maximising active window for current workspace
# "toggle_pause" - Toggles pausing komorebi on/off for all workspaces
# on_left: "next_layout"
# on_middle: "toggle_monocle"
# on_right: "prev_layout"
# custom-weather-widget-example:
# type: "yasb.clock.CustomWidget"
# options:
# label: "Temperature: {data[current][temp]}°"
# ^ The format label for the custom widget. Accepts: string containing {data} format options. Required field.
# If the command executed returns a JSON structure,
# the JSON object can be used within the format label using the python dictionary string formatting syntax.
# - data = "curl.exe api.openweathermap.org/..."
# - data = {"current": {"temp":287.03, "humidity":92}, ...}
# label_alt: "Temperature: {data[current][humidity]}%"
# ^ The alternate format label for the clock. Accepts: string containing {data} format options. Required field.
# label_max_length: None
# ^ The maximum length of the label. Accepts: positive integer
# class_name: 'my-weather-widget'
# ^ The CSS class name of the custom widget. Accepts: string. Required field.
# icon:
# position: "left"
# ^ The position of the icon relative to the widget label. Accepts: string 'left' or 'right'
# label: None
# ^ The contents of the icon. Accepts: string e.g. a unicode character / emoji. Required field.
# exec_options:
# run_cmd: "curl.exe api.openweathermap.org/data/2.5/weather?q=Glasgow&units=metric&appid={YOUR_API_KEY_HERE}"
# ^ The command to be executed by the custom widget's timer event. Accepts: string of command-line arguments.
# run_once: False
# ^ Specifies that the custom widget's timer event only run once on start-up. Accepts: boolean
# run_interval: 30000
# ^ The duration in which the custom widget's timer event will fire. Accepts: positive integer (milliseconds)
# run_format: "json"
# ^ The format of the data written to stdout by the command-line program. Accepts: strings 'string' or 'json'
# callbacks:
# on_left: "toggle_label" - toggles between the clock and alternate clock labels
# on_middle: "do_nothing"
# on_right: "do_nothing"
widgets:
active_window:
type: "yasb.active_window.ActiveWindowWidget"
options:
label: "{win[title]}"
label_alt: "[class_name='{win[class_name]}' exe='{win[process][name]}' hwnd={win[hwnd]}]"
label_no_window: ""
max_length: 48
max_length_ellipsis: "..."
monitor_exclusive: true
battery:
type: "yasb.battery.BatteryWidget"
options:
time_remaining_natural: true
# label: "{icon} {percent}"
# label_alt: "remaining: {time_remaining}"
# update_interval: 1000
# charging_options:
# icon_format: "{icon}"
# blink_charging_icon: false
# status_thresholds:
# critical: 10
# low: 30
# medium: 60
# high: 80
# full: 100
# status_icons:
# charging: "\uf583"
# critical: "\uf579"
# low: "\uf57b"
# medium: "\uf57e"
# high: "\uf580"
# full: "\uf578"
# callbacks:
# on_left: "toggle_label"
# on_middle: "do_nothing"
# on_right: "do_nothing"
clock:
type: "yasb.clock.ClockWidget"
options:
label: "{%H:%M:%S %Z}"
label_alt: "{%d-%m-%y %H:%M:%S %Z}"
timezones: ["America/Los_Angeles"]
callbacks:
on_middle: "exec explorer.exe shell:Appsfolder\\Microsoft.WindowsAlarms_8wekyb3d8bbwe!App"
on_right: "next_timezone"
cpu:
type: "yasb.cpu.CpuWidget"
options:
label: "\uf824 {info[histograms][cpu_percent]}"
label_alt: "\uf824 CPU: {info[percent][total]}% | freq: {info[freq][current]:.2f} Mhz"
update_interval: 500
histogram_icons:
- '\u2581' # 0%
- '\u2581' # 10%
- '\u2582' # 20%
- '\u2583' # 30%
- '\u2584' # 40%
- '\u2585' # 50%
- '\u2586' # 60%
- '\u2587' # 70%
- '\u2588' # 80%+
histogram_num_columns: 5
memory:
type: "yasb.memory.MemoryWidget"
options:
label: "\uf85a {virtual_mem_percent}%"
label_alt: "\uf85a {virtual_mem_free}"
update_interval: 5000
callbacks:
on_right: "exec cmd /c Taskmgr"
komorebi_workspaces:
type: "komorebi.workspaces.WorkspaceWidget"
options:
label_offline: "Komorebi Offline"
label_workspace_btn: "{index}"
label_default_name: "{index}"
label_zero_index: false
hide_empty_workspaces: false
komorebi_active_layout:
type: "komorebi.active_layout.ActiveLayoutWidget"
options:
hide_if_offline: false
label: "{icon}"
layout_icons:
bsp: "[\\\\]"
columns: "[||]"
rows: "[==]"
vertical_stack: "[V]="
horizontal_stack: "[H]="
ultrawide_vertical_stack: "||="
monocle: "[M]"
maximised: "[X]"
floating: "><>"
paused: "[P]"
callbacks:
on_left: "next_layout"
on_middle: "toggle_monocle"
on_right: "prev_layout"
# Some custom widgets
explorer_button:
type: "yasb.custom.CustomWidget"
options:
label: "\uf07c"
label_alt: "Explorer"
class_name: "explorer-widget"
exec_options:
run_once: true
callbacks:
on_left: "exec explorer.exe"
on_right: "toggle_label"
ip_info:
type: "yasb.custom.CustomWidget"
options:
label: "\uf3c5 {data[city]}, {data[region]}"
label_alt: "\uf3c5 {data[ip]} [{data[country]}]"
class_name: "ip-info-widget"
exec_options:
run_cmd: "curl.exe https://ipinfo.io"
run_interval: 120000 # every 5 minutes
return_format: "json"
callbacks:
on_left: "toggle_label"
on_middle: "exec cmd /c ncpa.cpl" # open network settings
on_right: "exec cmd /c start https://ipinfo.io/{data[ip]} " # open ipinfo in browser
weather:
type: "yasb.custom.CustomWidget"
options:
label: "\uf0c2 {data[main][temp]}\u00b0c"
label_alt: "\uf0c2 {data[weather][0][description]}"
class_name: "weather-widget"
exec_options:
run_cmd: "curl.exe api.openweathermap.org/data/2.5/weather?q=Glasgow&units=metric&appid={YOUR_API_KEY_HERE}"
# run every hour
run_interval: 3600000
return_format: "json"
terminal_button:
type: "yasb.custom.CustomWidget"
options:
label: "\uf120"
label_alt: "Terminal"
class_name: "terminal-widget"
exec_options:
run_once: true
callbacks:
on_left: "exec wt.exe"
on_right: "toggle_label"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment