dotfiles/de/home/.local/bin/sp-profiles
2024-04-29 15:58:34 -06:00

45 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
source "$HOME/.local/lib/sp-functions"
get_profile_list
case $1 in
next|prev)
current_profile=$(cat "${cache_dir}/active_profile")
echo ${current_profile}
;;&
next)
new_profile=$(( ${current_profile}+1 ))
[[ "$new_profile" -eq "${p_count}" ]] && new_profile=0
;;&
prev)
new_profile=$(( ${current_profile}-1 ))
[[ "$new_profile" -eq "-1" ]] && new_profile=3
;;&
prev|next)
op=$(printf "%01d\n" ${new_profile})
;;
*)
for (( p="0"; p<${p_count}; p++ ));do
[[ $p -eq $(( ${p_count} - 1 )) ]] && nl="" || nl="\n"
wofilist="${wofilist}${p_icons[$p]} ${p_names[$p]}${nl}"
done
[[ -z $1 ]] && op=$( echo -e "${wofilist}" | wofi -i --dmenu --width 250 --height 320 -k /dev/null | awk '{print $2}' ) || op="${1}"
op=$(echo ${p_names[@]/$op//} | cut -d/ -f1 | wc -w | tr -d ' ')
;;
esac
[[ "$op" -gt "$(( $p_count - 1 ))" ]] && exit
[[ $op -eq "0" ]] && p_num="" || p_num="$op"
p_icon="${p_icons[$op]}"
for i in {1..10};do
[[ "$i" -eq "10" ]] && k="0" || k=$i
swaymsg 'bindsym $mod+'"$k"' workspace number "'"${p_num}${i}:${p_icon}"'"'
swaymsg 'bindsym $mod+Shift+'"$k"' move container to workspace number "'"${p_num}${i}:${p_icon}"'"'
done
moveto="${p_num}1:${p_icon}"
swaymsg 'workspace number "'"${p_num}"'"1:"'"${p_icon}"'"'
echo "${op}" > "${cache_dir}/active_profile"