Unix3r

Build. Break. Learn. Repeat.

Starting0%
Skip to content

unix3r/dotfiles

Public
main
U Unix3r Initial commit: sway + waybar dotfiles (Catppuccin Mocha) eb290df
22 lines · 880 B Raw History
1#!/usr/bin/env bash
2# Shared helpers for the sway scripts. Source it, don't run it.
3
4has() { command -v "$1" >/dev/null 2>&1; }
5
6# notify <id-key> <icon> <summary> [body] [progress 0-100]
7# Re-uses the same notification bubble for the same <id-key>
8# so volume/brightness pop-ups replace each other instead of stacking.
9notify() {
10 has notify-send || return 0
11 local key=$1 icon=$2 summary=$3 body=${4:-} value=${5:-}
12 local idfile="${XDG_RUNTIME_DIR:-/tmp}/dotfiles-notify-$key"
13 local args=(-a "sway" -i "$icon" -t 1500 -p)
14 [[ -n $value ]] && args+=(-h "int:value:$value")
15 [[ -s $idfile ]] && args+=(-r "$(cat "$idfile")")
16 notify-send "${args[@]}" "$summary" "$body" >"$idfile" 2>/dev/null || true
17}
18
19# menu <prompt> — wofi in dmenu mode, reads choices from stdin
20menu() {
21 wofi --dmenu --insensitive --prompt "$1" --cache-file /dev/null "${@:2}"
22}