pnote 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. #pNote
  3. #Copyright 2010,2011,2014
  4. #Sigmund Berglund - Valåmoen, Norway.
  5. #------------------------------
  6. #This program 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 version 2.
  7. #This program 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. <http://www.gnu.org/licenses/>.
  8. #------------------------------
  9. BG=$1; [ ! "$BG" ] && BG='#FFF4AF'
  10. FG=$2; [ ! "$FG" ] && FG='#222222'
  11. VERSION=0.3
  12. set -a
  13. check_exit (){
  14. #because of focus-trouble in jwm-tray, this workaround is required. might be jwm-version specific
  15. if [ `getcurpos | cut -d' ' -f1` -gt 250 ] || [ `getcurpos | cut -d' ' -f2` -gt $HEIGHT ]; then
  16. echo -n "$PAD" > $HOME/.pnote
  17. for I in `ps | grep -wF pNote | awk '{print $1}'`; do kill -9 $I; done
  18. exit
  19. fi
  20. }
  21. #set colored background
  22. echo 'style "menu" {
  23. font_name = "DejaVu sans italic 12"
  24. bg[NORMAL] = "'$BG'"
  25. base[NORMAL] = "'$BG'"
  26. text[NORMAL] = "'$FG'"
  27. }
  28. class "*" style "menu"' > /tmp/gtkrc
  29. export GTK2_RC_FILES=/tmp/gtkrc:/root/.gtkrc-2.0
  30. #find height of screen
  31. TMP=`xwininfo -root | grep -m 1 '\geometry' | cut -f4 -d ' ' | cut -f2 -d 'x' | cut -f1 -d '+'`
  32. HEIGHT=$((TMP-27)) #minus main-tray
  33. [ ! "$HEIGHT" ] && HEIGHT=571 #in case
  34. #run app
  35. export pNote='
  36. <window title="pNote" width-request="250" height-request="'$HEIGHT'" decorated="false">
  37. <edit left-margin="5" wrap-mode="2"><variable>PAD</variable><input file>'$HOME'/.pnote</input></edit>
  38. <action signal="leave-notify-event">echo "$PAD" | xclip -i -selection clipboard</action>
  39. <action signal="leave-notify-event">check_exit</action>
  40. </window>'
  41. gtkdialog -p pNote -G +0+0