New desktop stuff added to 38 script.

This commit is contained in:
Storm Dragon 2024-06-22 21:01:00 -04:00
parent 0c2b5c3e8b
commit b813753968
2 changed files with 55 additions and 6 deletions

10
i38.sh
View File

@ -466,7 +466,7 @@ bindsym \$mod+F4 kill
bindsym \$mod+F1 exec --no-startup-id sgtk-menu -f
# Desktop icons
bindsym \$mod+Control+d exec --no-startup-id yad --icons --compact --no-buttons --title="Desktop" --close-on-unfocus --read-dir=${HOME}/Desktop
bindsym \$mod+Control+d exec --no-startup-id ${i3Path}/scripts/desktop.sh
# change focus
# alt+tab and alt+shift+tab
@ -662,13 +662,11 @@ else
echo '# Startup applications'
echo 'exec --no-startup-id clipster -d'
echo 'exec orca'
echo "exec_always --no-startup-id ${i3Path}/scripts/desktop.sh"
fi)
# If you want to add personal customizations to i3, add them in ${i3Path}/customizations
# It is not overwritten with the config file is recreated.
$(if [[ -r "${i3Path}/customizations" ]]; then
echo "include \"${i3Path}/customizations\""
else
echo "# Rerun the ${0##*/} script after creating the customizations file so it is detected."
fi)
touch "${i3Path}/customizations"
include "${i3Path}/customizations"
EOF

51
scripts/desktop.sh Executable file
View File

@ -0,0 +1,51 @@
#!/usr/bin/env bash
# This file is part of I38.
# I38 is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
# I38 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with I38. If not, see <https://www.gnu.org/licenses/>.
# Make sure there is a desktop to search.
if [[ ! -d ~/Desktop ]]; then
exit 0
fi
# Discover directories and files on the desktop
mapfile -t desktopDirs < <(find ~/Desktop -mindepth 1 -maxdepth 1 -type d)
mapfile -t desktopFiles < <(find ~/Desktop -mindepth 1 -maxdepth 1 -type f)
# Combine directories and files into one list
desktopItems=("${desktopDirs[@]}" "${desktopFiles[@]}")
# Build menu for yad.
declare -a menuList
for i in "${desktopItems[@]}" ; do
case "$i" in
*".desktop")
menuList+=("$(grep "^Name" "$i" | cut -f2- -d '=')" "gio launch \"$i\"")
;;
*)
menuList+=("${i##*/}" "/usr/bin/env xdg-open \"$i\"")
;;
esac
done
launch=$(yad --list \
--title="I38 Desktop" \
--column="Items" \
--column="Launch Command" \
--close-on-unfocus \
--hide-column=2 \
--search-column=1 \
--skip-taskbar \
"${menuList[@]}")
if [[ $? -eq 0 ]]; then
launch="${launch%|}"
launch="${launch##*|}"
eval "$launch"
fi