5 # Email : hayao@fascode.net
7 # (c) 2019-2021 Fascode Network.
11 # LICENSE: THE SUSHI-WARE LICENSE
12 # https://github.com/MakeNowJust/sushi-ware
16 # https://qiita.com/laikuaut/items/4bc07eabce56ee30812d
17 # https://qiita.com/t_nakayama0714/items/80b4c94de43643f4be51
19 SCRIPT_PATH="$( cd -P "$( dirname "$(readlink -f "${0}")" )" && pwd )"
22 echo "usage: dmc [options] [command]"
24 echo "A simple tool for switching LightDM Greeters"
26 echo " General command:"
27 echo " dm [display manager] Set display manager"
28 echo " [mode] [command] You can specify the mode as a command"
30 echo " LightDM command:"
31 echo " autologin [username] [session] Set up automatic login (with blank username to disable)"
32 echo " greeter Run greeter setup wizard"
33 echo " greeter-create [file] Set the specified executable file as Greeter"
34 echo " greeter-change [greeter] Specify the greeter to use"
35 echo " greeter-edit [greeter] Edit the greeter configs"
36 echo " greeter-list Show a list of currently installed Greeters"
37 echo " remove Removes all changes made by this command"
38 echo " edit Edit lightdm config"
39 echo " show-config Show current settings"
42 echo " autologin [username] [session] Set up automatic login (with blank username to disable)"
43 echo " cursor Run cursor selection wizard"
44 echo " cursor-change [cursor] Specify the cursor theme"
45 echo " cursor-list Show a list of cursor theme"
46 echo " sound [true or false] Toggle the sound when an event occurs"
47 echo " logo [image] Specify the logo of the login screen"
48 echo " tap [true or false] Toggle whether to recognize the tap as a click"
49 echo " accessibility [true or false] Toggle whether to show accessibility menu"
50 echo " root-login [true or false] Toggle whether to enable root login"
52 echo " Webkit2 command:"
53 echo " theme Run theme selection wizard"
54 echo " theme-change [theme] Specify the theme"
56 echo " Qtquick command:"
57 echo " back Specify the background image"
59 echo " Slick command:"
60 echo " back [image] Specify the background image"
61 echo " grid [true or false] Toggle whether to show grid"
62 echo " icon Run icon theme selection wizard"
63 echo " gtk Run gtk theme selection wizard"
64 echo " gtk-change [theme] Specify gtk theme"
67 echo " autologin [username] [session] Set up automatic login (with blank username to disable)"
68 echo " cursor Run cursor selection wizard"
69 echo " cursor-change [cursor] Specify the cursor theme"
70 echo " numlock [true or false] Toggle whether to enable Numlock force"
71 echo " tty [int number] The lowest virtual terminal number that will be used"
72 echo " theme Run theme selection wizard"
73 echo " theme-change [theme] Specify the theme"
76 echo " autologin [username] [session] Set up automatic login (with blank username to disable)"
77 echo " back [image] Specify the background image"
78 echo " session Run default session selection wizard"
79 echo " session-change [session] Specify the default session"
80 echo " remove-last Remove last selected setting"
81 echo " edit-script Edit the script"
82 echo " gtk Run gtk theme selection wizard"
83 echo " gtk-change [theme] Specify gtk theme"
85 echo " General option:"
86 echo " -G | --lightdm-greeter Automatically get the current greeter and set as mode (Only LightDM)"
87 echo " -m | --mode [mode name] Specifiy the target you want to set"
88 echo " -e | --editer [editor path] Specifiy the editor to use for editing"
89 echo " -h | --help This help message and exit"
90 echo " --non-interactive Run in non-interactive mode"
91 echo " --no-check-target No check the target for the selected mode"
92 echo " --noroot No check root permission"
93 echo " --write-all-files Allows rewriting of all configuration files"
95 echo " Supported modes:"
96 echo " Display managers: lightdm, gdm, sddm, lxdm"
97 echo " LightDM greeters: webkit2, qtquick, slick, gtkg"
99 echo " Default mode: ${DISPLAY_MANAGER}"
101 echo " This tool is incomplete and still under development."
102 echo " If you find a bug, please report it on GitHub."
103 echo " https://github.com/FascodeNet/dmc"
121 if [[ "${NOROOT}" = false ]] && (( "${UID}" != 0 )); then
122 msg_error "You have to run as root"
130 #if (( "$(expr "${1}" + 1 >/dev/null 2>&1; printf "${?}")" < 2 )); then
131 if printf "%s" "${1}" | grep -E "^[0-9]+$" 1>/dev/null 2>&1; then
141 if [[ -n "${1}" ]] && { [[ "${1}" = "true" ]] ||[[ "${1}" = "false" ]]; }; then
150 local _command="${1}"
152 if which "${_command}" >/dev/null 2>&1; then
153 $(which "${_command}") "${@}"
155 msg_error "${_command} was not found"
162 wrapper crudini "${@}"
170 # 指定されたコマンドが現在のモードで実行可能かどうかを判定する
172 if ! printf "%s\n" "${@}" | grep -xE "${DISPLAY_MANAGER}" >/dev/null 2>&1; then
173 msg_error "This command (${COMMAND}) is not available in the current mode (${DISPLAY_MANAGER})."
178 # 現在のモードのメインバイナリが存在しているかどうか確認する
180 if [[ -z "${MAIN_BINARY["${DISPLAY_MANAGER}"]+SET}" ]]; then
181 msg_warn "The main binary for the selected mode is not set."
182 elif [[ ! -f "${MAIN_BINARY["${DISPLAY_MANAGER}"]}" ]]; then
183 msg_error "The target for the selected mode is not installed."
191 # 参考: https://wiki.archlinux.jp/index.php/%E3%82%AB%E3%83%BC%E3%82%BD%E3%83%AB%E3%83%86%E3%83%BC%E3%83%9E
192 # 参考: https://wiki.archlinux.jp/index.php/GDM
193 #echo "Searching cursor themes..." 1>&2
194 local _dir _cursor_theme_dir_list _find_cursor_dir_list=("/usr/share/icons" "${HOME}/.local/share/icons" "${HOME}/.icons")
195 for _dir in "${_find_cursor_dir_list[@]}"; do
196 if [[ -d "${_dir}" ]]; then
197 while read -r line; do
198 _cursor_theme_dir_list+=("${line}")
199 done < <(find "${_dir}" -type d -name "cursors" -print0 | xargs -0 -i dirname {} | sort)
202 unset _dir _find_cursor_dir_list
204 local _cursor_theme _cursor_theme_name _name
205 for _cursor_theme in "${_cursor_theme_dir_list[@]}"; do
206 _name="$(grep -E "^Name=" "${_cursor_theme}/cursor.theme" 2> /dev/null | sed "s|^Name=||g")"
207 if [[ -z "${_name}" ]]; then
208 _name="$(basename "${_cursor_theme}")"
210 _cursor_theme_name+=("${_name}")
212 printf "%s\n" "${_cursor_theme_name[@]}"
217 echo "Loading GTK themes..." >&2
218 local _dir _find_theme_dir_list=("/usr/share/themes" "${HOME}/.local/share/themes" "${HOME}/.themes")
219 for _dir in "${_find_theme_dir_list[@]}"; do
220 if [[ -d "${_dir}" ]]; then
221 while read -r line; do
222 _gtk_theme_dir_list+=("${line}")
223 done < <(find "${_dir}" -type d -name "gtk-*" -print0 | xargs -0 -i dirname {} | tr " " "\n" | sort | uniq)
228 for _dir in "${_gtk_theme_dir_list[@]}"; do
229 _theme_name="$(crudini --get "${_dir}/index.theme" 'Desktop Entry' "Name" 2> /dev/null ;:)"
230 if [[ -z "${_theme_name}" ]]; then
233 _gtk_theme_name_list+=("${_theme_name}")
237 printf "%s\n" "${_gtk_theme_name_list[@]}" | sort | uniq
241 echo "Loading icons..." >&2
242 local _dir _find_theme_dir_list=("/usr/share/icons" "${HOME}/.local/share/icons" "${HOME}/.icons")
243 for _dir in "${_find_theme_dir_list[@]}"; do
244 if [[ -d "${_dir}" ]]; then
245 while read -r line; do
246 _icon_theme_dir_list+=("${line}")
247 done < <(find "${_dir}" -type f -name "index.theme" -print0 | xargs -0 -i dirname {} | tr " " "\n" | sort | uniq)
252 for _dir in "${_icon_theme_dir_list[@]}"; do
253 _theme_name="$(crudini --get "${_dir}/index.theme" 'Icon Theme' "Name" 2> /dev/null ;:)"
254 if [[ -z "${_theme_name}" ]]; then
257 _gtk_theme_name_list+=("${_theme_name}")
261 printf "%s\n" "${_gtk_theme_name_list[@]}" | sort | uniq
265 find "/usr/share/xsessions" -type f -print0 -name "*.desktop" | xargs -0 -I{} bash -c 'basename {} | sed "s|.desktop||g"'
268 get_wayland_session(){
269 find "/usr/share/wayland-sessions" -type f -print0 -name "*.desktop" | xargs -0 -I{} bash -c 'basename {} | sed "s|.desktop||g"'
273 # Returns only the selected result to standard output
274 # ask_question -d <デフォルト値> -p <質問文> <選択肢1> <選択肢2> ...
276 local arg OPTARG OPTIND
277 local _default="" _choice_list _count _choice _question
278 while getopts "d:p:" arg; do
280 d) _default="${OPTARG}" ;;
281 p) _question="${OPTARG}" ;;
285 shift $((OPTIND - 1))
286 _choice_list=("${@}")
287 _digit="$(expr length "${#}")"
290 if (( ${#_choice_list[@]} < 0 )); then
291 msg_error "An exception error has occurred."
295 # 選択肢が1つしか無いならばそのまま値を返す
296 if (( ${#_choice_list[@]} <= 1 )); then
297 echo "${_choice_list[*]}"
301 if [[ -v _question ]] && [[ ! "${_question}" = "" ]]; then
302 echo -e "${_question}" >&2
305 for (( _count=1; _count<=${#_choice_list[@]}; _count++)); do
306 _choice="${_choice_list[$(( _count - 1 ))]}"
307 if [[ ! "${_default}" = "" ]] && [[ "${_choice}" = "${_default}" ]]; then
308 #echo " * ${_count}: ${_choice}" >&2
309 printf " * %${_digit}d: ${_choice}\n" "${_count}" >&2
311 #echo " ${_count}: ${_choice}" >&2
312 printf " %${_digit}d: ${_choice}\n" "${_count}" >&2
316 echo -n "(1 ~ ${#_choice_list[@]}) > " >&2
320 if check_int "${_input}"; then
322 if (( 1 <= _input)) && (( _input <= ${#_choice_list[@]} )); then
323 _choice="${_choice_list[$(( _input - 1 ))]}"
329 if printf "%s\n" "${_choice_list[@]}" | grep -x "${_input}" 1>/dev/null 2>&1; then
342 if (( $(get_xorg_session | wc -l) <= 1 )); then
343 _session="$(get_xorg_session)"
344 elif [[ "${NON_INTERACTIVE}" = true ]]; then
347 _session="$(grep -E '^Session=' "${HOME}/.dmrc" 2> /dev/null | cut -d '=' -f 2)"
348 if [[ -z "${autologin_session}" ]]; then
349 msg_error "Failed to set the session."
350 msg_error "Not specified and ~/.dmrc does not exist either."
354 while read -r line; do
355 _session_list+=("${line}")
356 done < <(get_xorg_session)
357 if ! session="$(ask_question -p "Select the desktop session to autologin" "${_session_list[@]}")"; then
358 msg_error "Please enter the correct session name."
361 if [[ -f "/usr/share/xsessions/${session}.desktop" ]]; then
362 _session="${session}"
364 msg_error "Please enter the correct session name."
373 local gtk_themes _theme
374 while read -r line; do gtk_themes+=("${line}"); done < <(get_gtk_theme)
377 if ! _theme="$(ask_question -p "Please select the theme to use" "${gtk_themes[@]}")"; then
378 msg_error "Please select the correct theme"
385 # check_session <session>
387 if [[ ! -f "/usr/share/xsessions/${1}.desktop" ]]; then
389 msg_error "This is a session (${1}) that does not exist."
395 # get_session <session name>
398 local session_exec="$(crudini --get "/usr/share/xsessions/${1}.desktop" "Desktop Entry" "Exec")"
399 if [[ ! -f "${session_exec}" ]]; then
400 session_exec="$(type -p "${session_exec}")"
402 echo -n "${session_exec}"
407 # add_user_to_group <user> <group>
409 if ! getent passwd "${1}" 1> /dev/null 2>&1; then
410 echo "${1} is a non-existent user."
414 if ! getent group "${2}" 1> /dev/null 2>&1; then
415 LANG=C groupadd -r "${2}"
417 LANG=C gpasswd -a "${1}" "${2}"
421 # get_filetype <file>
423 file -inb "${1}" | cut -d ";" -f 1
428 # check_filetype <ファイルタイプ> <ファイルパス>
430 local _type="${1}" _path="${2}"
432 # ファイルタイプに/が含まれているかどうか
433 if echo "${_type}" | grep -E "^.+/.+$" >/dev/null 2<&1; then
434 # 含まれていたらファイルタイプを完全一致で判定する\
435 if [[ "${_type}" = "$(get_filetype "${_path}")" ]]; then
439 # 含まれていなかったらファイルタイプをメインタイプのみで判定する
440 if [[ "${_type}" = "$(get_filetype "${_path}" | cut -d "/" -f 1 )" ]]; then
448 # systemdのunitが存在しているか確認
449 check_systemd_unit(){
450 if [[ ! -v 1 ]]; then
452 elif systemctl cat "${1}" 1> /dev/null 2>&1; then
459 command_general_dm(){
460 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
461 msg_error "Please specify display manager"
466 systemctl disable "${CURRENT_DM}.service"
468 # 指定されたディスプレイマネージャを有効化
469 if check_systemd_unit "${1}"; then
470 systemctl enable "${1}.service"
472 msg_error "Wrong display manager name"
476 # モードをコマンドとして扱い自身を再実行する
477 # command_mode <mode> <command> <args>
479 if [[ -z "${2+SET}" ]] || [[ "${2}" = "" ]]; then
480 msg_error "Please specify command"
484 local _mode="${1}" _command="${2}"
485 local _dmc_args="-e ${USE_EDITOR} -m ${_mode}"
489 local _command_args="${*}"
490 : "${_command_args-""}" # サブコマンドの引数が何も指定されなかった場合に空文字を代入
494 if [[ "${NON_INTERACTIVE}" = true ]]; then
495 _dmc_args+=" --non-interactive"
497 if [[ "${NOROOT}" = true ]]; then
498 _dmc_args+=" --noroot"
500 if [[ "${NO_CHECK_TARGET}" = true ]]; then
501 _dmc_args+=" --no-check-target"
503 if [[ "${WRITE_ALL_FILES}" = true ]]; then
504 _dmc_args+=" --write-all-files"
507 bash -c "${SCRIPT_PATH}/$(basename "${0}") ${_dmc_args} ${_command} ${_command_args}"
512 #== LightDM用の汎用関数 ==#
514 lightdm_get_source_file(){
516 local source_name="$(lightdm --show-config 2>&1 | grep -E "^[A-Z] ${key}=" | cut -d ' ' -f 1)"
517 local source_path="$(lightdm --show-config 2>&1 | grep -x -A "$(lightdm --show-config 2>&1 | wc -l)" "Sources:" | grep -xv "Sources" | grep -E "^${source_name} " | sed "s|^${source_name} ||g")"
518 if [[ -n "${source_path}" ]]; then
519 echo -n "${source_path}"
527 lightdm_set_config(){
528 local key="${1}" value="${2}" file=${3-${DISPLAY_MANAGER_CONFIG["lightdm"]}}
529 if [[ "${WRITE_ALL_FILES}" = true ]] && [[ -n "$(lightdm_get_source_file "${1}")" ]]; then
530 crudini --set "$(lightdm_get_source_file "${1}")" 'Seat:*' "${key}" "${value}"
532 crudini --set "${file}" 'Seat:*' "${key}" "${value}"
535 if [[ ! "$(lightdm_get_value "${key}")" = "${value}" ]]; then
536 msg_error "Failed to change the setting value. A value has already been set for $(lightdm_get_source_file "${1}")"
537 msg_error "lightdm-config does not manipulate other configuration files for safety. Comment out the settings in that file."
542 lightdm_remove_key(){
543 local key="${1}" _config
544 if grep -E "^ ?${key}.+" "${DISPLAY_MANAGER_CONFIG["lightdm"]}" 1>/dev/null 2>&1; then
545 sed -i -r "s|^ ?${key} ?=.+||g" "${DISPLAY_MANAGER_CONFIG["lightdm"]}"
546 sed -i '/^$/d' "${DISPLAY_MANAGER_CONFIG["lightdm"]}"
551 lightdm_init_configs(){
553 if [[ ! -f "${DISPLAY_MANAGER_CONFIG["lightdm"]}" ]]; then
554 mkdir -p "$(dirname "${DISPLAY_MANAGER_CONFIG["lightdm"]}")"
555 touch "${DISPLAY_MANAGER_CONFIG["lightdm"]}"
556 echo "[Seat:*]" > "${DISPLAY_MANAGER_CONFIG["lightdm"]}"
562 local _current_value="$(lightdm --show-config 2>&1 | grep -E "^[A-Z] ${1}=" | sed "s|^[A-Z] ||g" | cut -d "=" -f "2")"
563 if [[ "${_current_value}" ]]; then
564 echo -n "${_current_value}"
574 command_lightdm_greeter_change() {
576 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
577 msg_error "Please specify Greeter."
581 # 指定されたGreeterが正しいか確認
582 if ! printf "%s\n" "${LIGHTDM_GREETERS[@]}" | grep -x "${1}" > /dev/null 2>&2; then
583 msg_error "The greeter (${1}) doesn't exist."
586 lightdm_set_config "greeter-session" "${1}"
591 command_lightdm_greeter_create(){
592 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
593 msg_error "Please specify Greeter."
596 if [[ ! -f "${1}" ]]; then
597 msg_error "${1} does not exist."
600 if [[ ! -x "${1}" ]]; then
601 msg_error "hoge is not an executable file."
606 local filename="$(basename "${1}")"
608 if [[ -f "/usr/share/xgreeters/${filename}.desktop" ]]; then
609 msg_error "Greeter with the same name already exists."
612 cat > "/usr/share/xgreeters/${filename}.desktop" <<EOF
614 Name=LightDM custom Greeter ${filename}
615 Comment=LightDM Greeter
622 command_lightdm_greeter_list() {
623 echo "Available Lightdm greeter list:"
625 for _greeter in "${LIGHTDM_GREETERS[@]}"; do
626 if [[ "${_greeter}" = "${LIGHTDM_CURRENT_GREETER}" ]]; then
627 echo " * ${_greeter}"
635 run_greeter_wizard(){
637 if (( ${#LIGHTDM_GREETERS[@]} < 1 )); then
638 msg_error "LightDM Greeter was not found."
644 if ! _greeter="$(ask_question -p "Please select the greeter to use." -d "${LIGHTDM_CURRENT_GREETER}" "${LIGHTDM_GREETERS[@]}")"; then
650 if [[ -n "${_greeter}" ]]; then
651 command_lightdm_greeter_change "${_greeter}"
657 if [[ ! "${LIGHTDM_CURRENT_GREETER}" = "${_greeter}" ]]; then
658 echo "Changed greeter to ${_greeter}"
663 command_lightdm_remove(){
664 if [[ ! -f "${DISPLAY_MANAGER_CONFIG["lightdm"]}" ]]; then
668 echo -ne "Are you sure you want to delete all settings?\nThis change is irreversible.\n (y or n) > "
669 read -r -n 1 _yes_or_no
670 if [[ "${_yes_or_no}" = "y" ]]; then
671 mv "${DISPLAY_MANAGER_CONFIG["lightdm"]}" "${DISPLAY_MANAGER_CONFIG["lightdm"]}.disabled"
677 command_lightdm_greeter_edit(){
678 if [[ "${NON_INTERACTIVE}" = true ]]; then
679 msg_error "You cannot use this command in non-interactive mode."
682 local _greeter="${1:-${LIGHTDM_CURRENT_GREETER}}"
683 if [[ -z "${GREETER_CONFIG["${_greeter}"]+SET}" ]]; then
684 msg_error "This Greeter is not currently supported."
685 msg_error "Please report the problem here."
686 msg_error "https://github.com/FascodeNet/lightdm-config/issues"
689 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
690 msg_warn "Greeter was not specified. Open the currently configured Greeter configuration file."
691 echo -n "(Enter to continue) > "
695 bash -c "${USE_EDITOR} ${GREETER_CONFIG["${_greeter}"]}"
701 command_lightdm_edit(){
702 if [[ "${NON_INTERACTIVE}" = true ]]; then
703 msg_error "You cannot use this command in non-interactive mode."
706 for _config in "${LIGHTDM_LOADED_CONFIG[@]}"; do
707 echo -ne "Edit ${_config} ? (y or n)> "
708 read -r -n 1 _yes_or_no
710 if [[ "${_yes_or_no}" = "y" ]]; then
711 bash -c "${USE_EDITOR} ${_config}"
717 command_lightdm_auto_login(){
718 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
719 # 既に自動ログインが設定されているかを確認
720 local autologin_user="$(lightdm_get_value autologin-user)"
721 if [[ -n "${autologin_user}" ]]; then
723 for _autologin in "autologin-guest" "autologin-user" "autologin-user-timeout" "autologin-in-background" "autologin-session"; do
724 remove_key "${_autologin}"
726 echo "Canceled automatic login of ${autologin_user}"
729 local autologin_user="${1}" autologin_session
731 autologin_session="${2}"
734 # セッションを設定 (WayLandのセッションは現在サポートされていません)
735 if [[ -z "${autologin_session+SET}" ]]; then
736 autologin_session="$(ask_session)"
739 check_session "${autologin_session}"
743 add_user_to_group "${autologin_user}" "autologin"
746 lightdm_set_config "autologin-guest" "false"
747 lightdm_set_config "autologin-user" "${autologin_user}"
748 lightdm_set_config "autologin-user-timeout" "0"
749 lightdm_set_config "autologin-in-background" "false"
750 lightdm_set_config "autologin-session" "${autologin_session}"
752 echo "${autologin_user} will automatically log in with ${autologin_session}"
758 command_lightdm_show_config(){
759 lightdm --show-config 2>&1
765 if [[ ! -f "/etc/dconf/profile/gdm" ]]; then
766 mkdir -p "/etc/dconf/profile"
767 touch "/etc/dconf/profile/gdm"
768 echo -e "user-db:user\nsystem-db:gdm\nfile-db:/usr/share/gdm/greeter-dconf-defaults" > "/etc/dconf/profile/gdm"
772 for _file in "${DISPLAY_MANAGER_CONFIG["gdm-dconf"]}" "${DISPLAY_MANAGER_CONFIG["gdm-custom"]}"; do
773 if [[ ! -f "${_file}" ]]; then
774 mkdir -p "$(dirname "${_file}")"
780 # gdm_dconf_set_config <dconf path> <key> <value>
781 gdm_dconf_set_config(){
782 if check_int "${3}" || check_bool "${3}"; then
783 crudini --set "${DISPLAY_MANAGER_CONFIG["gdm-dconf"]}" "${1}" "${2}" "${3}"
785 crudini --set "${DISPLAY_MANAGER_CONFIG["gdm-dconf"]}" "${1}" "${2}" "\"${3}\""
790 # gdm_dconf_get_value <dconf path> <key>
791 gdm_dconf_get_value(){
792 find "/etc/dconf/db/gdm.d/" -type f -print0 | xargs -0i cat {} | crudini --get - "${1}" "${2}" | sed "s|^[\"\']||g" | sed "s|[\"\']$||g"
795 # gdm_custom_get_value <section> <key>
796 gdm_custom_get_value(){
797 crudini --get "${DISPLAY_MANAGER_CONFIG["gdm-custom"]}" "${1}" "${2}"
800 # gdm_custom_set_config <section> <key> <value>
801 gdm_custom_set_config(){
802 if check_int "${3}" || check_bool "${3}"; then
803 crudini --set "${DISPLAY_MANAGER_CONFIG["gdm-custom"]}" "${1}" "${2}" "${3}"
805 crudini --set "${DISPLAY_MANAGER_CONFIG["gdm-custom"]}" "${1}" "${2}" "\"${3}\""
817 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
818 msg_error "Please specify the image of background"
821 if [[ ! -f "${1}" ]]; then
822 msg_error "${1} was not found."
826 local _backgrounf_file="/usr/share/backgrounds/gdm/background"
827 mkdir -p "$(dirname "${_backgrounf_file}")"
828 cp "${1}" "${_backgrounf_file}"
829 chmod 644 "${_backgrounf_file}"
831 gdm_dconf_set_config "org/gnome/login-screen" "logo" "${_backgrounf_file}"
834 command_gdm_cursor_wizard(){
836 local cursor_themes _current_theme="$(gdm_dconf_get_value "org/gnome/desktop/interface" "cursor-theme")"
837 while read -r line; do cursor_themes+=("${line}"); done < <(get_cursor_theme)
840 if ! _cursor_theme="$(ask_question -d "${_current_theme}" -p "Please select the cursor theme to use." "${cursor_themes[@]}")"; then
845 if [[ -n "${_cursor_theme}" ]]; then
846 command_gdm_cursor_change "${_cursor_theme}"
848 command_gdm_cursor_wizard
852 if [[ ! "${_current_theme}" = "${_cursor_theme}" ]]; then
853 echo "Changed cursor to ${_cursor_theme}"
857 command_gdm_cursor_change(){
858 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
859 msg_error "Please specify the cursor theme"
863 while read -r line; do cursor_themes+=("${line}"); done < <(get_cursor_theme)
864 if ! printf "%s\n" "${cursor_themes[@]}" | grep -x "${1}" 1>/dev/null 2>&1; then
865 msg_error "The cursor theme (${1}) was not found"
868 gdm_dconf_set_config "org/gnome/desktop/interface" "cursor-theme" "${1}"
872 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
873 if ! check_bool "${_arg}"; then
874 msg_error "Please specify true or false"
877 gdm_dconf_set_config "org/gnome/desktop/sound" "event-sounds" "${_arg}"
881 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
882 if ! check_bool "${_arg}"; then
883 msg_error "Please specify true or false"
886 gdm_dconf_set_config "org/gnome/desktop/peripherals/touchpad" "tap-to-click" "${_arg}"
890 command_gdm_auto_login(){
891 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
892 # 既に自動ログインが設定されているかを確認
893 local autologin="$(gdm_custom_get_value daemon AutomaticLoginEnable)"
894 if [[ "${autologin}" = "True" ]]; then
895 gdm_custom_set_config "daemon" "AutomaticLoginEnable" "False"
896 echo "Canceled automatic login of $(gdm_custom_get_value "daemon" "AutomaticLogin")"
899 local autologin_user="${1}" autologin_session
901 autologin_session="${2}"
904 # セッションを設定 (WayLandのセッションは現在サポートされていません)
905 if [[ -z "${autologin_session+SET}" ]]; then
906 autologin_session="$(ask_session)"
909 check_session "${autologin_session}"
913 add_user_to_group "${autologin_user}" "autologin"
916 gdm_custom_set_config "daemon" "AutomaticLoginEnable" "True"
917 gdm_custom_set_config "daemon" "AutomaticLogin" "${autologin_user}"
920 crudini --set "/var/lib/AccountsService/users/${autologin_user}" "User" "Session" "${autologin_session}"
921 crudini --set "/var/lib/AccountsService/users/${autologin_user}" "User" "XSession" "${autologin_session}"
923 echo "${autologin_user} will automatically log in with ${autologin_session}"
929 command_gdm_accessibility(){
930 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
931 if ! check_bool "${_arg}"; then
932 msg_error "Please specify true or false"
935 gdm_dconf_set_config "org/gnome/desktop/interface" "toolkit-accessibility" "${_arg}"
939 command_gdm_root_login(){
940 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
941 if ! check_bool "${_arg}"; then
942 msg_error "Please specify true or false"
945 gdm_custom_set_config "daemon" "AllowRoot" "${_arg}"
948 #== Webkit2用の汎用関数 ==#
949 webkit2_init_configs(){
951 if [[ ! -f "${GREETER_CONFIG["lightdm-webkit2-greeter"]}" ]]; then
952 mkdir -p "$(dirname "${GREETER_CONFIG["lightdm-webkit2-greeter"]}")"
953 touch "${GREETER_CONFIG["lightdm-webkit2-greeter"]}"
957 # webkit2_get_value <section> <key>
959 crudini --get "${GREETER_CONFIG["lightdm-webkit2-greeter"]}" "${1}" "${2}"
962 # webkit2_set_config <section> <key> <value>
963 webkit2_set_config(){
964 crudini --set "${GREETER_CONFIG["lightdm-webkit2-greeter"]}" "${1}" "${2}" "${3}"
968 command_webkit2_theme_wizard(){
970 while read -r line; do
971 _theme_list+=("${line}")
972 done < <(ls /usr/share/lightdm-webkit/themes)
974 local _current_theme=$(webkit2_get_value greeter webkit_theme | sed "s|\"||g")
976 if ! _theme="$(ask_question -d "${_current_theme}" -p "Please select the theme to use." "${_theme_list[@]}")"; then
980 if [[ -n "${_theme}" ]]; then
981 command_webkit2_theme_change "${_theme}"
982 echo "Changed the theme to ${_theme}"
984 command_webkit2_theme_wizard
990 command_webkit2_theme_change(){
991 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
992 msg_error "Please specify the theme name"
995 if [[ ! -d "/usr/share/lightdm-webkit/themes/${1}" ]]; then
996 msg_error "The specified theme (${1}) does not exist"
1000 webkit2_set_config "greeter" "webkit_theme" "${1}"
1003 #== Qtquick用の汎用関数 ==#
1004 qtquick_init_configs(){
1006 if [[ ! -f "${GREETER_CONFIG["lightdm-qtquick-greeter"]}" ]] || [[ -z "$(cat "${GREETER_CONFIG["lightdm-qtquick-greeter"]}")" ]]; then
1007 mkdir -p "$(dirname "${GREETER_CONFIG["lightdm-qtquick-greeter"]}")"
1008 touch "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1009 #echo -e "{\n\n}\n" > "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1010 qtquick_set_config background_path "file:///hoge/fuga.png"
1011 qtquick_set_config theme "qrc:/Login.qml"
1015 #qtquick_get_value <key>
1016 qtquick_get_value(){
1017 jq ".${1}" < "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1020 # command_qtquick_back <key> <value>
1021 qtquick_set_config(){
1022 local _tempfile="/tmp/$(basename "${GREETER_CONFIG["lightdm-qtquick-greeter"]}")-$(base64 < "/dev/urandom" | fold -w 10 | head -n 1)"
1023 cp "${GREETER_CONFIG["lightdm-qtquick-greeter"]}" "${_tempfile}"
1024 #cat "${_tempfile}" | jq -r ".${1}|=\"${2}\"" > "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1025 jq -r ".${1}|=\"${2}\"" < "${_tempfile}" > "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1026 chmod 644 "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1029 #== Qtquick用コマンド ==#
1030 command_qtquick_back(){
1031 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1032 msg_error "Please specify the image of background"
1035 if [[ ! -f "${1}" ]]; then
1036 msg_error "${1} was not found."
1040 local _backgrounf_file="/usr/share/backgrounds/lightdm/qtquick-greeter"
1041 mkdir -p "$(dirname "${_backgrounf_file}")"
1042 cp "${1}" "${_backgrounf_file}"
1043 chmod 644 "${_backgrounf_file}"
1045 qtquick_set_config "background_path" "file://${_backgrounf_file}"
1050 crudini --get "${GREETER_CONFIG["lightdm-slick-greeter"]}" "Greeter" "${1}"
1054 crudini --set "${GREETER_CONFIG["lightdm-slick-greeter"]}" "Greeter" "${1}" "${2}"
1057 slick_init_configs(){
1059 if [[ ! -f "${GREETER_CONFIG["lightdm-slick-greeter"]}" ]]; then
1060 mkdir -p "$(dirname "${GREETER_CONFIG["lightdm-slick-greeter"]}")"
1061 touch "${GREETER_CONFIG["lightdm-slick-greeter"]}"
1062 echo "[Greeter]" > "${GREETER_CONFIG["lightdm-slick-greeter"]}"
1067 command_slick_grid(){
1068 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
1069 if ! check_bool "${_arg}"; then
1070 msg_error "Please specify true or false"
1073 slick_set_config "draw-grid" "${_arg}"
1076 command_slick_back(){
1077 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1078 msg_error "Please specify the image of background"
1081 if [[ ! -f "${1}" ]]; then
1082 msg_error "${1} was not found."
1086 local _backgrounf_file="/usr/share/backgrounds/lightdm/slick-greeter"
1087 mkdir -p "$(dirname "${_backgrounf_file}")"
1088 cp "${1}" "${_backgrounf_file}"
1089 chmod 644 "${_backgrounf_file}"
1091 slick_set_config "background" "${_backgrounf_file}"
1095 command_slick_gtk_wizard(){
1096 local _theme="$(ask_gtk_theme)"
1099 if [[ -n "${_theme}" ]]; then
1100 command_slick_gtk_change "${_theme}"
1104 echo "Changed theme to ${_theme}"
1107 command_slick_gtk_change(){
1108 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1109 msg_error "Please specify the theme"
1112 if [[ ! -d "/usr/share/themes/${1}" ]]; then
1113 msg_error "${1} was not found."
1116 slick_set_config "theme-name" "${1}"
1119 command_slick_icon_wizard(){
1121 while read -r line; do icons+=("${line}"); done < <(get_icon_theme)
1124 echo "Please select the icon theme to use."
1125 if ! _icon="$(ask_question "${icons[@]}")"; then
1126 command_slick_icon_wizard
1130 if [[ -n "${_icon}" ]]; then
1131 slick_set_config "icon-theme-name" "${_icon}"
1133 command_slick_icon_wizard
1136 echo "Changed icon theme to ${_icon}"
1139 command_slick_icon_chenge(){
1140 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1141 msg_error "Please specify the icon theme to use."
1144 if ! printf "%s\n" $(get_icon_theme) | grep -x "${1}" 1> /dev/null 2>&1; then
1145 msg_error "${1} was not found."
1148 slick_set_config "icon-theme-name" "${_icon}"
1153 # sddm_get_value <section> <key> <valye>
1155 crudini --set "${DISPLAY_MANAGER_CONFIG["sddm"]}" "${1}" "${2}"
1158 # sddm_set_config <section> <key> <value>
1160 crudini --set "${DISPLAY_MANAGER_CONFIG["sddm"]}" "${1}" "${2}" "${3}"
1163 # sddm_remove_key <section> <key>
1165 crudini --del "${DISPLAY_MANAGER_CONFIG["sddm"]}" "${1}" "${2}"
1169 sddm_init_configs(){
1171 if [[ ! -f "${DISPLAY_MANAGER_CONFIG["sddm"]}" ]]; then
1172 mkdir -p "$(dirname "${DISPLAY_MANAGER_CONFIG["sddm"]}")"
1173 sddm --example-config > "${DISPLAY_MANAGER_CONFIG["sddm"]}"
1178 command_sddm_auto_login(){
1179 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1180 # 既に自動ログインが設定されているかを確認
1181 local autologin_user="$(sddm_get_value Autologin User)"
1182 if [[ -n "${autologin_user}" ]]; then
1183 sddm_remove_key "Autologin" "User"
1184 echo "Canceled automatic login of ${autologin_user}"
1187 local autologin_user="${1}" autologin_session
1189 autologin_session="${2}"
1192 # セッションを設定 (WayLandのセッションは現在サポートされていません)
1193 if [[ -z "${autologin_session+SET}" ]]; then
1194 autologin_session="$(ask_session)"
1197 check_session "${autologin_session}"
1201 add_user_to_group "${autologin_user}" "autologin"
1204 sddm_set_config "Autologin" "User" "${autologin_user}"
1205 sddm_set_config "Autologin" "Session" "${autologin_session}"
1207 echo "${autologin_user} will automatically log in with ${autologin_session}"
1211 command_sddm_cursor_wizard(){
1213 local cursor_themes _current_theme="$(sddm_get_value "Theme" "CursorTheme")"
1214 while read -r line; do cursor_themes+=("${line}"); done < <(get_cursor_theme)
1217 if ! _cursor_theme="$(ask_question -d "${_current_theme}" -p "Please select the cursor theme to use." "${cursor_themes[@]}")"; then
1218 command_sddm_cursor_wizard
1222 if [[ -n "${_cursor_theme}" ]]; then
1223 command_sddm_cursor_change "${_cursor_theme}"
1225 command_sddm_cursor_change
1229 if [[ ! "${_current_theme}" = "${_cursor_theme}" ]]; then
1230 echo "Changed cursor to ${_cursor_theme}"
1234 command_sddm_cursor_change(){
1235 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1236 msg_error "Please specify the cursor theme"
1240 while read -r line; do cursor_themes+=("${line}"); done < <(get_cursor_theme)
1241 if ! printf "%s\n" "${cursor_themes[@]}" | grep -x "${1}" 1>/dev/null 2>&1; then
1242 msg_error "The cursor theme (${1}) was not found"
1245 sddm_set_config "Theme" "CursorTheme" "${1}"
1248 command_sddm_numlock(){
1249 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
1250 if ! check_bool "${_arg}"; then
1251 msg_error "Please specify true or false"
1255 if [[ "${_arg}" = true ]]; then
1260 sddm_set_config "General" "Numlock" "${_value}"
1264 if ! check_int "${1}" || (( "${1}" < 1 )); then
1265 msg_error "Please enter an integer greater than 1"
1268 sddm_set_config "X11" "MinimumVT" "${1}"
1271 command_sddm_theme_wizard(){
1273 while read -r line; do
1274 _theme_list+=("${line}")
1275 done < <(find "/usr/share/sddm/themes/" -maxdepth 1 -mindepth 1 -type d -print0 | xargs -0 -I{} basename {})
1277 local _theme _current_theme=$(sddm_get_value "Theme" "Current")
1278 if ! _theme="$(ask_question -d "${_current_theme}" -p "Please select the theme to use." "${_theme_list[@]}")"; then
1279 command_sddm_theme_wizard
1282 if [[ -n "${_theme}" ]]; then
1283 command_sddm_theme_change "${_theme}"
1284 echo "Changed the theme to ${_theme}"
1286 command_sddm_theme_wizard
1292 command_sddm_theme_change(){
1293 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1294 msg_error "Please specify the theme name"
1297 if [[ ! -d "/usr/share/sddm/themes/${1}" ]]; then
1298 msg_error "The specified theme (${1}) does not exist"
1302 sddm_set_config "Theme" "Current" "${1}"
1306 # sddm_get_value <section> <key> <valye>
1308 crudini --set "${DISPLAY_MANAGER_CONFIG["lxdm"]}" "${1}" "${2}"
1311 # sddm_set_config <section> <key> <value>
1313 crudini --set "${DISPLAY_MANAGER_CONFIG["lxdm"]}" "${1}" "${2}" "${3}"
1316 # sddm_remove_key <section> <key>
1318 crudini --del "${DISPLAY_MANAGER_CONFIG["lxdm"]}" "${1}" "${2}"
1322 lxdm_init_configs(){
1324 if [[ ! -f "${DISPLAY_MANAGER_CONFIG["lxdm"]}" ]]; then
1325 mkdir -p "$(dirname "${DISPLAY_MANAGER_CONFIG["lxdm"]}")"
1326 touch "${DISPLAY_MANAGER_CONFIG["lxdm"]}"
1331 command_lxdm_auto_login(){
1332 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1333 # 既に自動ログインが設定されているかを確認
1334 local autologin_user="$(lxdm_get_value "base" "autologin")"
1335 if [[ -n "${autologin_user}" ]]; then
1336 sddm_remove_key "base" "autologin"
1337 echo "Canceled automatic login of ${autologin_user}"
1340 local autologin_user="${1}" autologin_session
1342 autologin_session="${2}"
1345 # セッションを設定 (WayLandのセッションは現在サポートされていません)
1346 if [[ -z "${autologin_session+SET}" ]]; then
1347 autologin_session="$(ask_session)"
1350 check_session "${autologin_session}"
1354 add_user_to_group "${autologin_user}" "autologin"
1357 sddm_set_config "base" "autologin" "${autologin_user}"
1360 command_lxdm_session_change "${autologin_session}"
1362 echo "${autologin_user} will automatically log in with ${autologin_session}"
1366 command_lxdm_session_wizard(){
1367 command_lxdm_session_change "$(ask_session)"
1370 command_lxdm_session_change(){
1371 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1372 msg_error "Please specify the session name"
1375 local session="${1}"
1376 check_session "${session}"
1377 local session_exec="$(get_session "${session}")"
1378 lxdm_set_config "base" "session" "${session_exec}"
1381 command_lxdm_remove_last(){
1382 rm -rf "/var/lib/lxdm/lxdm.conf"
1383 echo "Removed last configs"
1386 comamnd_lxdm_edit_script(){
1388 "LoginReady : executed with root privileges when LXDM is ready to show the login window"
1389 "PreLogin : run as root before logging a user in"
1390 "PostLogin : run as the logged-in user right after they have logged in"
1391 "PostLogout : run as the logged-in user right after they have logged out"
1392 "PreReboot : run as root before rebooting with LXDM"
1393 "PreShutdown: run as root before poweroff with LXDM"
1395 if ! file=$(ask_question -p "Select the script you want to edit" "${_filelist[@]}" | cut -d ":" -f 1 | tr -d " "); then
1396 comamnd_lxdm_edit_script
1399 bash -c "${USE_EDITOR} ${file}"
1402 command_lxdm_back(){
1403 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1404 msg_error "Please specify the image of background"
1407 if [[ ! -f "${1}" ]]; then
1408 msg_error "${1} was not found."
1412 local _backgrounf_file="/usr/share/backgrounds/lxdm/background"
1413 mkdir -p "$(dirname "${_backgrounf_file}")"
1414 cp "${1}" "${_backgrounf_file}"
1415 chmod 644 "${_backgrounf_file}"
1417 lxdm_set_config "display" "bg" "file://${_backgrounf_file}"
1420 command_lxdm_gtk_wizard(){
1421 local _theme="$(ask_gtk_theme)"
1424 if [[ -n "${_theme}" ]]; then
1425 command_lxdm_gtk_change "${_theme}"
1429 echo "Changed theme to ${_theme}"
1432 command_lxdm_gtk_change(){
1433 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1434 msg_error "Please specify the theme"
1437 if [[ ! -d "/usr/share/themes/${1}" ]]; then
1438 msg_error "${1} was not found."
1441 lxdm_set_config "display" "gtk_theme" "${1}"
1444 #== GTk Greeter用の汎用関数 ==#
1445 # gtk_greeter_get_value <section> <key>
1446 gtk_greeter_get_value(){
1447 crudini --set "${GREETER_CONFIG["lightdm-gtk-greeter"]}" "${1}" "${2}"
1450 # gtk_greeter_set_config <section> <key> <value>
1451 gtk_greeter_set_config(){
1452 crudini --set "${GREETER_CONFIG["lightdm-gtk-greeter"]}" "${1}" "${2}" "${3}"
1455 # gtk_greeter_remove_key <section> <key>
1456 gtk_greeter_remove_key(){
1457 crudini --del "${GREETER_CONFIG["lightdm-gtk-greeter"]}" "${1}" "${2}"
1460 gtk_greeter_init_configs(){
1462 if [[ ! -f "${GREETER_CONFIG["lightdm-gtk-greeter"]}" ]]; then
1463 mkdir -p "$(dirname "${GREETER_CONFIG["lightdm-gtk-greeter"]}")"
1464 touch "${GREETER_CONFIG["lightdm-gtk-greeter"]}"
1468 #== GTk Greeter用のコマンド==#
1469 command_gtk_greeter_gtk_wizard(){
1470 local _theme="$(ask_gtk_theme)"
1473 if [[ -n "${_theme}" ]]; then
1474 gtk_greeter_set_config "greeter" "theme-name" "${_theme}"
1478 echo "Changed theme to ${_theme}"
1481 command_gtk_greeter_gtk_change(){
1482 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1483 msg_error "Please specify the theme"
1486 if ! printf "%s\n" $(get_gtk_theme) | grep -x "${1}" 1> /dev/null 2>&1; then
1487 msg_error "${1} was not found."
1490 gtk_greeter_set_config "greeter" "theme-name" "${1}"
1493 command_gtk_greeter_icon_wizard(){
1495 while read -r line; do icons+=("${line}"); done < <(get_icon_theme)
1498 echo "Please select the icon theme to use."
1499 if ! _icon="$(ask_question "${icons[@]}")"; then
1500 command_gtk_greeter_icon_wizard
1504 if [[ -n "${_icon}" ]]; then
1505 gtk_greeter_set_config "greeter" "icon-theme-name" "${_icon}"
1507 command_gtk_greeter_icon_wizard
1510 echo "Changed icon theme to ${_icon}"
1513 command_gtk_greeter_icon_chenge(){
1514 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1515 msg_error "Please specify the icon theme to use."
1518 if ! printf "%s\n" $(get_icon_theme) | grep -x "${1}" 1> /dev/null 2>&1; then
1519 msg_error "${1} was not found."
1522 gtk_greeter_set_config "greeter" "icon-theme-name" "${_icon}"
1527 declare -A GREETER_CONFIG=(
1528 ["lightdm-webkit2-greeter"]="/etc/lightdm/lightdm-webkit2-greeter.conf"
1529 ["lightdm-slick-greeter"]="/etc/lightdm/slick-greeter.conf"
1530 ["lightdm-gtk-greeter"]="/etc/lightdm/lightdm-gtk-greeter.conf"
1531 ["io.elementary.greeter"]="/etc/lightdm/io.elementary.greeter.conf"
1532 ["lightdm-mini-greeter"]="/etc/lightdm/lightdm-mini-greeter.conf"
1533 ["lightdm-qtquick-greeter"]="/etc/lightdm/lightdm-qtquick-greeter.json"
1536 declare -A DISPLAY_MANAGER_CONFIG=(
1537 ["lightdm"]="/etc/lightdm/lightdm.conf.d/00-dmc-lightdm.conf"
1538 ["gdm-dconf"]="/etc/dconf/db/gdm.d/00-dmc-gdm"
1539 ["gdm-custom"]="/etc/gdm/custom.conf"
1540 ["sddm"]="/etc/sddm.conf.d/sddm.conf"
1541 ["lxdm"]="/etc/lxdm/lxdm.conf"
1544 declare -A MAIN_BINARY=(
1545 ["lightdm"]="/usr/bin/lightdm"
1546 ["gdm"]="/usr/bin/gdm"
1547 ["sddm"]="/usr/bin/sddm"
1548 ["webkit2"]="/usr/bin/lightdm-webkit2-greeter"
1549 ["slick"]="/usr/bin/slick-greeter"
1550 ["gtkg"]="/usr/bin/lightdm-gtk-greeter"
1551 ["elementary"]="/usr/bin/io.elementary.greeter"
1552 ["mini"]="/usr/bin/lightdm-mini-greeter"
1553 ["qtquick"]="/usr/bin/lightdm-qtquick-greeter"
1554 ["lxdm"]="/usr/bin/lxdm"
1557 declare -A GREETER_MODE=(
1558 ["lightdm-webkit2-greeter"]="webkit2"
1559 ["lightdm-slick-greeter"]="slick"
1560 ["io.elementary.greeter"]="elementary"
1561 ["lightdm-mini-greeter"]="mini"
1562 ["lightdm-qtquick-greeter"]="qtquick"
1563 ["lightdm-gtk-greeter"]="gtkg"
1569 # LightDM - Greeterのディレクトリ
1570 LIGHTDM_GREETERS_DIR="$(lightdm_get_value "greeters-directory")"
1571 : "${LIGHTDM_GREETERS_DIR:="/usr/share/xgreeters"}"
1573 # LightDM - Greeter一覧
1574 #LIGHTDM_GREETERS=( $( )
1575 while read -r line; do
1576 LIGHTDM_GREETERS+=("${line}")
1577 done < <( (find "${LIGHTDM_GREETERS_DIR}" -print0 -type f | xargs -0 -i basename {} | grep -E ".desktop$" | sed "s|.desktop$||g" | grep -xv "xgreeters") 2> /dev/null )
1579 # LightDM - 現在設定されているGreeter
1580 LIGHTDM_CURRENT_GREETER="$(lightdm --show-config 2>&1 | grep "greeter-session" | cut -d "=" -f 2)"
1581 : "${LIGHTDM_CURRENT_GREETER:="lightdm-gtk-greeter"}"
1583 # LightDM - 読み込まれた設定ファイルの一覧
1584 while read -r line; do
1585 LIGHTDM_LOADED_CONFIG+=("${line}")
1586 done < <(printf "%s\n" "$(lightdm --show-config 2>&1 | grep -x -A "$(lightdm --show-config 2>&1 | wc -l)" "Sources:" | grep -v "Sources" | sed 's|^[A-Z] ||g')" | tr -d " ")
1589 USE_EDITOR="${EDITOR:-vi}"
1591 # Global - 現在のディスプレイマネージャ名
1592 CURRENT_DM="$(basename "$(readlink "/etc/systemd/system/display-manager.service")" | sed "s|.service$||g")"
1595 DISPLAY_MANAGER="${CURRENT_DM}"
1596 : "${DISPLAY_MANAGER:="lightdm"}"
1599 NON_INTERACTIVE=false
1600 WRITE_ALL_FILES=false
1602 NO_CHECK_TARGET=false
1607 OPTL="mode:,editor:,help,non-interactive,noroot,write-all-files,no-check-target,lightdm-greeter"
1608 # shellcheck disable=SC2086
1609 if ! OPT="$(getopt -o ${OPTS} -l ${OPTL} -- ${ARGUMENT})"; then
1613 eval set -- "${OPT}"
1619 DISPLAY_MANAGER="${2}"
1630 -G | --lightdm-greeter)
1631 if [[ ! -z "${LIGHTDM_CURRENT_GREETER+SET}" ]]; then
1632 DISPLAY_MANAGER="${GREETER_MODE["${LIGHTDM_CURRENT_GREETER}"]}"
1634 msg_error "Failed to get the currently running Greeter."
1640 NON_INTERACTIVE=true
1648 NO_CHECK_TARGET=true
1652 WRITE_ALL_FILES=true
1663 COMMAND="${1:-null}"
1664 if (( "${#}" >= 1 )); then
1668 : "${COMMAND_ARGS-""}" # サブコマンドの引数が何も指定されなかった場合に空文字を代入
1670 if [[ "${COMMAND}" = "null" ]]; then
1676 if [[ "${NO_CHECK_TARGET}" = false ]]; then
1680 # コマンドとモードに応じて関数を実行する
1681 case "${COMMAND}" in
1683 check_command_dm "lightdm" "gdm" "sddm" "lxdm"
1684 case "${DISPLAY_MANAGER}" in
1686 lightdm_init_configs
1687 command_lightdm_auto_login "${COMMAND_ARGS}"
1691 command_gdm_auto_login "${COMMAND_ARGS}"
1695 command_sddm_auto_login "${COMMAND_ARGS}"
1699 command_lxdm_auto_login "${COMMAND_ARGS}"
1704 check_command_dm "lightdm"
1705 lightdm_init_configs
1709 check_command_dm "lightdm"
1710 lightdm_init_configs
1711 command_lightdm_greeter_change "${COMMAND_ARGS}"
1714 check_command_dm "lightdm"
1715 lightdm_init_configs
1716 command_lightdm_greeter_create "${COMMAND_ARGS}"
1719 check_command_dm "lightdm"
1720 command_lightdm_greeter_list
1723 check_command_dm "lightdm"
1725 command_lightdm_greeter_edit "${COMMAND_ARGS}"
1728 check_command_dm "lightdm"
1730 command_lightdm_remove
1733 check_command_dm "lightdm"
1735 command_lightdm_edit
1738 check_command_dm "lightdm"
1739 command_lightdm_show_config
1742 check_command_dm "gdm" "sddm"
1743 case "${DISPLAY_MANAGER}" in
1746 command_gdm_cursor_wizard
1750 command_sddm_cursor_wizard
1755 check_command_dm "gdm" "sddm"
1756 case "${DISPLAY_MANAGER}" in
1759 command_gdm_cursor_change "${COMMAND_ARGS}"
1763 command_sddm_cursor_change "${COMMAND_ARGS}"
1768 check_command_dm "gdm"
1770 command_gdm_sound "${COMMAND_ARGS}"
1773 check_command_dm "gdm" "slick"
1774 case "${DISPLAY_MANAGER}" in
1777 command_gdm_logo "${COMMAND_ARGS}"
1781 command_slick_logo "${COMMAND_ARGS}"
1786 check_command_dm "gdm"
1788 command_gdm_tap "${COMMAND_ARGS}"
1791 check_command_dm "gdm"
1793 command_gdm_accessibility "${COMMAND_ARGS}"
1796 check_command_dm "gdm"
1798 command_gdm_root_login "${COMMAND_ARGS}"
1801 check_command_dm "webkit2" "sddm"
1802 case "${DISPLAY_MANAGER}" in
1804 webkit2_init_configs
1805 command_webkit2_theme_wizard
1809 command_sddm_theme_wizard
1814 check_command_dm "webkit2" "sddm"
1815 case "${DISPLAY_MANAGER}" in
1817 webkit2_init_configs
1818 command_webkit2_theme_change "${COMMAND_ARGS}"
1822 command_sddm_theme_change
1827 check_command_dm "slick" "lxdm" "gtkg"
1828 case "${DISPLAY_MANAGER}" in
1831 command_slick_gtk_wizard
1835 command_lxdm_gtk_wizard
1838 gtk_greeter_init_configs
1839 command_gtk_greeter_gtk_wizard
1844 check_command_dm "slick" "lxdm" "gtkg"
1845 case "${DISPLAY_MANAGER}" in
1848 command_slick_gtk_change "${COMMAND_ARGS}"
1851 command_lxdm_gtk_change "${COMMAND_ARGS}"
1854 command_gtk_greeter_gtk_change "${COMMAND_ARGS}"
1859 check_command_dm "qtquick" "slick" "lxdm"
1860 case "${DISPLAY_MANAGER}" in
1862 qtquick_init_configs
1863 command_qtquick_back "${COMMAND_ARGS}"
1867 command_slick_back "${COMMAND_ARGS}"
1871 command_lxdm_back "${COMMAND_ARGS}"
1876 check_command_dm "slick"
1878 command_slick_grid "${COMMAND_ARGS}"
1881 check_command_dm "slick" "gtkg"
1882 case "${DISPLAY_MANAGER}" in
1885 command_slick_icon_wizard
1888 gtk_greeter_init_configs
1889 command_gtk_greeter_icon_wizard
1894 check_command_dm "slick" "gtkg"
1895 case "${DISPLAY_MANAGER}"; in
1898 command_slick_icon_chenge "${COMMAND_ARGS}"
1901 gtk_greeter_init_configs
1902 command_gtk_greeter_icon_chenge "${COMMAND_ARGS}"
1907 check_command_dm "slick"
1909 command_slick_other_monitor "${COMMAND_ARGS}"
1912 check_command_dm "sddm"
1914 command_sddm_numlock "${COMMAND_ARGS}"
1917 check_command_dm "sddm"
1919 command_sddm_tty "${COMMAND_ARGS}"
1922 check_command_dm "lxdm"
1924 command_lxdm_session_wizard
1927 check_command_dm "lxdm"
1929 command_lxdm_session_change "${COMMAND_ARGS}"
1932 check_command_dm "lxdm"
1934 command_lxdm_remove_last
1937 check_command_dm "lxdm"
1939 comamnd_lxdm_edit_script
1942 command_general_dm "${COMMAND_ARGS}"
1944 "lightdm" | "gdm" | "sddm" | "lxdm" | "webkit2" | "qtquick" | "slick" | "gtkg")
1945 command_mode "${COMMAND}" "${COMMAND_ARGS}"
1948 msg_error "This command cannot be used in any mode"