OSDN Git Service

[add] : auto open webpage
authorhayao <shun819.mail@gmail.com>
Sun, 26 Jul 2020 05:56:59 +0000 (14:56 +0900)
committerhayao <shun819.mail@gmail.com>
Sun, 26 Jul 2020 05:57:03 +0000 (14:57 +0900)
channels/cinnamon/airootfs.any/etc/skel/.config/autostart/welcome_page.desktop [new file with mode: 0755]
channels/cinnamon/airootfs.any/usr/local/bin/alterlinux-welcome-page [new file with mode: 0755]
channels/lxde/airootfs.any/etc/skel/.config/autostart/welcome_page.desktop [new file with mode: 0755]
channels/lxde/airootfs.any/usr/local/bin/alterlinux-welcome-page [new file with mode: 0755]
channels/plasma/airootfs.any/etc/skel/.config/autostart/welcome_page.desktop [new file with mode: 0755]
channels/plasma/airootfs.any/usr/local/bin/alterlinux-welcome-page [new file with mode: 0755]

diff --git a/channels/cinnamon/airootfs.any/etc/skel/.config/autostart/welcome_page.desktop b/channels/cinnamon/airootfs.any/etc/skel/.config/autostart/welcome_page.desktop
new file mode 100755 (executable)
index 0000000..16986fa
--- /dev/null
@@ -0,0 +1,13 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Name=Welcome to AlterLinux
+Comment=Displays the AlterLinux welcome page.
+Icon=utilities-terminal
+Exec=/usr/local/bin/alterlinux-welcome-page -l --alterlive
+X-GNOME-Autostart-enabled=true
+Type=Application
+RunHook=0
+StartupNotify=false
+Terminal=false
+Hidden=false
diff --git a/channels/cinnamon/airootfs.any/usr/local/bin/alterlinux-welcome-page b/channels/cinnamon/airootfs.any/usr/local/bin/alterlinux-welcome-page
new file mode 100755 (executable)
index 0000000..10e32bf
--- /dev/null
@@ -0,0 +1,130 @@
+#!/usr/bin/env bash
+# Yamada Hayao
+# Twitter: @Hayao0819
+# Email  : hayao@fascode.net
+#
+# (c) 2019-2020 Fascode Network.
+#
+
+set -e
+
+checklive=false
+alterlive=false
+url="https://fascode.net/en/projects/linux/alter/welcome.php"
+browser="chromium --start-maximized %s"
+custombrowser=false
+
+defaultbrowserlist=(
+    "firefox %s"
+    "chromium --start-maximized %s"
+    "google-chrome  --start-maximized %s"
+)
+
+remove () {
+    local _list
+    local _file
+    _list=($(echo "$@"))
+    for _file in "${_list[@]}"; do
+        if [[ -f ${_file} ]]; then
+            rm -f "${_file}"
+        elif [[ -d ${_file} ]]; then
+            rm -rf "${_file}"
+        fi
+    done
+}
+
+_help() {
+    echo "Displays the AlterLinux welcome page"
+    echo "usage alterlinux-welcome-page [options]"
+    echo
+    echo " General options:"
+    echo "    -b | --browser <cmd>  Specify the browser command."
+    echo "                          %s will be replaced with the URL"
+    echo "                          Default: ${browser}"
+    echo "    -u | --url <url>      Set the URL."
+    echo "                          Default: ${url}"
+    echo
+    echo "    -l | --live           Opens the page only in a live environment."
+    echo "    -h | --help           This help message and exit."
+}
+
+_msg_error() {
+    echo "${@}" >&2
+}
+
+
+# Argument analysis and processing
+options="${@}"
+_opt_short="b:u:lh"
+_opt_long="browser:,url:,live,help,alterlive"
+OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
+if [[ ${?} != 0 ]]; then
+    exit 1
+fi
+
+eval set -- "${OPT}"
+unset OPT
+unset _opt_short
+unset _opt_long
+
+while true; do
+    case ${1} in
+        -b | --browser)
+            browser="${2}"
+            custombrowser=true
+            shift 2
+            ;;
+        -l | --live)
+            checklive=true
+            shift 1
+            ;;
+        -u | --url)
+            url="${2}"
+            shift 2
+            ;;
+        -h | --help)
+            _help
+            shift 1
+            exit 0
+            ;;
+        --alterlive)
+            alterlive=true
+            shift 1
+            ;;
+        --)
+            shift
+            break
+            ;;
+        *)
+            _msg_error "Invalid argument '${1}'"
+            _help
+            exit 1
+            ;;
+    esac
+done
+
+if [[ "${checklive}" = true ]]; then
+    if [[ -n $(pacman -Q alterlinux-calamares) ]]; then
+        exit 0
+    fi
+fi
+
+if [[ "${custombrowser}" = false ]]; then
+    defaultbrowserlist+=("END_OF_LIST")
+    for ((_browser_count = 0; _browser_count < ${#defaultbrowserlist[@]}; _browser_count++)); do
+        _browser="${defaultbrowserlist[${_browser_count}]}"
+        if [[ -f $(type -P "$(echo ${_browser} | awk '{print $1}')") ]]; then
+            browser="${_browser}"
+            break
+        elif [[ "${_browser}" == "END_OF_LIST" ]]; then
+            _msg_error "No available browser is installed."
+            exit 1
+        fi
+    done
+fi
+
+$(printf "${browser}" "${url}")
+
+if [[ "${alterlive}" = true ]]; then
+    remove ~/.config/autostart/welcome_page.desktop
+fi
diff --git a/channels/lxde/airootfs.any/etc/skel/.config/autostart/welcome_page.desktop b/channels/lxde/airootfs.any/etc/skel/.config/autostart/welcome_page.desktop
new file mode 100755 (executable)
index 0000000..16986fa
--- /dev/null
@@ -0,0 +1,13 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Name=Welcome to AlterLinux
+Comment=Displays the AlterLinux welcome page.
+Icon=utilities-terminal
+Exec=/usr/local/bin/alterlinux-welcome-page -l --alterlive
+X-GNOME-Autostart-enabled=true
+Type=Application
+RunHook=0
+StartupNotify=false
+Terminal=false
+Hidden=false
diff --git a/channels/lxde/airootfs.any/usr/local/bin/alterlinux-welcome-page b/channels/lxde/airootfs.any/usr/local/bin/alterlinux-welcome-page
new file mode 100755 (executable)
index 0000000..10e32bf
--- /dev/null
@@ -0,0 +1,130 @@
+#!/usr/bin/env bash
+# Yamada Hayao
+# Twitter: @Hayao0819
+# Email  : hayao@fascode.net
+#
+# (c) 2019-2020 Fascode Network.
+#
+
+set -e
+
+checklive=false
+alterlive=false
+url="https://fascode.net/en/projects/linux/alter/welcome.php"
+browser="chromium --start-maximized %s"
+custombrowser=false
+
+defaultbrowserlist=(
+    "firefox %s"
+    "chromium --start-maximized %s"
+    "google-chrome  --start-maximized %s"
+)
+
+remove () {
+    local _list
+    local _file
+    _list=($(echo "$@"))
+    for _file in "${_list[@]}"; do
+        if [[ -f ${_file} ]]; then
+            rm -f "${_file}"
+        elif [[ -d ${_file} ]]; then
+            rm -rf "${_file}"
+        fi
+    done
+}
+
+_help() {
+    echo "Displays the AlterLinux welcome page"
+    echo "usage alterlinux-welcome-page [options]"
+    echo
+    echo " General options:"
+    echo "    -b | --browser <cmd>  Specify the browser command."
+    echo "                          %s will be replaced with the URL"
+    echo "                          Default: ${browser}"
+    echo "    -u | --url <url>      Set the URL."
+    echo "                          Default: ${url}"
+    echo
+    echo "    -l | --live           Opens the page only in a live environment."
+    echo "    -h | --help           This help message and exit."
+}
+
+_msg_error() {
+    echo "${@}" >&2
+}
+
+
+# Argument analysis and processing
+options="${@}"
+_opt_short="b:u:lh"
+_opt_long="browser:,url:,live,help,alterlive"
+OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
+if [[ ${?} != 0 ]]; then
+    exit 1
+fi
+
+eval set -- "${OPT}"
+unset OPT
+unset _opt_short
+unset _opt_long
+
+while true; do
+    case ${1} in
+        -b | --browser)
+            browser="${2}"
+            custombrowser=true
+            shift 2
+            ;;
+        -l | --live)
+            checklive=true
+            shift 1
+            ;;
+        -u | --url)
+            url="${2}"
+            shift 2
+            ;;
+        -h | --help)
+            _help
+            shift 1
+            exit 0
+            ;;
+        --alterlive)
+            alterlive=true
+            shift 1
+            ;;
+        --)
+            shift
+            break
+            ;;
+        *)
+            _msg_error "Invalid argument '${1}'"
+            _help
+            exit 1
+            ;;
+    esac
+done
+
+if [[ "${checklive}" = true ]]; then
+    if [[ -n $(pacman -Q alterlinux-calamares) ]]; then
+        exit 0
+    fi
+fi
+
+if [[ "${custombrowser}" = false ]]; then
+    defaultbrowserlist+=("END_OF_LIST")
+    for ((_browser_count = 0; _browser_count < ${#defaultbrowserlist[@]}; _browser_count++)); do
+        _browser="${defaultbrowserlist[${_browser_count}]}"
+        if [[ -f $(type -P "$(echo ${_browser} | awk '{print $1}')") ]]; then
+            browser="${_browser}"
+            break
+        elif [[ "${_browser}" == "END_OF_LIST" ]]; then
+            _msg_error "No available browser is installed."
+            exit 1
+        fi
+    done
+fi
+
+$(printf "${browser}" "${url}")
+
+if [[ "${alterlive}" = true ]]; then
+    remove ~/.config/autostart/welcome_page.desktop
+fi
diff --git a/channels/plasma/airootfs.any/etc/skel/.config/autostart/welcome_page.desktop b/channels/plasma/airootfs.any/etc/skel/.config/autostart/welcome_page.desktop
new file mode 100755 (executable)
index 0000000..16986fa
--- /dev/null
@@ -0,0 +1,13 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Name=Welcome to AlterLinux
+Comment=Displays the AlterLinux welcome page.
+Icon=utilities-terminal
+Exec=/usr/local/bin/alterlinux-welcome-page -l --alterlive
+X-GNOME-Autostart-enabled=true
+Type=Application
+RunHook=0
+StartupNotify=false
+Terminal=false
+Hidden=false
diff --git a/channels/plasma/airootfs.any/usr/local/bin/alterlinux-welcome-page b/channels/plasma/airootfs.any/usr/local/bin/alterlinux-welcome-page
new file mode 100755 (executable)
index 0000000..10e32bf
--- /dev/null
@@ -0,0 +1,130 @@
+#!/usr/bin/env bash
+# Yamada Hayao
+# Twitter: @Hayao0819
+# Email  : hayao@fascode.net
+#
+# (c) 2019-2020 Fascode Network.
+#
+
+set -e
+
+checklive=false
+alterlive=false
+url="https://fascode.net/en/projects/linux/alter/welcome.php"
+browser="chromium --start-maximized %s"
+custombrowser=false
+
+defaultbrowserlist=(
+    "firefox %s"
+    "chromium --start-maximized %s"
+    "google-chrome  --start-maximized %s"
+)
+
+remove () {
+    local _list
+    local _file
+    _list=($(echo "$@"))
+    for _file in "${_list[@]}"; do
+        if [[ -f ${_file} ]]; then
+            rm -f "${_file}"
+        elif [[ -d ${_file} ]]; then
+            rm -rf "${_file}"
+        fi
+    done
+}
+
+_help() {
+    echo "Displays the AlterLinux welcome page"
+    echo "usage alterlinux-welcome-page [options]"
+    echo
+    echo " General options:"
+    echo "    -b | --browser <cmd>  Specify the browser command."
+    echo "                          %s will be replaced with the URL"
+    echo "                          Default: ${browser}"
+    echo "    -u | --url <url>      Set the URL."
+    echo "                          Default: ${url}"
+    echo
+    echo "    -l | --live           Opens the page only in a live environment."
+    echo "    -h | --help           This help message and exit."
+}
+
+_msg_error() {
+    echo "${@}" >&2
+}
+
+
+# Argument analysis and processing
+options="${@}"
+_opt_short="b:u:lh"
+_opt_long="browser:,url:,live,help,alterlive"
+OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- "${@}")
+if [[ ${?} != 0 ]]; then
+    exit 1
+fi
+
+eval set -- "${OPT}"
+unset OPT
+unset _opt_short
+unset _opt_long
+
+while true; do
+    case ${1} in
+        -b | --browser)
+            browser="${2}"
+            custombrowser=true
+            shift 2
+            ;;
+        -l | --live)
+            checklive=true
+            shift 1
+            ;;
+        -u | --url)
+            url="${2}"
+            shift 2
+            ;;
+        -h | --help)
+            _help
+            shift 1
+            exit 0
+            ;;
+        --alterlive)
+            alterlive=true
+            shift 1
+            ;;
+        --)
+            shift
+            break
+            ;;
+        *)
+            _msg_error "Invalid argument '${1}'"
+            _help
+            exit 1
+            ;;
+    esac
+done
+
+if [[ "${checklive}" = true ]]; then
+    if [[ -n $(pacman -Q alterlinux-calamares) ]]; then
+        exit 0
+    fi
+fi
+
+if [[ "${custombrowser}" = false ]]; then
+    defaultbrowserlist+=("END_OF_LIST")
+    for ((_browser_count = 0; _browser_count < ${#defaultbrowserlist[@]}; _browser_count++)); do
+        _browser="${defaultbrowserlist[${_browser_count}]}"
+        if [[ -f $(type -P "$(echo ${_browser} | awk '{print $1}')") ]]; then
+            browser="${_browser}"
+            break
+        elif [[ "${_browser}" == "END_OF_LIST" ]]; then
+            _msg_error "No available browser is installed."
+            exit 1
+        fi
+    done
+fi
+
+$(printf "${browser}" "${url}")
+
+if [[ "${alterlive}" = true ]]; then
+    remove ~/.config/autostart/welcome_page.desktop
+fi