File-based tofi menus

Also changed the snippet script to use this method
This commit is contained in:
John Mertz 2023-11-14 14:10:53 -07:00
parent e5b3acb5e4
commit d4e274c29a
Signed by: jpm
GPG Key ID: E9C5EA2D867501AB
12 changed files with 91 additions and 12 deletions

View File

@ -1,12 +0,0 @@
#!/usr/bin/env bash
# Copy snippet to primary clipboard for middle-click pasting
# Maintain list of snippets in private repository
FOLDER=${HOME}/.private-scripts/snippets
FILE=`ls ${FOLDER} | /usr/bin/rofi -dmenu`
if [ -f ${FOLDER}/${FILE} ]; then
DATA=$([ -x "${FOLDER}/${FILE}" ] && bash "${FOLDER}/${FILE}" || head --bytes=-1 ${FOLDER}/${FILE})
printf -- "${DATA}" | wl-copy -p
fi

6
tofi/power/↩ Logout Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
if [ -z ${SWAYSOCK+x} ]; then
i3lock -c 000000
else
swaylock -c 000000
fi

2
tofi/power/↯ Hibernate Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
systemctl hibernate -i

7
tofi/power/↻ Reload Desktop Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
if [ -z ${SWAYSOCK+x} ]; then
i3 reload
else
swaymsg reload
distrobox-enter -n debian${HOME}/scripts/sway/displays.pl
fi

6
tofi/power/↻ Reload Toolbar Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
if [ -z ${SWAYSOCK+x} ]; then
i3 reload
else
${HOME}/scripts/sway/displays.pl -w
fi

3
tofi/power/⏻ Shutdown Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
rm /var/home/jpm/.spool/ssh-agent.sock
systemctl poweroff -i

6
tofi/power/⚿ Lock Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
if [ -z ${SWAYSOCK+x} ]; then
i3lock -c 000000
else
swaylock -c 000000
fi

View File

@ -0,0 +1,13 @@
#!/bin/bash
RUNNING=$(pgrep yubioath-deskto)
if [ "$RUNNING" ]; then
kill $RUNNING
sudo systemctl stop pcscd.socket
sudo systemctl restart pcscd.service
sudo systemctl start pcscd.socket
fi
if [ -z ${SWAYSOCK+x} ]; then
QT_QPA_PLATFORMTHEME=qt5ct QT_QPA_PLATFORM=wayland QT_PLUGIN_PATH=/usr/lib/qt/plugins flatpak run com.yubico.yubioath &
else
QT_QPA_PLATFORMTHEME=qt5ct QT_QPA_PLATFORM=wayland QT_PLUGIN_PATH=/usr/lib/qt/plugins flatpak run com.yubico.yubioath &
fi

View File

@ -0,0 +1,7 @@
#!/bin/bash
if [ -z ${SWAYSOCK+x} ]; then
# xrandr command here
::
else
distrobox-enter -n debian -- ${HOME}/scripts/sway/toggle_outputs.sh
fi

3
tofi/power/🡙 Reboot Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
rm /var/home/jpm/.spool/ssh-agent.sock
systemctl reboot -i

29
tofi/tofi-menu.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
cd ${HOME}/scripts/tofi
if [ -z $1 ]; then
echo -n "Argument required. Available arguments are:"
for i in $(find -type d); do
i=$(echo $i | sed -E 's/^\.\/?//')
echo " $i"
done
cd ${HOME}/.private-scripts/tofi
$(find -type d)
for i in $(find -type d); do
i=$(echo $i | sed -E 's/^\.\/?//')
echo " $i"
done
exit
fi
if [ ! -e $1 ]; then
cd ${HOME}/.private-scripts/tofi
if [ ! -e $1 ]; then
echo "$PWD/$1 is not a tofi directory"
exit
fi
fi
cd $1
HEIGHT=$(swaymsg -t get_outputs | tr '\n' ' ' | sed -e 's/ */ /g' | sed -e 's/\(.*"focused": [a-z]*\),/\1\n/' | less | grep '"focused": true' | sed -e 's/.*"rect": {[^}]*"height": \([0-9]*\).*/\1/')
exec "./$(find ./ -executable -type f | sed -E 's/\.\///' | tofi --prompt-text 'Power: ' --height $HEIGHT --config ${HOME}/.dotfiles/tofi/sidebar.toml)" 2>/dev/null

9
tofi/tofi-snippets.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Copy snippet to primary clipboard for middle-click pasting
# Maintain list of snippets in private repository
cd ${HOME}/.private-scripts/snippets
HEIGHT=$(swaymsg -t get_outputs | tr '\n' ' ' | sed -e 's/ */ /g' | sed -e 's/\(.*"focused": [a-z]*\),/\1\n/' | less | grep '"focused": true' | sed -e 's/.*"rect": {[^}]*"height": \([0-9]*\).*/\1/')
cat $(find ./ -type f | sed -E 's/\.\///' | tofi --prompt-text 'Snippets: ' --height $HEIGHT --config ${HOME}/.dotfiles/tofi/sidebar.toml) | wl-copy -p