feat: Use nix-shell interpreter

This commit is contained in:
punkfairie 2024-11-23 11:37:18 -08:00
parent 912ae5df82
commit d44933c182
Signed by: punkfairie
GPG key ID: A509E8F77FB9D696
8 changed files with 129 additions and 107 deletions

View file

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env nix-shell
#! nix-shell -i bash -p rofi gnugrep
# shellcheck shell=bash
## Author : Aditya Shakya (adi1090x) ## Author : Aditya Shakya (adi1090x)
## Github : @adi1090x ## Github : @adi1090x
@ -6,12 +8,13 @@
## Applets : Power Menu ## Applets : Power Menu
# Import Current Theme # Import Current Theme
# shellcheck source=./../shared/theme.bash
source "$HOME"/.config/rofi/applets/shared/theme.bash source "$HOME"/.config/rofi/applets/shared/theme.bash
theme="$type/$style" theme="$type/$style"
# Theme Elements # Theme Elements
prompt="`hostname`" prompt="$(hostname)"
mesg="Uptime : `uptime -p | sed -e 's/up //g'`" mesg="Uptime : $(uptime -p | sed -e 's/up //g')"
if [[ ("$theme" == *'type-1'*) || ("$theme" == *'type-3'*) || ("$theme" == *'type-5'*) ]]; then if [[ ("$theme" == *'type-1'*) || ("$theme" == *'type-3'*) || ("$theme" == *'type-5'*) ]]; then
list_col='1' list_col='1'
@ -22,7 +25,7 @@ elif [[ ( "$theme" == *'type-2'* ) || ( "$theme" == *'type-4'* ) ]]; then
fi fi
# Options # Options
layout=`cat ${theme} | grep 'USE_ICON' | cut -d'=' -f2` layout=$(cat "${theme}" | grep 'USE_ICON' | cut -d'=' -f2)
if [[ "$layout" == 'NO' ]]; then if [[ "$layout" == 'NO' ]]; then
option_1=" Lock" option_1=" Lock"
option_2=" Logout" option_2=" Logout"
@ -44,23 +47,26 @@ else
fi fi
# Rofi CMD # Rofi CMD
rofi_cmd() { rofi_cmd()
{
rofi -theme-str "listview {columns: $list_col; lines: $list_row;}" \ rofi -theme-str "listview {columns: $list_col; lines: $list_row;}" \
-theme-str 'textbox-prompt-colon {str: "";}' \ -theme-str 'textbox-prompt-colon {str: "";}' \
-dmenu \ -dmenu \
-p "$prompt" \ -p "$prompt" \
-mesg "$mesg" \ -mesg "$mesg" \
-markup-rows \ -markup-rows \
-theme ${theme} -theme "${theme}"
} }
# Pass variables to rofi dmenu # Pass variables to rofi dmenu
run_rofi() { run_rofi()
{
echo -e "$option_1\n$option_2\n$option_3\n$option_4\n$option_5\n$option_6" | rofi_cmd echo -e "$option_1\n$option_2\n$option_3\n$option_4\n$option_5\n$option_6" | rofi_cmd
} }
# Confirmation CMD # Confirmation CMD
confirm_cmd() { confirm_cmd()
{
rofi -theme-str 'window {location: center; anchor: center; fullscreen: false; width: 350px;}' \ rofi -theme-str 'window {location: center; anchor: center; fullscreen: false; width: 350px;}' \
-theme-str 'mainbox {orientation: vertical; children: [ "message", "listview" ];}' \ -theme-str 'mainbox {orientation: vertical; children: [ "message", "listview" ];}' \
-theme-str 'listview {columns: 2; lines: 1;}' \ -theme-str 'listview {columns: 2; lines: 1;}' \
@ -69,16 +75,18 @@ confirm_cmd() {
-dmenu \ -dmenu \
-p 'Confirmation' \ -p 'Confirmation' \
-mesg 'Are you Sure?' \ -mesg 'Are you Sure?' \
-theme ${theme} -theme "${theme}"
} }
# Ask for confirmation # Ask for confirmation
confirm_exit() { confirm_exit()
{
echo -e "$yes\n$no" | confirm_cmd echo -e "$yes\n$no" | confirm_cmd
} }
# Confirm and execute # Confirm and execute
confirm_run () { confirm_run()
{
selected="$(confirm_exit)" selected="$(confirm_exit)"
if [[ "$selected" == "$yes" ]]; then if [[ "$selected" == "$yes" ]]; then
${1} && ${2} && ${3} ${1} && ${2} && ${3}
@ -88,7 +96,8 @@ confirm_run () {
} }
# Execute Command # Execute Command
run_cmd() { run_cmd()
{
if [[ "$1" == '--opt1' ]]; then if [[ "$1" == '--opt1' ]]; then
betterlockscreen -l betterlockscreen -l
elif [[ "$1" == '--opt2' ]]; then elif [[ "$1" == '--opt2' ]]; then
@ -107,23 +116,22 @@ run_cmd() {
# Actions # Actions
chosen="$(run_rofi)" chosen="$(run_rofi)"
case ${chosen} in case ${chosen} in
$option_1) "$option_1")
run_cmd --opt1 run_cmd --opt1
;; ;;
$option_2) "$option_2")
run_cmd --opt2 run_cmd --opt2
;; ;;
$option_3) "$option_3")
run_cmd --opt3 run_cmd --opt3
;; ;;
$option_4) "$option_4")
run_cmd --opt4 run_cmd --opt4
;; ;;
$option_5) "$option_5")
run_cmd --opt5 run_cmd --opt5
;; ;;
$option_6) "$option_6")
run_cmd --opt6 run_cmd --opt6
;; ;;
esac esac

