Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. DMENU="rofi -p SaveLayout: -bg #922713 -dmenu"
  4. if ! command -v "jshon" >/dev/null 2>&1; then
  5. printf "%s\\n" "you need to install 'jshon' to run this program" >&2
  6. exit 1
  7. fi
  8.  
  9. if ! command -v "rofi" >/dev/null 2>&1; then
  10. printf "%s\\n" "you need to install 'rofi' to run this program" >&2
  11. exit 1
  12. fi
  13.  
  14. LNAME="$(ls ~/.i3/layouts | ${DMENU})"
  15.  
  16. if [ -z "$LNAME" ]; then
  17. echo 1
  18. exit 1
  19. else
  20. echo $LNAME
  21.  
  22. echo '// vim:ts=4:sw=4:et
  23. {
  24. // this is a manually added container to restore the vertical split
  25. "layout": "splith",
  26. "percent": 0.5,
  27. "type": "con",
  28. "nodes": [
  29.  
  30. ' > ~/.i3/layouts/${LNAME}
  31.  
  32. WORKSPACE="$(i3-msg -t get_workspaces | jshon -a -e focused -u -p -e name -u | awk 'f{print;f=0} /true/{f=1}')"
  33.  
  34. ## Last sed is for some few problems with save-tree returning "} {" without
  35. ## comma, i dunno regexp but "multi document" json wont fix itself.
  36. i3-save-tree --workspace ${WORKSPACE} | sed 's/\/\/[ ]"class":[ ]"\(.*\)",/"class": "\1"/g' | sed ':a;N;$!ba;s/}\n\n{/},\n{/g' >> ~/.i3/layouts/${LNAME}
  37.  
  38. echo '
  39. ]
  40. }
  41. ' >> ~/.i3/layouts/${LNAME}
  42. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement