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