Back to dmenu.

This commit is contained in:
Bartek Stalewski 2021-10-08 00:58:07 +02:00
parent 0ba9df8d5e
commit 6a14afdb8e
6 changed files with 16 additions and 28 deletions

View file

@ -4,7 +4,7 @@
mkdir -p ~/.config ~/.local/bin ~/.local/settings
# link config
for i in dunst fontconfig rofi zathura; do
for i in dunst fontconfig zathura; do
rm -rf ~/.config/${i}
ln -sf ~/.local/repos/dotfiles/_desktop/${i} ~/.config
done

View file

@ -3,7 +3,7 @@
div="----------"
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
back) show_current ;;
exit) exit ;;
@ -14,7 +14,7 @@ set_output() {
}
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
back) show_current ;;
exit) exit ;;
@ -29,7 +29,7 @@ set_bt_profile() {
bt_sink=$(pactl list cards | awk -F'"' '/device.name.*bluez/ {print $2}')
[ -z "${bt_sink}" ] &&
{ 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
back) show_current ;;
exit) exit ;;
@ -44,7 +44,7 @@ set_bt_profile() {
show_current() {
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}')
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
case "$chosen" in
*) dunstify -u critical "🔊 no device to switch" ;;

View file

@ -7,14 +7,6 @@
#
# 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
divider="----------"
@ -225,7 +217,6 @@ device_menu() {
trusted=$(device_trusted $mac)
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")"
# Match chosen option to command
@ -248,7 +239,6 @@ device_menu() {
esac
}
# Opens a rofi menu with current bluetooth status and options to connect
show_menu() {
# Get menu options
if power_on; then
@ -263,14 +253,12 @@ show_menu() {
pairable=$(pairable_on)
discoverable=$(discoverable_on)
# Options passed to rofi
options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\nexit"
else
power="power: off"
options="$power\nexit"
fi
# Open rofi menu, read chosen option
chosen="$(echo -e "$options" | $rofi_command "bluetooth")"
# Match chosen option to command
@ -298,8 +286,8 @@ show_menu() {
esac
}
# Rofi command to pipe into, can add any options here
rofi_command="rofi -dmenu -l 20 -i -p"
# command to pipe into, can add any options here
rofi_command="dmenu -l 20 -i -p"
case "$1" in
--status)

View file

@ -1,9 +1,9 @@
#!/bin/sh
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
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")
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
tail -n 1 | awk '{print $1}')
@ -19,9 +19,9 @@ twoscreen() {
--output "$internal" --auto --same-as "$external" \
--scale "$scale_x"x"$scale_y"
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")
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
fi
}
@ -30,7 +30,7 @@ onescreen() {
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 ' ' -)
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
"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 ' ' -);;
@ -55,7 +55,7 @@ screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
{ onescreen "$screens" "native"; postrun; dunstify -u critical "💻 no device to switch"; exit ;}
# 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
"multi") twoscreen ;;
*) onescreen "$chosen" ;;

View file

@ -103,7 +103,7 @@ static Key keys[] = {
TAGKEYS( XK_0, 9)
/* apps n'shit */
{ 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_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'") },
@ -114,7 +114,7 @@ static Key keys[] = {
{ CTRKEY, XK_a, spawn, SHCMD("dmenu-audio") },
{ CTRKEY, XK_b, spawn, SHCMD("dmenu-bluetooth") },
{ 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") },
/* window controls */
{ SHTKEY, XK_m, zoom, {0} },

View file

@ -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
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 & ;;
c) echo "$urls" | dmenu -i -p 'copy' -l 10 | tr -d '\n' | xsel -l /dev/null ;;
*) printf "Invalid option: -%s\\n" "$OPTARG" && exit 1 ;;