View file

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env nix-shell
#! nix-shell -i bash -p rofi
# shellcheck shell=bash
## Author : Aditya Shakya (adi1090x) ## Author : Aditya Shakya (adi1090x)
## Github : @adi1090x ## Github : @adi1090x

View file

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env nix-shell
#! nix-shell -i bash -p rofi
# shellcheck shell=bash
## Author : Aditya Shakya (adi1090x) ## Author : Aditya Shakya (adi1090x)
## Github : @adi1090x ## Github : @adi1090x
@ -17,4 +19,4 @@ theme='style-1'
## Run ## Run
rofi \ rofi \
-show drun \ -show drun \
-theme ${dir}/${theme}.rasi -theme "${dir}"/${theme}.rasi

View file

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env nix-shell
#! nix-shell -i bash -p rofi
# shellcheck shell=bash
## Author : Aditya Shakya (adi1090x) ## Author : Aditya Shakya (adi1090x)
## Github : @adi1090x ## Github : @adi1090x
@ -16,4 +18,4 @@ theme='style-10'
## Run ## Run
rofi \ rofi \
-show drun \ -show drun \
-theme ${dir}/${theme}.rasi -theme "${dir}"/${theme}.rasi

View file

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env nix-shell
#! nix-shell -i bash -p rofi
# shellcheck shell=bash
## Author : Aditya Shakya (adi1090x) ## Author : Aditya Shakya (adi1090x)
## Github : @adi1090x ## Github : @adi1090x
@ -16,4 +18,4 @@ theme='style-1'
## Run ## Run
rofi \ rofi \
-show drun \ -show drun \
-theme ${dir}/${theme}.rasi -theme "${dir}"/${theme}.rasi

View file

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env nix-shell
#! nix-shell -i bash -p rofi
# shellcheck shell=bash
## Author : Aditya Shakya (adi1090x) ## Author : Aditya Shakya (adi1090x)
## Github : @adi1090x ## Github : @adi1090x
@ -15,4 +17,4 @@ theme='style-1'
## Run ## Run
rofi \ rofi \
-show drun \ -show drun \
-theme ${dir}/${theme}.rasi -theme "${dir}"/${theme}.rasi

View file

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env nix-shell
#! nix-shell -i bash -p rofi
# shellcheck shell=bash
## Author : Aditya Shakya (adi1090x) ## Author : Aditya Shakya (adi1090x)
## Github : @adi1090x ## Github : @adi1090x
@ -16,4 +18,4 @@ theme='style-1'
## Run ## Run
rofi \ rofi \
-show drun \ -show drun \
-theme ${dir}/${theme}.rasi -theme "${dir}"/${theme}.rasi

View file

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env nix-shell
#! nix-shell -i bash -p rofi
# shellcheck shell=bash
## Author : Aditya Shakya (adi1090x) ## Author : Aditya Shakya (adi1090x)
## Github : @adi1090x ## Github : @adi1090x
@ -16,4 +18,4 @@ theme='style-1'
## Run ## Run
rofi \ rofi \
-show drun \ -show drun \
-theme ${dir}/${theme}.rasi -theme "${dir}"/${theme}.rasi