48 lines
1.5 KiB
Bash
Executable File
48 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
####################################################################
|
|
# wofi_wrun - wofi-dmenu script that simulates 'rofi -show window' #
|
|
# #
|
|
# Author: q3aql <q3aql@duck.com> #
|
|
# Last update: 04-01-2023 #
|
|
####################################################################
|
|
|
|
# Configuration variables
|
|
load_theme_path="${HOME}/.wofi"
|
|
|
|
function generate_spaces() {
|
|
num_spaces=${1}
|
|
count_spaces=1
|
|
while [ ${count_spaces} -le ${num_spaces} ] ; do
|
|
echo -n " "
|
|
count_spaces=$(expr ${count_spaces} + 1)
|
|
done
|
|
}
|
|
|
|
function check_dependencies() {
|
|
swaymsg &> /dev/null
|
|
error=$?
|
|
if [ ${error} -ne 0 ] ; then
|
|
echo " Error: You need install 'swaymsg'" | wofi --dmenu -p " window"
|
|
exit
|
|
fi
|
|
}
|
|
|
|
function list_applications_icons() {
|
|
swaymsg -t get_tree | jq -r '.. | .nodes?[]? | select(.type == "con" and .focused == false and .name != null) | .name' | while read current_app ; do
|
|
echo " ${current_app}"
|
|
done
|
|
generate_spaces 75
|
|
}
|
|
|
|
check_dependencies
|
|
list_output=$(list_applications_icons | wofi -s ~/.config/wofi/wofi.css --dmenu -i -p " window")
|
|
run_output=$(echo ${list_output} | cut -c 5-999)
|
|
echo "# Selected: ${run_output}"
|
|
run_output=$(echo "${run_output}" | cut -d " " -f 1)
|
|
if [ -z "${run_output}" ] ; then
|
|
echo "# Selection window canceled"
|
|
else
|
|
swaymsg "[title=\"${run_output}\"] focus" &> /dev/null
|
|
fi
|