packaging files for QtCreator added
[kitchenalert] / src / qtc_packaging / debian_fremantle / kitchenalert.postinst
1 #! /bin/sh
2
3 set -e
4
5 gtk-update-icon-cache /usr/share/icons/hicolor
6
7 #check whether the needed sound systen settings are already in place
8
9 if ! grep -q KitchenAlert /usr/share/policy/etc/current/pulse/xpolicy.conf
10
11 then
12
13 #checks whether there is a newline at the end of the file and adds one if there is not and then
14 #checks if there is an ampty line at the end of the file and add one if there is not
15
16 perl -e 'use strict;' \
17 -e 'use warnings;' \
18 -e 'open(my $in,  "<",  "/usr/share/policy/etc/current/pulse/xpolicy.conf")  or die "Cannot open /usr/share/policy/etc/current/pulse/xpolicy.conf: $!";' \
19 -e 'my @lines = <$in>;' \
20 -e 'my $lastlineishere = $#lines;' \
21 -e 'my $lastline = $lines[$lastlineishere];' \
22 -e 'unless ($lastline =~ /\n$/){open(my $log, ">>", "/usr/share/policy/etc/current/pulse/xpolicy.conf") or die "Cannot open /usr/share/policy/etc/current/pulse/xpolicy.conf: $!"; print $log "\n"; }' \
23 -e 'unless ($lastline =~ /^\n$/){open(my $log, ">>", "/usr/share/policy/etc/current/pulse/xpolicy.conf") or die "Cannot open /usr/share/policy/etc/current/pulse/xpolicy.conf: $!"; print $log "\n"; }'
24
25 #writes the sound system settings needed
26
27 echo -e "[stream]\n\
28 exe     = KitchenAlert\n\
29 group   = alarm" >> /usr/share/policy/etc/current/pulse/xpolicy.conf
30
31 #restarts the pulseaudio so that the above changed settings take effect
32 #this interrupts all playing sounds (they do not resume play at restart)
33  
34 stop pulseaudio
35 start pulseaudio
36
37 # give the default save directory to user "user" so it can be written to from the application 
38 # (autocreating with kitchenalert.dirs gives it to root with no access rights to user)
39 chown user /home/user/KitchenAlert
40
41 fi
42
43 exit 0
44