summarylogtreecommitdiffstats
path: root/optimus-manager.install
blob: a343b10b6be1a635eb87f1e9be93883bd2991691 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
cleanup() {

    echo "optimus-manager : removing obsolete auto-generated files left over by previous versions"
    
    # SDDM
    sddm_conf=/etc/sddm.conf.d/10-optimus-manager.conf
    if [ -f "$sddm_conf" ]; then
        rm $sddm_conf
    fi
    
    sddm_xsetup=/usr/share/sddm/scripts/Xsetup
    if [ -f "$sddm_conf" ]; then
        printf "#!/bin/sh\n# Xsetup - run as root before the login dialog appears\n" > "$sddm_xsetup"
        chmod 755 "$sddm_xsetup"
    fi

    # LightDM
    lightdm_conf=/etc/lightdm/lightdm.conf.d/10-optimus-manager.conf
    if [ -f "$lightdm_conf" ]; then
        rm $lightdm_conf
    fi

    # GDM
    gdm_file_1=/usr/share/gdm/greeter/autostart/optimus-manager-xsetup.desktop
    if [ -f "$gdm_file_1" ]; then
        rm $gdm_file_1
    fi

    gdm_file_2=/etc/xdg/autostart/optimus-manager-xsetup.desktop
    if [ -f "$gdm_file_2" ]; then
        rm $gdm_file_2
    fi

    # Xorg
    xorg_conf=/etc/X11/xorg.conf.d/10-optimus-manager.conf
    if [ -f "$xorg_conf" ]; then
        rm $xorg_conf
    fi
}

make_log_folder() {
    LOGDIR=/var/log/optimus-manager/
    mkdir -p "$LOGDIR"
    chmod 777 "$LOGDIR"
}

pre_install() {
    cleanup
}

post_install() {

    echo "optimus-manager : enabling optimus-manager.service"
    mkdir -p /etc/systemd/system/graphical.target.wants/
    ln -s /usr/lib/systemd/system/optimus-manager.service /etc/systemd/system/graphical.target.wants/optimus-manager.service
    
    make_log_folder
    
    bold=$(tput bold)
    red=$(tput setaf 1)
    normal=$(tput sgr0)
    echo "${bold}${red}Please reboot your computer before using optimus-manager${normal}"

}

pre_upgrade() {
    cleanup
    
}

post_upgrade() {

    make_log_folder
    
    bold=$(tput bold)
    red=$(tput setaf 1)
    normal=$(tput sgr0)
    echo "${bold}${red}optimus-manager : warning : power management is disabled by default since v1.2. See https://github.com/Askannz/optimus-manager/wiki/A-guide--to-power-management-options${normal}"
}

post_remove() {

	echo "optimus-manager : cleaning up auto-generated Xorg conf"

    xorg_conf=/etc/X11/xorg.conf.d/10-optimus-manager.conf
    if [ -f "$xorg_conf" ]; then
        rm $xorg_conf
    fi

    echo "optimus-manager : disabling optimus-manager.service"

    service_file_link=/etc/systemd/system/graphical.target.wants/optimus-manager.service
    if [ -L "$service_file_link" ]; then
        rm $service_file_link
    fi

}