Advertisement
metalx1000

i3wm and Dmenu Window Focus by Class

Oct 30th, 2018
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.38 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2018  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #Uses dmenu to focus on an Open Window by Class
  7.  
  8. #This program is free software: you can redistribute it and/or modify
  9. #it under the terms of the GNU General Public License as published by
  10. #the Free Software Foundation, either version 3 of the License, or
  11. #(at your option) any later version.
  12.  
  13. #This program is distributed in the hope that it will be useful,
  14. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. #GNU General Public License for more details.
  17.  
  18. #You should have received a copy of the GNU General Public License
  19. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20. ######################################################################
  21.  
  22. function main(){
  23.   #get Window Title
  24.   w="$(getList|dmenu -i -l 20 -fn Monospace-18)"
  25.  
  26.   #focus on Window by class
  27.   i3-msg "[class=\"$w\"] focus"
  28.   exit 0
  29. }
  30.  
  31. function getList(){
  32.   #get a list of classes for open Windows
  33.   i3-msg -t get_tree|\
  34.     tr "," "\n"|\
  35.     grep class|\
  36.     cut -d\" -f6|\
  37.     sort -u
  38. }
  39. function getListTitle(){
  40.   #get a list of all open windows
  41.   i3-msg -t get_tree|\
  42.     tr "," "\n"|\
  43.     grep '^"title"'|\
  44.     cut -d\" -f4|\
  45.     sort -u
  46. }
  47. main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement