summarylogtreecommitdiffstats
path: root/fcitx5-mozc.install
blob: 8e2931397bdffe6515e3506651727e9ee74e84c4 (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
install_if_not_exists() {
    [ -z $SUDO_USER ] && SUDO_USER=$(who|head -n1|cut -f1 -d" ")
    [ -z $SUDO_HOME ] && SUDO_HOME=$(eval echo ~$SUDO_USER)
    src_path=$1
    dest_path=$2
    if [ ! -e $dest_path ];then
      install -D -m 644 $src_path $dest_path
    fi
}

install_as_user_if_not_exists() {
    [ -z $SUDO_USER ] && SUDO_USER=$(who|head -n1|cut -f1 -d" ")
    [ -z $SUDO_HOME ] && SUDO_HOME=$(eval echo ~$SUDO_USER)
    src_path=$1
    dest_path=$2
    if [ ! -e $dest_path ];then
      SUDO_GROUP=$(id -gn $SUDO_USER)
      install -o $SUDO_USER -g $SUDO_GROUP -D -m 644 $src_path $dest_path
    fi
}

post_install() {
    [ -z $SUDO_USER ] && SUDO_USER=$(who|head -n1|cut -f1 -d" ")
    [ -z $SUDO_HOME ] && SUDO_HOME=$(eval echo ~$SUDO_USER)
    install_if_not_exists /usr/share/fcitx5-mozc/fcitx5/profile /etc/skel/.config/fcitx5/profile 
    sudo -u $SUDO_USER mkdir -p $SUDO_HOME/.config/fcitx5/conf
    mkdir -p /etc/skel/.config/fcitx5/conf
    install_as_user_if_not_exists /usr/share/fcitx5-mozc/fcitx5/profile $SUDO_HOME/.config/fcitx5/profile
    install_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/notifications.conf /etc/skel/.config/fcitx5/conf/notifications.conf
    install_as_user_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/notifications.conf $SUDO_HOME/.config/fcitx5/conf/notifications.conf
    install_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/waylandim.conf /etc/skel/.config/fcitx5/conf/waylandim.conf
    install_as_user_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/waylandim.conf $SUDO_HOME/.config/fcitx5/conf/waylandim.conf
    install_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/xim.conf /etc/skel/.config/fcitx5/conf/xim.conf
    install_as_user_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/xim.conf $SUDO_HOME/.config/fcitx5/conf/xim.conf
    install_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/mozc.conf /etc/skel/.config/fcitx5/conf/mozc.conf
    install_as_user_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/mozc.conf $SUDO_HOME/.config/fcitx5/conf/mozc.conf
}

post_upgrade() {
    [ -z $SUDO_USER ] && SUDO_USER=$(who|head -n1|cut -f1 -d" ")
    [ -z $SUDO_HOME ] && SUDO_HOME=$(eval echo ~$SUDO_USER)
    install_if_not_exists /usr/share/fcitx5-mozc/fcitx5/profile /etc/skel/.config/fcitx5/profile 
    sudo -u $SUDO_USER mkdir -p $SUDO_HOME/.config/fcitx5/conf
    mkdir -p /etc/skel/.config/fcitx5/conf
    install_as_user_if_not_exists /usr/share/fcitx5-mozc/fcitx5/profile $SUDO_HOME/.config/fcitx5/profile
    install_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/notifications.conf /etc/skel/.config/fcitx5/conf/notifications.conf
    install_as_user_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/notifications.conf $SUDO_HOME/.config/fcitx5/conf/notifications.conf
    install_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/waylandim.conf /etc/skel/.config/fcitx5/conf/waylandim.conf
    install_as_user_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/waylandim.conf $SUDO_HOME/.config/fcitx5/conf/waylandim.conf
    install_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/xim.conf /etc/skel/.config/fcitx5/conf/xim.conf
    install_as_user_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/xim.conf $SUDO_HOME/.config/fcitx5/conf/xim.conf
    install_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/mozc.conf /etc/skel/.config/fcitx5/conf/mozc.conf
    install_as_user_if_not_exists /usr/share/fcitx5-mozc/fcitx5/conf/mozc.conf $SUDO_HOME/.config/fcitx5/conf/mozc.conf
}