summaryrefslogtreecommitdiffstats
path: root/etc/xdg/plasma-workspace/env/plasma5-firstsetup.sh
blob: 36f23fdcf1fd68c4222d356ec0be4b3a12636232 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash

#
# TODO: Factorize for Mageia 2
#

KRCFG="$(which kreadconfig5)"

if [ ! -z "$KRCFG" ]; then # Check if kde is installed, otherwise do nothing

    # "Desktop" Mageia icons"
    MGADESK=$(kreadconfig5 --group "Mageia" --key "MageiaDesktopFiles" --default "false")

    if [ ! "$MGADESK" = "true" ]; then
        # TODO: We need to handle default => Default too 
        PROD=$(sed 's/.*product=\(.*\)/\L\1/' < /etc/product.id)
        # We should handle i18n dir modes in xgd user dirs
        DIR=$(eval "echo $(kreadconfig5 --file $HOME/.config/user-dirs.dirs --key XDG_DESKTOP_DIR)" )
        if [ -z "${DIR}" ]; then
            DIR="$HOME/Desktop"
        fi

        if [ ! -d "${DIR}" ]; then
            mkdir -p "${DIR}"
        fi

        if [ -n "$PROD" -a -d "/usr/share/dist/desktop-files/${PROD}" ]; then  
            cp -f /usr/share/dist/desktop-files/${PROD}/*.desktop "${DIR}"
        fi

        # Copy the "Trash" icon on the desktop
        cp -f /usr/share/kio_desktop/directory.trash "${DIR}/org.kde.trash.desktop"

        kwriteconfig5 --group "Mageia" --key "MageiaDesktopFiles" --type "bool" 1
    fi

    # Add .directory to XDG_*_DIR
    ICONSXDGDIR=$(kreadconfig5 --group "Mageia" --key "IconsXdgDir" --default "false")

    if [ ! "$ICONSXDGDIR" = "true" ]; then

        MUSICDIR=$(eval "echo $(kreadconfig5 --file $HOME/.config/user-dirs.dirs --key XDG_MUSIC_DIR)" )
        if [ -z "$MUSICDIR" ]; then
            MUSICDIR="$HOME/Music"
        fi

        if [ ! -e "$MUSICDIR/.directory" ]; then
            cat >> "$MUSICDIR/.directory" << EOF
[Desktop Entry]
Hidden=true
Icon=folder-sound
EOF
        fi


        DLDIR=$(eval "echo $(kreadconfig5 --file $HOME/.config/user-dirs.dirs --key XDG_DOWNLOAD_DIR)" )
        if [ -z "$DLDIR" ]; then
            DLDIR="$HOME/Downloads"
        fi

        if [ ! -e "$DLDIR/.directory" ]; then
            cat >> "$DLDIR/.directory" << EOF
[Desktop Entry]
Hidden=true
Icon=folder-downloads
EOF
        fi


        DOCDIR=$(eval "echo $(kreadconfig5 --file $HOME/.config/user-dirs.dirs --key XDG_DOCUMENTS_DIR)" )
        if [ -z "$DOCDIR" ]; then
            DOCDIR="$HOME/Documents"
        fi

        if [ ! -e "$DOCDIR/.directory" ]; then
            cat >> "$DOCDIR/.directory" << EOF
[Desktop Entry]
Hidden=true
Icon=folder-documents
EOF
        fi


        PICTUREDIR=$(eval "echo $(kreadconfig5 --file $HOME/.config/user-dirs.dirs --key XDG_PICTURES_DIR)" )
        if [ -z "$PICTUREDIR" ]; then
            PICTUREDIR="$HOME/Pictures"
        fi

        if [ ! -e "$PICTUREDIR/.directory" ]; then
            cat >> "$PICTUREDIR/.directory" << EOF
[Desktop Entry]
Hidden=true
Icon=folder-image
EOF
        fi


        VIDEOSDIR=$(eval "echo $(kreadconfig5 --file $HOME/.config/user-dirs.dirs --key XDG_VIDEOS_DIR)" )
        if [ -z "$VIDEOSDIR" ]; then
            VIDEOSDIR="$HOME/Videos"
        fi

        if [ ! -e "$VIDEOSDIR/.directory" ]; then
            cat >> "$VIDEOSDIR/.directory" << EOF
[Desktop Entry]
Hidden=true
Icon=folder-video
EOF
        fi
        kwriteconfig5 --group "Mageia" --key "IconsXdgDir" --type "bool" 1
    fi

# end of main if: all the changes should be done inside this main if
fi