aboutsummaryrefslogtreecommitdiff
path: root/i3blocks/i3flags.sh
blob: 8d18ca046a0ac51840ba930b970df30200b4d8d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash

# i3Flags.sh
#
# Usage: i3Flags.sh [COMMAND]...
#
# Outputs a line for each of a list of programs, showing if it is executing.
# pgrep -x is used for the name matching, so command names must be exact.
# Uses a default list of programs if none is provided.

#case $BLOCK_BUTTON in
#	1) # Left click
#	2) # Middle click
#	3) # Right click
#esac

if [ -z "$1" ]; then
	programs="picom dunst"
else
	programs="$*"
fi
flags=""

for program in $programs; do
	if [ -n "$(pgrep -x "$program")" ]; then
		flag="$(echo "${program:0:1}" | awk '{print toupper($1)}')"
		flags="${flags}${flag}"
	else
		flags="${flags}-"
	fi
done

echo "$flags"