From 6044e99716387884e79975b4954f8c163f76ecba Mon Sep 17 00:00:00 2001 From: bill-auger Date: Fri, 18 May 2018 19:50:45 -0400 Subject: autostart script to bin/ --- bin/autostart.sh | 61 ++++++++++++++++++++++++++++++++ etc/xdg/autostart/autostart.desktop | 5 +++ skel/.config/autostart/autostart.desktop | 6 +--- skel/.config/autostart/autostart.sh | 56 ----------------------------- skel/.config/autostart/autostart.sh.new | 57 ----------------------------- 5 files changed, 67 insertions(+), 118 deletions(-) create mode 100755 bin/autostart.sh create mode 100644 etc/xdg/autostart/autostart.desktop mode change 100644 => 120000 skel/.config/autostart/autostart.desktop delete mode 100755 skel/.config/autostart/autostart.sh delete mode 100755 skel/.config/autostart/autostart.sh.new diff --git a/bin/autostart.sh b/bin/autostart.sh new file mode 100755 index 0000000..db0b790 --- /dev/null +++ b/bin/autostart.sh @@ -0,0 +1,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 & ;; + '"MATE"' ) ;; +esac diff --git a/etc/xdg/autostart/autostart.desktop b/etc/xdg/autostart/autostart.desktop new file mode 100644 index 0000000..abb6d1a --- /dev/null +++ b/etc/xdg/autostart/autostart.desktop @@ -0,0 +1,5 @@ +[Desktop Entry] +Type=Application +Name=Parabola Autostart Script +Exec=/usr/bin/autostart.sh +Terminal=false diff --git a/skel/.config/autostart/autostart.desktop b/skel/.config/autostart/autostart.desktop deleted file mode 100644 index 8d02256..0000000 --- a/skel/.config/autostart/autostart.desktop +++ /dev/null @@ -1,5 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Parabola Autostart Script -Exec=.config/autostart/autostart.sh -Terminal=false diff --git a/skel/.config/autostart/autostart.desktop b/skel/.config/autostart/autostart.desktop new file mode 120000 index 0000000..2e58940 --- /dev/null +++ b/skel/.config/autostart/autostart.desktop @@ -0,0 +1 @@ +/etc/xdg/autostart/autostart.desktop \ No newline at end of file diff --git a/skel/.config/autostart/autostart.sh b/skel/.config/autostart/autostart.sh deleted file mode 100755 index 91be332..0000000 --- a/skel/.config/autostart/autostart.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/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}') - - -DisplayNotice() -{ - gxmessage -title "_EDITION_TITLE_" \ - -file $notice \ - -buttons "OK:1,Don't show this again:0" \ - -default "OK" \ - -geometry 620x460 \ - -center -wrap -ontop -sticky -} - -Cleanup() -{ - return # TODO: - - 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 - '"LXDE"') which octopi-notifier && sleep 10 && octopi-notifier & ;; - '"MATE"') ;; -esac diff --git a/skel/.config/autostart/autostart.sh.new b/skel/.config/autostart/autostart.sh.new deleted file mode 100755 index cb98c05..0000000 --- a/skel/.config/autostart/autostart.sh.new +++ /dev/null @@ -1,57 +0,0 @@ -#!/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() -{ - gxmessage -title "$TITLE" \ - -file $notice \ - -buttons "$BUTTONS" \ - -default "OK" \ - -geometry 620x460 \ - -center -wrap -ontop -sticky -} - -Cleanup() -{ - return # TODO: - - 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 & ;; - '"MATE"' ) ;; -esac -- cgit v1.2.2