From 19bc1126ff435f1bbc0c3de1cff566e76ce5f02b Mon Sep 17 00:00:00 2001 From: Penelope Gwen Date: Mon, 29 Apr 2024 15:58:34 -0600 Subject: [PATCH] New backup 2024-04-29 15:58:34 --- de/home/.local/bin/sp-clipboard | 20 ++++++++++++ de/home/.local/bin/sp-global-shortcuts | 8 +++++ de/home/.local/bin/sp-launcher | 17 ++++++++++ de/home/.local/bin/sp-lock | 16 +++++++++ de/home/.local/bin/sp-powermenu | 18 +++++++++++ de/home/.local/bin/sp-profiles | 45 ++++++++++++++++++++++++++ de/home/.local/bin/sp-rename | 7 ++++ de/home/.local/bin/sp-screenshot | 12 +++++++ de/home/.local/bin/sp-shortcuts | 10 ++++++ de/home/.local/bin/sp-wallpaper | 30 +++++++++++++++++ de/include | 10 ++++++ 11 files changed, 193 insertions(+) create mode 100755 de/home/.local/bin/sp-clipboard create mode 100755 de/home/.local/bin/sp-global-shortcuts create mode 100755 de/home/.local/bin/sp-launcher create mode 100755 de/home/.local/bin/sp-lock create mode 100755 de/home/.local/bin/sp-powermenu create mode 100755 de/home/.local/bin/sp-profiles create mode 100755 de/home/.local/bin/sp-rename create mode 100755 de/home/.local/bin/sp-screenshot create mode 100755 de/home/.local/bin/sp-shortcuts create mode 100755 de/home/.local/bin/sp-wallpaper diff --git a/de/home/.local/bin/sp-clipboard b/de/home/.local/bin/sp-clipboard new file mode 100755 index 0000000..f2011cd --- /dev/null +++ b/de/home/.local/bin/sp-clipboard @@ -0,0 +1,20 @@ +#!/bin/bash + +cb_count=$(copyq count) +cb_count=10 + +wofilist="" + +for i in $(seq $cb_count);do + cb_line="$( copyq read $((${i}-1)) | tr '\n' ' ' )" + echo "${cb_line}" + if [[ "${cb_line}" == "" ]];then + cb_line=$( copyq read ? "$((${i}-1))" | head -n 1 ) + fi + wofilist="${wofilist}${setnl}${i}. ${cb_line}" + setnl="\n" +done + +selected=$( echo -e "${wofilist}" | wofi -i --dmenu -k /dev/null | cut -d. -f1) + +copyq select "$(( ${selected}-1)) " diff --git a/de/home/.local/bin/sp-global-shortcuts b/de/home/.local/bin/sp-global-shortcuts new file mode 100755 index 0000000..411e4f5 --- /dev/null +++ b/de/home/.local/bin/sp-global-shortcuts @@ -0,0 +1,8 @@ +#!/bin/bash + +source "${HOME}/.local/lib/sp-functions" + +options=$( ls "${conf_dir}/global-shortcuts/" ) +op=$( echo -e "${options}" | wofi -i --dmenu | awk '{print}' ) + +"${conf_dir}/global-shortcuts/${op}" diff --git a/de/home/.local/bin/sp-launcher b/de/home/.local/bin/sp-launcher new file mode 100755 index 0000000..445843f --- /dev/null +++ b/de/home/.local/bin/sp-launcher @@ -0,0 +1,17 @@ +#!/bin/bash + +source "${HOME}/.local/lib/sp-functions" +source "${conf_dir}/config" + +case $1 in + file_manager ) + launch_exec=${filemanager_cmd} + launch_arg=$( jq -r .[].home_directory "${conf_dir}/profiles/$( get_profile_id )/vars.json" ) + ;; + browser ) + launch_exec=${browser_cmd} + launch_arg=$( jq -r .[].browser_profile "${conf_dir}/profiles/$( get_profile_id )/vars.json" ) + ;; +esac + +bash -c "${launch_exec} ${launch_arg}" diff --git a/de/home/.local/bin/sp-lock b/de/home/.local/bin/sp-lock new file mode 100755 index 0000000..e2613a8 --- /dev/null +++ b/de/home/.local/bin/sp-lock @@ -0,0 +1,16 @@ +#!/bin/bash + +source "${HOME}/.local/lib/sp-functions" + +outputs=( $(swaymsg -t get_outputs | jq -r '.[] | {name} | "\(.name)"') ) + +for o in ${outputs[@]};do + workspace=$(swaymsg -t get_workspaces | jq -r '.[] | select(.output) | {name} | "\(.name)"') + wpno=$(cat "${cache_dir}/displays/${o}") + wp_imgpath="$HOME/.config/sway/assets/wallpaper/${o}/${wpno}.jpg" + sl_imgpath="${cache_dir}/lock/${o}.jpg" + convert -scale 10% -blur 0x3 -resize 500% "${wp_imgpath}" "${sl_imgpath}" + sl_args="${sl_args}--image ${o}:${sl_imgpath} " +done + +swaylock ${sl_args} diff --git a/de/home/.local/bin/sp-powermenu b/de/home/.local/bin/sp-powermenu new file mode 100755 index 0000000..88274f7 --- /dev/null +++ b/de/home/.local/bin/sp-powermenu @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +op=$( echo -e "ā» Poweroff\nļƒœ Reboot\nļ†† Suspend\nšŸ”’ Lock\nļ‚‹ Logout" | wofi -i --dmenu -a --width 250 --height 420 | awk '{print tolower($2)}' ) +case $op in + poweroff) + ;& + reboot) + ;& + suspend) + systemctl $op + ;; + lock) + swaylock + ;; + logout) + swaymsg exit + ;; +esac diff --git a/de/home/.local/bin/sp-profiles b/de/home/.local/bin/sp-profiles new file mode 100755 index 0000000..15b173c --- /dev/null +++ b/de/home/.local/bin/sp-profiles @@ -0,0 +1,45 @@ +#!/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" diff --git a/de/home/.local/bin/sp-rename b/de/home/.local/bin/sp-rename new file mode 100755 index 0000000..9ca8757 --- /dev/null +++ b/de/home/.local/bin/sp-rename @@ -0,0 +1,7 @@ +#!/bin/bash + +source "${HOME}/.local/lib/sp-functions" + +new_wsname="$( get_workspace_prefix )$(wofi -i --dmenu --height 1 --search $( get_workspace_name ))" + +swaymsg 'rename workspace "'"$( get_workspace_fullname )"'" to "'"${new_wsname}"'"' diff --git a/de/home/.local/bin/sp-screenshot b/de/home/.local/bin/sp-screenshot new file mode 100755 index 0000000..cbe63d1 --- /dev/null +++ b/de/home/.local/bin/sp-screenshot @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +source "${HOME}/.local/lib/sp-functions" + +op=$( echo -e "Output\nWindow\nRegion" | wofi -i --dmenu --width 250 --height 260 | awk '{print tolower($1)}' ) + +echo "$op" + +sleep 0.5 +mkdir -p "${cache_dir}/screenshots/" +sway-screenshot -m $op --output-folder "${cache_dir}/screenshots/" +mv "${cache_dir}/screenshots/"* "$HOME/Pictures/Screen Capture" diff --git a/de/home/.local/bin/sp-shortcuts b/de/home/.local/bin/sp-shortcuts new file mode 100755 index 0000000..13a3594 --- /dev/null +++ b/de/home/.local/bin/sp-shortcuts @@ -0,0 +1,10 @@ +#!/bin/bash + +source "${HOME}/.local/lib/sp-functions" + +current_profile=$( get_profile_id ) + +profile_scripts=$( ls "${conf_dir}/profiles/${current_profile}/shortcuts/" ) +op=$( echo -e "${profile_scripts}" | wofi -w 2 -i --dmenu | awk '{print}' ) + +"${conf_dir}/profiles/${current_profile}/shortcuts/${op}" diff --git a/de/home/.local/bin/sp-wallpaper b/de/home/.local/bin/sp-wallpaper new file mode 100755 index 0000000..0434833 --- /dev/null +++ b/de/home/.local/bin/sp-wallpaper @@ -0,0 +1,30 @@ +#!/bin/bash + +source "${HOME}/.local/lib/sp-functions" + +getwpno() { + wpno=$(printf "%02d\n" $(($(echo "$1" | awk '{print $1}' | grep -o "^[1-9]*")-1)) | cut -c 1 | sed 's/[^0-9]*//g') + echo "${wpno}" | tee "${cache_dir}/displays/${2}" +} + +setbg() { + for d in ${outputs[@]};do + d_wpno=$(cat "${cache_dir}/displays/${d}") + swaymsg output "${d}" bg "$HOME/.config/sway/assets/wallpaper/${d}/${d_wpno}.jpg" fill + done +} + +output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | {name} | "\(.name)"') +outputs=( $(swaymsg -t get_outputs | jq -r '.[] | {name} | "\(.name)"') ) +workspace=$(swaymsg -t get_workspaces | jq -r '.[] | select(.focused) | {name} | "\(.name)"') +getwpno "${workspace}" "${output}" +setbg "${output}" "${wpno}" + +swaymsg -r -t subscribe -m '["workspace"]' | jq -rc --unbuffered 'select(.change == "focus") | .current | "\(.name) \(.output)"' | while read name output;do + wsno=$(($(echo "$name" | awk '{print $1}' | grep -o "^[1-9]*")-1)) + wpno_last=$(cat "${cache_dir}/displays/${output}") + getwpno "${name}" "${output}" + if [[ "${wpno}" -ne "${wpno_last}" ]];then + setbg "${output}" "${wpno}" + fi +done diff --git a/de/include b/de/include index 126f16c..5a558e2 100644 --- a/de/include +++ b/de/include @@ -12,3 +12,13 @@ .config/alacritty .local/bin/randomrat .local/lib/sp-functions +.local/bin/sp-clipboard +.local/bin/sp-global-shortcuts +.local/bin/sp-launcher +.local/bin/sp-lock +.local/bin/sp-powermenu +.local/bin/sp-profiles +.local/bin/sp-rename +.local/bin/sp-screenshot +.local/bin/sp-shortcuts +.local/bin/sp-wallpaper