Back to dmenu.
This commit is contained in:
parent
0ba9df8d5e
commit
6a14afdb8e
6 changed files with 16 additions and 28 deletions
|
@ -4,7 +4,7 @@
|
||||||
mkdir -p ~/.config ~/.local/bin ~/.local/settings
|
mkdir -p ~/.config ~/.local/bin ~/.local/settings
|
||||||
|
|
||||||
# link config
|
# link config
|
||||||
for i in dunst fontconfig rofi zathura; do
|
for i in dunst fontconfig zathura; do
|
||||||
rm -rf ~/.config/${i}
|
rm -rf ~/.config/${i}
|
||||||
ln -sf ~/.local/repos/dotfiles/_desktop/${i} ~/.config
|
ln -sf ~/.local/repos/dotfiles/_desktop/${i} ~/.config
|
||||||
done
|
done
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
div="----------"
|
div="----------"
|
||||||
|
|
||||||
set_output() {
|
set_output() {
|
||||||
sel_sink=$(printf "$sinks\\n$div\\nback\\nexit" | rofi -dmenu -l 10 -i -p "sink")
|
sel_sink=$(printf "$sinks\\n$div\\nback\\nexit" | dmenu -l 10 -i -p "sink")
|
||||||
case "$sel_sink" in
|
case "$sel_sink" in
|
||||||
back) show_current ;;
|
back) show_current ;;
|
||||||
exit) exit ;;
|
exit) exit ;;
|
||||||
|
@ -14,7 +14,7 @@ set_output() {
|
||||||
}
|
}
|
||||||
|
|
||||||
set_input() {
|
set_input() {
|
||||||
sel_source=$(printf "$sources\\n$div\\nBluetooth profile\\n$div\\nback\\nexit" | rofi -dmenu -l 10 -i -p "source")
|
sel_source=$(printf "$sources\\n$div\\nBluetooth profile\\n$div\\nback\\nexit" | dmenu -l 10 -i -p "source")
|
||||||
case "$sel_source" in
|
case "$sel_source" in
|
||||||
back) show_current ;;
|
back) show_current ;;
|
||||||
exit) exit ;;
|
exit) exit ;;
|
||||||
|
@ -29,7 +29,7 @@ set_bt_profile() {
|
||||||
bt_sink=$(pactl list cards | awk -F'"' '/device.name.*bluez/ {print $2}')
|
bt_sink=$(pactl list cards | awk -F'"' '/device.name.*bluez/ {print $2}')
|
||||||
[ -z "${bt_sink}" ] &&
|
[ -z "${bt_sink}" ] &&
|
||||||
{ dunstify -u critical "🎧 no headphones connected"; exit; }
|
{ dunstify -u critical "🎧 no headphones connected"; exit; }
|
||||||
profile_chosen=$(printf "profile mSBC\\nprofile LDAC\\n$div\\nback\\nexit" | rofi -dmenu -l 5 -i -p "profile")
|
profile_chosen=$(printf "profile mSBC\\nprofile LDAC\\n$div\\nback\\nexit" | dmenu -l 5 -i -p "profile")
|
||||||
case "$profile_chosen" in
|
case "$profile_chosen" in
|
||||||
back) show_current ;;
|
back) show_current ;;
|
||||||
exit) exit ;;
|
exit) exit ;;
|
||||||
|
@ -44,7 +44,7 @@ set_bt_profile() {
|
||||||
show_current() {
|
show_current() {
|
||||||
def_snk=$(pactl list | grep -A 1 "Name: $(pactl get-default-sink)\$" | awk -F': ' '/Description: / {print $2}')
|
def_snk=$(pactl list | grep -A 1 "Name: $(pactl get-default-sink)\$" | awk -F': ' '/Description: / {print $2}')
|
||||||
def_src=$(pactl list | grep -A 1 "Name: $(pactl get-default-source)\$" | awk -F': ' '/Description: / {print $2}')
|
def_src=$(pactl list | grep -A 1 "Name: $(pactl get-default-source)\$" | awk -F': ' '/Description: / {print $2}')
|
||||||
chosen=$(printf "Output: $def_snk\\nInput: $def_src" | rofi -dmenu -l 2 -p "current settings")
|
chosen=$(printf "Output: $def_snk\\nInput: $def_src" | dmenu -l 2 -p "current settings")
|
||||||
if [ "$1" = "no_switch" ]; then
|
if [ "$1" = "no_switch" ]; then
|
||||||
case "$chosen" in
|
case "$chosen" in
|
||||||
*) dunstify -u critical "🔊 no device to switch" ;;
|
*) dunstify -u critical "🔊 no device to switch" ;;
|
||||||
|
|
|
@ -7,14 +7,6 @@
|
||||||
#
|
#
|
||||||
# Author: Nick Clyde (clydedroid)
|
# Author: Nick Clyde (clydedroid)
|
||||||
#
|
#
|
||||||
# A script that generates a rofi menu that uses bluetoothctl to
|
|
||||||
# connect to bluetooth devices and display status info.
|
|
||||||
#
|
|
||||||
# Inspired by networkmanager-dmenu (https://github.com/firecat53/networkmanager-dmenu)
|
|
||||||
# Thanks to x70b1 (https://github.com/polybar/polybar-scripts/tree/master/polybar-scripts/system-bluetooth-bluetoothctl)
|
|
||||||
#
|
|
||||||
# Depends on:
|
|
||||||
# Arch repositories: rofi, bluez-utils (contains bluetoothctl)
|
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
divider="----------"
|
divider="----------"
|
||||||
|
@ -225,7 +217,6 @@ device_menu() {
|
||||||
trusted=$(device_trusted $mac)
|
trusted=$(device_trusted $mac)
|
||||||
options="$connected\n$paired\n$trusted\n$divider\n$goback\nexit"
|
options="$connected\n$paired\n$trusted\n$divider\n$goback\nexit"
|
||||||
|
|
||||||
# Open rofi menu, read chosen option
|
|
||||||
chosen="$(echo -e "$options" | $rofi_command "$device_name")"
|
chosen="$(echo -e "$options" | $rofi_command "$device_name")"
|
||||||
|
|
||||||
# Match chosen option to command
|
# Match chosen option to command
|
||||||
|
@ -248,7 +239,6 @@ device_menu() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Opens a rofi menu with current bluetooth status and options to connect
|
|
||||||
show_menu() {
|
show_menu() {
|
||||||
# Get menu options
|
# Get menu options
|
||||||
if power_on; then
|
if power_on; then
|
||||||
|
@ -263,14 +253,12 @@ show_menu() {
|
||||||
pairable=$(pairable_on)
|
pairable=$(pairable_on)
|
||||||
discoverable=$(discoverable_on)
|
discoverable=$(discoverable_on)
|
||||||
|
|
||||||
# Options passed to rofi
|
|
||||||
options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\nexit"
|
options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\nexit"
|
||||||
else
|
else
|
||||||
power="power: off"
|
power="power: off"
|
||||||
options="$power\nexit"
|
options="$power\nexit"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Open rofi menu, read chosen option
|
|
||||||
chosen="$(echo -e "$options" | $rofi_command "bluetooth")"
|
chosen="$(echo -e "$options" | $rofi_command "bluetooth")"
|
||||||
|
|
||||||
# Match chosen option to command
|
# Match chosen option to command
|
||||||
|
@ -298,8 +286,8 @@ show_menu() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Rofi command to pipe into, can add any options here
|
# command to pipe into, can add any options here
|
||||||
rofi_command="rofi -dmenu -l 20 -i -p"
|
rofi_command="dmenu -l 20 -i -p"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--status)
|
--status)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
twoscreen() {
|
twoscreen() {
|
||||||
mirror=$(printf "no\\nyes" | rofi -dmenu -l 2 -i -p "mirror")
|
mirror=$(printf "no\\nyes" | dmenu -l 2 -i -p "mirror")
|
||||||
if [ "$mirror" = "yes" ]; then
|
if [ "$mirror" = "yes" ]; then
|
||||||
external=$(echo "$screens" | rofi -dmenu -l 2 -i -p "optimize resolution for")
|
external=$(echo "$screens" | dmenu -l 2 -i -p "optimize resolution for")
|
||||||
internal=$(echo "$screens" | grep -v "$external")
|
internal=$(echo "$screens" | grep -v "$external")
|
||||||
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
|
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
|
||||||
tail -n 1 | awk '{print $1}')
|
tail -n 1 | awk '{print $1}')
|
||||||
|
@ -19,9 +19,9 @@ twoscreen() {
|
||||||
--output "$internal" --auto --same-as "$external" \
|
--output "$internal" --auto --same-as "$external" \
|
||||||
--scale "$scale_x"x"$scale_y"
|
--scale "$scale_x"x"$scale_y"
|
||||||
else
|
else
|
||||||
primary=$(echo "$screens" | rofi -dmenu -l 50 -i -p "primary")
|
primary=$(echo "$screens" | dmenu -l 50 -i -p "primary")
|
||||||
secondary=$(echo "$screens" | grep -v "$primary")
|
secondary=$(echo "$screens" | grep -v "$primary")
|
||||||
direction=$(printf "left\\nright" | rofi -dmenu -l 2 -i -p "side of $primary should $secondary be on")
|
direction=$(printf "left\\nright" | dmenu -l 2 -i -p "side of $primary should $secondary be on")
|
||||||
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
|
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ onescreen() {
|
||||||
if [ "$2" = "native" ]; then
|
if [ "$2" = "native" ]; then
|
||||||
xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -)
|
xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -)
|
||||||
else
|
else
|
||||||
scale=$(printf "native\\n0.75\\n0.5" | rofi -dmenu -l 3 -i -p "scale") &&
|
scale=$(printf "native\\n0.75\\n0.5" | dmenu -l 3 -i -p "scale") &&
|
||||||
case "$scale" in
|
case "$scale" in
|
||||||
"native") xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -);;
|
"native") xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -);;
|
||||||
*) xrandr --output "$1" --auto --scale ${scale}x${scale} $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -);;
|
*) xrandr --output "$1" --auto --scale ${scale}x${scale} $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -);;
|
||||||
|
@ -55,7 +55,7 @@ screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
|
||||||
{ onescreen "$screens" "native"; postrun; dunstify -u critical "💻 no device to switch"; exit ;}
|
{ onescreen "$screens" "native"; postrun; dunstify -u critical "💻 no device to switch"; exit ;}
|
||||||
|
|
||||||
# Get user choice including both and manual selection:
|
# Get user choice including both and manual selection:
|
||||||
chosen=$(printf -- "%s\\nmulti" "$screens" | rofi -dmenu -l 5 -i -p "display") &&
|
chosen=$(printf -- "%s\\nmulti" "$screens" | dmenu -l 5 -i -p "display") &&
|
||||||
case "$chosen" in
|
case "$chosen" in
|
||||||
"multi") twoscreen ;;
|
"multi") twoscreen ;;
|
||||||
*) onescreen "$chosen" ;;
|
*) onescreen "$chosen" ;;
|
||||||
|
|
|
@ -103,7 +103,7 @@ static Key keys[] = {
|
||||||
TAGKEYS( XK_0, 9)
|
TAGKEYS( XK_0, 9)
|
||||||
/* apps n'shit */
|
/* apps n'shit */
|
||||||
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
|
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
|
||||||
{ MODKEY, XK_space, spawn, SHCMD("rofi -show run") },
|
{ MODKEY, XK_space, spawn, SHCMD("dmenu_run") },
|
||||||
{ MODKEY, XK_f, spawn, SHCMD("st -n nnn -e nnn -de") },
|
{ MODKEY, XK_f, spawn, SHCMD("st -n nnn -e nnn -de") },
|
||||||
{ MODKEY, XK_i, spawn, SHCMD("scrot -f -s 'scrot_%Y-%m-%d_%H-%M-%S_%s.png'") },
|
{ MODKEY, XK_i, spawn, SHCMD("scrot -f -s 'scrot_%Y-%m-%d_%H-%M-%S_%s.png'") },
|
||||||
{ SHTKEY, XK_i, spawn, SHCMD("scrot 'scrot_%Y-%m-%d_%H-%M-%S_%s.png'") },
|
{ SHTKEY, XK_i, spawn, SHCMD("scrot 'scrot_%Y-%m-%d_%H-%M-%S_%s.png'") },
|
||||||
|
@ -114,7 +114,7 @@ static Key keys[] = {
|
||||||
{ CTRKEY, XK_a, spawn, SHCMD("dmenu-audio") },
|
{ CTRKEY, XK_a, spawn, SHCMD("dmenu-audio") },
|
||||||
{ CTRKEY, XK_b, spawn, SHCMD("dmenu-bluetooth") },
|
{ CTRKEY, XK_b, spawn, SHCMD("dmenu-bluetooth") },
|
||||||
{ CTRKEY, XK_d, spawn, SHCMD("dmenu-display") },
|
{ CTRKEY, XK_d, spawn, SHCMD("dmenu-display") },
|
||||||
{ CTRKEY, XK_e, spawn, SHCMD("rofi -show emoji") },
|
{ CTRKEY, XK_e, spawn, SHCMD("dmenu-emoji") },
|
||||||
{ CTRKEY, XK_l, spawn, SHCMD("physlock") },
|
{ CTRKEY, XK_l, spawn, SHCMD("physlock") },
|
||||||
/* window controls */
|
/* window controls */
|
||||||
{ SHTKEY, XK_m, zoom, {0} },
|
{ SHTKEY, XK_m, zoom, {0} },
|
||||||
|
|
|
@ -12,7 +12,7 @@ urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sideb
|
||||||
|
|
||||||
while getopts "hoc" o; do case "${o}" in
|
while getopts "hoc" o; do case "${o}" in
|
||||||
h) printf "Optional arguments for custom use:\\n -c: copy\\n -o: xdg-open\\n -h: Show this message\\n" && exit 1 ;;
|
h) printf "Optional arguments for custom use:\\n -c: copy\\n -o: xdg-open\\n -h: Show this message\\n" && exit 1 ;;
|
||||||
o) chosen="$(echo "$urls" | rofi -dmenu -l 20 -i -p 'open')"
|
o) chosen="$(echo "$urls" | dmenu -l 20 -i -p 'open')"
|
||||||
setsid xdg-open "$chosen" >/dev/null 2>&1 & ;;
|
setsid xdg-open "$chosen" >/dev/null 2>&1 & ;;
|
||||||
c) echo "$urls" | dmenu -i -p 'copy' -l 10 | tr -d '\n' | xsel -l /dev/null ;;
|
c) echo "$urls" | dmenu -i -p 'copy' -l 10 | tr -d '\n' | xsel -l /dev/null ;;
|
||||||
*) printf "Invalid option: -%s\\n" "$OPTARG" && exit 1 ;;
|
*) printf "Invalid option: -%s\\n" "$OPTARG" && exit 1 ;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue