From b8137539683bae3c258e2885533e70257af09f84 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 22 Jun 2024 21:01:00 -0400 Subject: [PATCH] New desktop stuff added to 38 script. --- i38.sh | 10 ++++----- scripts/desktop.sh | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 6 deletions(-) create mode 100755 scripts/desktop.sh diff --git a/i38.sh b/i38.sh index edb8eff..a0777b7 100755 --- a/i38.sh +++ b/i38.sh @@ -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 diff --git a/scripts/desktop.sh b/scripts/desktop.sh new file mode 100755 index 0000000..7febecb --- /dev/null +++ b/scripts/desktop.sh @@ -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 . + +# 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