Add rofi sudo scripts

This commit is contained in:
Daniel_I_Am 2021-12-27 15:42:48 +01:00
parent 5b8fa6ef0e
commit 8bab72ac23
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,14 @@
{# symlink{~/bin/askpass-rofi} #}
#!/usr/bin/env bash
if [ -p /dev/stdin ]
then
data=$(< /dev/stdin)
fi
rofi -dmenu\
-password\
-i\
-no-fixed-num-lines\
-p "Password:"\
-theme ~/.config/rofi/themes/askpass.rasi

30
templates/rofi/rofisudo Normal file
View File

@ -0,0 +1,30 @@
{# symlink{~/bin/rofisudo} #}
#!/usr/bin/env bash
if [ -p /dev/stdin ] || [ ! -t 0 ]
then
data=$(< /dev/stdin)
fi
sudo -n true > /dev/null 2>&1
if [ $? -gt 0 ]
then
password=$(echo -n "" | rofi -dmenu\
-password\
-i\
-no-fixed-num-lines\
-p "Password:"\
-theme ~/.config/rofi/themes/askpass.rasi)
echo -n "$password" | sudo --stdin -v
fi
sudo -n true > /dev/null 2>&1
if [ $? -eq 0 ]
then
if [ ! -z "$data" ]
then
echo -n "$data" | sudo "$@"
else
sudo "$@"
fi
fi