Advertisement
metalx1000

FZF Window Switcher

Jun 16th, 2020
1,700
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.33 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #This creates a windows switcher/launcher with fzf
  4. #Copyright (C) 2020  Kris Occhipinti
  5. #https://filmsbykris.com
  6.  
  7. #This program is free software: you can redistribute it and/or modify
  8. #it under the terms of the GNU General Public License as published by
  9. #the Free Software Foundation, either version 3 of the License, or
  10. #(at your option) any later version.
  11.  
  12. #This program is distributed in the hope that it will be useful,
  13. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. #GNU General Public License for more details.
  16.  
  17. #You should have received a copy of the GNU General Public License
  18. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19. ######################################################################
  20.  
  21.  
  22. win=$((wmctrl -l|sed 's/^/o /';ls /usr/share/applications/*.desktop)|fzf)
  23.  
  24. if [[ $win = "o "* ]]
  25. then
  26.   title="$(echo $win|awk '{ s = ""; for (i = 5; i <= NF; i++) s = s $i " "; print s}')"
  27.   space="$(echo $win|awk '{print $3}')"
  28.  
  29.   echo "wmctrl -s $space -a \"$title\""
  30.   #wmctrl -s $space -a "${title%?}"
  31.   wmctrl -s $space -a $title
  32. else
  33.   prog="$(basename $win)"
  34.   setsid gtk-launch $prog &> /dev/null
  35.   echo "Opening $prog..."
  36. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement