autostart.sh.new 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. readonly NEWS_DIR=/usr/share/parabola-laf/news
  3. readonly NEWS_STAMP=~/.local/share/parabola-laf/last_news
  4. readonly CLEANUP_MSG="These old news files are no longer needed. It is safe to delete them."
  5. readonly ROOT_WIN_ID=$(xprop -notype -root | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}')
  6. readonly WM_NAME=$( xprop -notype -id $ROOT_WIN_ID | awk '$1=="_NET_WM_NAME"{print $3}')
  7. readonly TITLE="_EDITION_TITLE_"
  8. readonly BUTTONS="OK:1,Don't show this again:0"
  9. DisplayNotice()
  10. {
  11. gxmessage -title "$TITLE" \
  12. -file $notice \
  13. -buttons "$BUTTONS" \
  14. -default "OK" \
  15. -geometry 620x460 \
  16. -center -wrap -ontop -sticky
  17. }
  18. Cleanup()
  19. {
  20. return # TODO:
  21. current_news="news-$(pacman -Si parabola-laf | awk '$1=="Version"{print $3}').txt"
  22. declare -a read_notices=( $(grep -v $current_news $NEWS_STAMP) )
  23. (( ${#read_notices[*]} > 10 )) || return
  24. gxmessage -title "Delete read news items ?" \
  25. -buttons "Keep them:1,Delete them:0" \
  26. -default "Keep them" \
  27. -geometry 620x460 \
  28. -center -wrap -ontop -sticky \
  29. "$CLEANUP_MSG$(printf "\n\t%s" "${read_notices[*]}")" && \
  30. echo $current_news > $NEWS_STAMP && \
  31. chroot $NEWS_DIR "pkexec rm ${read_notices[*]}"
  32. }
  33. # display unread news items
  34. mkdir -p $(dirname $NEWS_STAMP) ; touch $NEWS_STAMP ;
  35. cd $NEWS_DIR
  36. for notice in news-* # e.g. news-${pkgver}-${pkgrel}
  37. do [ -f $notice ] && notice_exists=1 || notice_exists=0
  38. [ -z "$(grep $notice $NEWS_STAMP)" ] && is_unread=1 || is_unread=0
  39. [ -z "$(echo $(cat $notice))" ] && is_blank=1 || is_blank=0
  40. (( $notice_exists && $is_unread )) || continue
  41. ( (( $is_blank )) || DisplayNotice ) && echo "$notice" >> $NEWS_STAMP && Cleanup &
  42. done
  43. # WM-specific startup tasks
  44. case "$WM_NAME" in
  45. '"Openbox"') which octopi-notifier && sleep 10 && octopi-notifier & ;;
  46. '"MATE"' ) ;;
  47. esac