Jump to content

Swayosd

From Official NixOS Wiki

SwayOSD is a OSD (On Screen Display) window for common actions such as volume, playback, and caps lock.

Installation

SwayOSD may be installed simply by adding it into your configuration like so.

❄︎ /etc/nixos/configuration.nix
environment.systemPackages = [
  pkgs.swayosd
];

Home Manager

SwayOSD has some options configurable in home manager, you may find them under Home Manger - services.swayosd.

❄︎ /etc/nixos/home.nix
services.swayosd = {
  enable = true;
  # OSD Margin from the top edge, 0.5 would be the screen center. May be from 0.0 - 1.0.
  topMargin = 0.9;
  # For a custom stylesheet file.
  #stylePath = "/etc/xdg/swayosd/style.css";
};

You will need to bind the keys to use swayosd to perform actions. For more specific configuration options check the swayosd github page. The following configuration will set up the Volume Controls, Microphone Controls, Caps Lock, Brightness, and Media Controls through swayosd.

❄︎ /etc/nixos/home.nix
wayland.windowManager.sway = {
  enable = true;
  config = {
    keybindings = {
      # Audio Volume Controls (Sink - Output)
      "XF86AudioRaiseVolume" = "exec swayosd-client --output-volume raise";
      "XF86AudioLowerVolume" = "exec swayosd-client --output-volume lower";
      "XF86AudioMute" = "exec swayosd-client --output-volume mute-toggle";
        
      # Microphone Volume Control (Source - Input)
      "XF86AudioMicMute" = "exec swayosd-client --input-volume mute-toggle";
        
      # Caps Lock
      "--release Caps_Lock" = "exec swayosd-client --caps-lock";
        
      # Brightness Controls
      "XF86MonBrightnessUp" = "exec swayosd-client --brightness raise";
      "XF86MonBrightnessDown" = "exec swayosd-client --brightness lower";
        
      # Media Player Controls
      "XF86AudioPlay" = "exec swayosd-client --playerctl play-pause";
      "XF86AudioNext" = "exec swayosd-client --playerctl next";
    };
  };
};