4 # Email : hayao@fascode.net
6 # (c) 2019-2020 Fascode Network.
16 echo "usage ${0} [options]"
18 echo " General options:"
19 echo " -f | --force Force overwriting."
20 echo " -h | --help This help message and exit."
21 echo " -l | --live Opens the page only in a live environment."
22 echo " Whether it is a live environment or not is determined"
23 echo " by the presence or absence of the installer."
25 echo " --alterlive Remove the file for live session"
28 # Argument analysis and processing
31 _opt_long="force,live,help,alterlive"
32 OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
33 if [[ ${?} != 0 ]]; then
66 echo "Invalid argument '${1}'" >&2
74 if [[ "${checklive}" = true ]]; then
75 if ! pacman -Qq alterlinux-calamares 1> /dev/null 2> /dev/null; then
81 # ~/Desktopに相当するディレクトリを返します
83 local _user_config_dir _desktop_dir
84 if [[ -v XDG_CONFIG_HOME ]]; then
85 _user_config_dir="${XDG_CONFIG_HOME}"
87 _user_config_dir="${HOME}/.config"
89 if [[ -f "${_user_config_dir}/user-dirs.dirs" ]]; then
90 source "${_user_config_dir}/user-dirs.dirs"
92 if [[ -v XDG_DESKTOP_DIR ]]; then
93 _desktop_dir="${XDG_DESKTOP_DIR}"
95 _desktop_dir="${HOME}/Desktop"
97 echo -n "${_desktop_dir}"
104 for _file in "${_list[@]}"; do
105 if [[ -f ${_file} ]]; then
107 elif [[ -d ${_file} ]]; then
115 if [[ ! -f "${1}" ]]; then
116 echo "${1} was not found" >&2
119 if [[ -f "${2}/$(basename "${1}")" ]] || [[ -f "${2}" ]] && [[ "${force}" = false ]]; then
120 echo "File already exists" >&2
127 desktop_dir="$(get_desktop_dir)"
130 source_file="/usr/share/alterlinux/desktop-file/calamares.desktop"
131 desktop_icon="${desktop_dir}/$(basename "${source_file}")"
132 copy "${source_file}" "${desktop_dir}"
134 if [[ -f "/etc/os-release" ]]; then
135 source "/etc/os-release"
138 echo -n "Alter Linux"
141 sed -i "s/%OS_NAME%/${os_name}/g" "${desktop_icon}"
145 source_file="/usr/share/alterlinux/desktop-file/welcome-to-alter.desktop"
146 desktop_icon="${desktop_dir}/$(basename "${source_file}")"
147 copy "${source_file}" "${desktop_dir}"
150 if [[ "${alterlive}" = true ]]; then
151 remove "${HOME}/.config/autostart/genicon.desktop"