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 " GTKG command: (lightdm-gtk-greeter)"
53 echo " gtk Run gtk theme selection wizard"
54 echo " gtk-change [theme] Specify gtk theme"
55 echo " icon Run icon theme selection wizard"
56 echo " icon-change [icon] Specify the icon theme"
58 echo " Webkit2 command: (lightdm-webkit2-greeter)"
59 echo " theme Run theme selection wizard"
60 echo " theme-change [theme] Specify the theme"
62 echo " Qtquick command: (lightdm-qtquick-greeter)"
63 echo " back Specify the background image"
65 echo " Slick command: (lightdm-slick-greeter)"
66 echo " back [image] Specify the background image"
67 echo " grid [true or false] Toggle whether to show grid"
68 echo " icon Run icon theme selection wizard"
69 echo " icon-change [icon] Specify the icon theme"
70 echo " gtk Run gtk theme selection wizard"
71 echo " gtk-change [theme] Specify gtk theme"
74 echo " autologin [username] [session] Set up automatic login (with blank username to disable)"
75 echo " cursor Run cursor selection wizard"
76 echo " cursor-change [cursor] Specify the cursor theme"
77 echo " numlock [true or false] Toggle whether to enable Numlock force"
78 echo " tty [int number] The lowest virtual terminal number that will be used"
79 echo " theme Run theme selection wizard"
80 echo " theme-change [theme] Specify the theme"
83 echo " autologin [username] [session] Set up automatic login (with blank username to disable)"
84 echo " back [image] Specify the background image"
85 echo " session Run default session selection wizard"
86 echo " session-change [session] Specify the default session"
87 echo " remove-last Remove last selected setting"
88 echo " edit-script Edit the script"
89 echo " gtk Run gtk theme selection wizard"
90 echo " gtk-change [theme] Specify gtk theme"
92 echo " General option:"
93 echo " -G | --lightdm-greeter Automatically get the current greeter and set as mode (Only LightDM)"
94 echo " -m | --mode [mode name] Specifiy the target you want to set"
95 echo " -e | --editer [editor path] Specifiy the editor to use for editing"
96 echo " -h | --help This help message and exit"
97 echo " --non-interactive Run in non-interactive mode"
98 echo " --no-check-target No check the target for the selected mode"
99 echo " --noroot No check root permission"
100 echo " --write-all-files Allows rewriting of all configuration files"
102 echo " Supported modes:"
103 echo " Display managers: lightdm, gdm, sddm, lxdm"
104 echo " LightDM greeters: webkit2, qtquick, slick, gtkg"
106 echo " Default mode: ${DISPLAY_MANAGER}"
108 echo " This tool is incomplete and still under development."
109 echo " If you find a bug, please report it on GitHub."
110 echo " https://github.com/FascodeNet/dmc"
128 if [[ "${NOROOT}" = false ]] && (( "${UID}" != 0 )); then
129 msg_error "You have to run as root"
137 #if (( "$(expr "${1}" + 1 >/dev/null 2>&1; printf "${?}")" < 2 )); then
138 if printf "%s" "${1}" | grep -E "^[0-9]+$" 1>/dev/null 2>&1; then
148 if [[ -n "${1}" ]] && { [[ "${1}" = "true" ]] ||[[ "${1}" = "false" ]]; }; then
157 local _command="${1}"
159 if which "${_command}" >/dev/null 2>&1; then
160 $(which "${_command}") "${@}"
162 msg_error "${_command} was not found"
169 wrapper crudini "${@}"
177 # 指定されたコマンドが現在のモードで実行可能かどうかを判定する
179 if ! printf "%s\n" "${@}" | grep -xE "${DISPLAY_MANAGER}" >/dev/null 2>&1; then
180 msg_error "This command (${COMMAND}) is not available in the current mode (${DISPLAY_MANAGER})."
185 # 現在のモードのメインバイナリが存在しているかどうか確認する
187 if [[ -z "${MAIN_BINARY["${DISPLAY_MANAGER}"]+SET}" ]]; then
188 msg_warn "The main binary for the selected mode is not set."
189 elif [[ ! -f "${MAIN_BINARY["${DISPLAY_MANAGER}"]}" ]]; then
190 msg_error "The target for the selected mode is not installed."
198 # 参考: 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
199 # 参考: https://wiki.archlinux.jp/index.php/GDM
200 #echo "Searching cursor themes..." 1>&2
201 local _dir _cursor_theme_dir_list _find_cursor_dir_list=("/usr/share/icons" "${HOME}/.local/share/icons" "${HOME}/.icons")
202 for _dir in "${_find_cursor_dir_list[@]}"; do
203 if [[ -d "${_dir}" ]]; then
204 while read -r line; do
205 _cursor_theme_dir_list+=("${line}")
206 done < <(find "${_dir}" -type d -name "cursors" -print0 | xargs -0 -i dirname {} | sort)
209 unset _dir _find_cursor_dir_list
211 local _cursor_theme _cursor_theme_name _name
212 for _cursor_theme in "${_cursor_theme_dir_list[@]}"; do
213 _name="$(grep -E "^Name=" "${_cursor_theme}/cursor.theme" 2> /dev/null | sed "s|^Name=||g")"
214 if [[ -z "${_name}" ]]; then
215 _name="$(basename "${_cursor_theme}")"
217 _cursor_theme_name+=("${_name}")
219 printf "%s\n" "${_cursor_theme_name[@]}"
224 echo "Loading GTK themes..." >&2
225 local _dir _find_theme_dir_list=("/usr/share/themes" "${HOME}/.local/share/themes" "${HOME}/.themes")
226 for _dir in "${_find_theme_dir_list[@]}"; do
227 if [[ -d "${_dir}" ]]; then
228 while read -r line; do
229 _gtk_theme_dir_list+=("${line}")
230 done < <(find "${_dir}" -type d -name "gtk-*" -print0 | xargs -0 -i dirname {} | tr " " "\n" | sort | uniq)
235 for _dir in "${_gtk_theme_dir_list[@]}"; do
236 _theme_name="$(crudini --get "${_dir}/index.theme" 'Desktop Entry' "Name" 2> /dev/null ;:)"
237 if [[ -z "${_theme_name}" ]]; then
240 _gtk_theme_name_list+=("${_theme_name}")
244 printf "%s\n" "${_gtk_theme_name_list[@]}" | sort | uniq
248 echo "Loading icons..." >&2
249 local _dir _find_theme_dir_list=("/usr/share/icons" "${HOME}/.local/share/icons" "${HOME}/.icons")
250 for _dir in "${_find_theme_dir_list[@]}"; do
251 if [[ -d "${_dir}" ]]; then
252 while read -r line; do
253 _icon_theme_dir_list+=("${line}")
254 done < <(find "${_dir}" -type f -name "index.theme" -print0 | xargs -0 -i dirname {} | tr " " "\n" | sort | uniq)
259 for _dir in "${_icon_theme_dir_list[@]}"; do
260 _theme_name="$(crudini --get "${_dir}/index.theme" 'Icon Theme' "Name" 2> /dev/null ;:)"
261 if [[ -z "${_theme_name}" ]]; then
264 _gtk_theme_name_list+=("${_theme_name}")
268 printf "%s\n" "${_gtk_theme_name_list[@]}" | sort | uniq
272 find "/usr/share/xsessions" -type f -print0 -name "*.desktop" | xargs -0 -I{} bash -c 'basename {} | sed "s|.desktop||g"'
275 get_wayland_session(){
276 find "/usr/share/wayland-sessions" -type f -print0 -name "*.desktop" | xargs -0 -I{} bash -c 'basename {} | sed "s|.desktop||g"'
280 # Returns only the selected result to standard output
281 # ask_question -d <デフォルト値> -p <質問文> <選択肢1> <選択肢2> ...
283 local arg OPTARG OPTIND
284 local _default="" _choice_list _count _choice _question
285 while getopts "d:p:" arg; do
287 d) _default="${OPTARG}" ;;
288 p) _question="${OPTARG}" ;;
292 shift $((OPTIND - 1))
293 _choice_list=("${@}")
297 if (( ${#_choice_list[@]} < 0 )); then
298 msg_error "An exception error has occurred."
302 # 選択肢が1つしか無いならばそのまま値を返す
303 if (( ${#_choice_list[@]} <= 1 )); then
304 echo "${_choice_list[*]}"
308 if [[ -v _question ]] && [[ ! "${_question}" = "" ]]; then
309 echo -e "${_question}" >&2
312 for (( _count=1; _count<=${#_choice_list[@]}; _count++)); do
313 _choice="${_choice_list[$(( _count - 1 ))]}"
314 if [[ ! "${_default}" = "" ]] && [[ "${_choice}" = "${_default}" ]]; then
315 #echo " * ${_count}: ${_choice}" >&2
316 printf " * %${_digit}d: ${_choice}\n" "${_count}" >&2
318 #echo " ${_count}: ${_choice}" >&2
319 printf " %${_digit}d: ${_choice}\n" "${_count}" >&2
323 echo -n "(1 ~ ${#_choice_list[@]}) > " >&2
327 if check_int "${_input}"; then
329 if (( 1 <= _input)) && (( _input <= ${#_choice_list[@]} )); then
330 _choice="${_choice_list[$(( _input - 1 ))]}"
336 if printf "%s\n" "${_choice_list[@]}" | grep -x "${_input}" 1>/dev/null 2>&1; then
349 if (( $(get_xorg_session | wc -l) <= 1 )); then
350 _session="$(get_xorg_session)"
351 elif [[ "${NON_INTERACTIVE}" = true ]]; then
354 _session="$(grep -E '^Session=' "${HOME}/.dmrc" 2> /dev/null | cut -d '=' -f 2)"
355 if [[ -z "${autologin_session}" ]]; then
356 msg_error "Failed to set the session."
357 msg_error "Not specified and ~/.dmrc does not exist either."
361 while read -r line; do
362 _session_list+=("${line}")
363 done < <(get_xorg_session)
364 if ! session="$(ask_question -p "Select the desktop session to autologin" "${_session_list[@]}")"; then
365 msg_error "Please enter the correct session name."
368 if [[ -f "/usr/share/xsessions/${session}.desktop" ]]; then
369 _session="${session}"
371 msg_error "Please enter the correct session name."
380 local gtk_themes _theme
381 while read -r line; do gtk_themes+=("${line}"); done < <(get_gtk_theme)
384 if ! _theme="$(ask_question -p "Please select the theme to use" "${gtk_themes[@]}")"; then
385 msg_error "Please select the correct theme"
392 # check_session <session>
394 if [[ ! -f "/usr/share/xsessions/${1}.desktop" ]]; then
396 msg_error "This is a session (${1}) that does not exist."
402 # get_session <session name>
405 local session_exec="$(crudini --get "/usr/share/xsessions/${1}.desktop" "Desktop Entry" "Exec")"
406 if [[ ! -f "${session_exec}" ]]; then
407 session_exec="$(type -p "${session_exec}")"
409 echo -n "${session_exec}"
414 # add_user_to_group <user> <group>
416 if ! getent passwd "${1}" 1> /dev/null 2>&1; then
417 echo "${1} is a non-existent user."
421 if ! getent group "${2}" 1> /dev/null 2>&1; then
422 LANG=C groupadd -r "${2}"
424 LANG=C gpasswd -a "${1}" "${2}"
428 # get_filetype <file>
430 file -inb "${1}" | cut -d ";" -f 1
435 # check_filetype <ファイルタイプ> <ファイルパス>
437 local _type="${1}" _path="${2}"
439 # ファイルタイプに/が含まれているかどうか
440 if echo "${_type}" | grep -E "^.+/.+$" >/dev/null 2<&1; then
441 # 含まれていたらファイルタイプを完全一致で判定する\
442 if [[ "${_type}" = "$(get_filetype "${_path}")" ]]; then
446 # 含まれていなかったらファイルタイプをメインタイプのみで判定する
447 if [[ "${_type}" = "$(get_filetype "${_path}" | cut -d "/" -f 1 )" ]]; then
455 # systemdのunitが存在しているか確認
456 check_systemd_unit(){
457 if [[ ! -v 1 ]]; then
459 elif systemctl cat "${1}" 1> /dev/null 2>&1; then
466 command_general_dm(){
467 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
468 msg_error "Please specify display manager"
473 systemctl disable "${CURRENT_DM}.service"
475 # 指定されたディスプレイマネージャを有効化
476 if check_systemd_unit "${1}"; then
477 systemctl enable "${1}.service"
479 msg_error "Wrong display manager name"
483 # モードをコマンドとして扱い自身を再実行する
484 # command_mode <mode> <command> <args>
486 if [[ -z "${2+SET}" ]] || [[ "${2}" = "" ]]; then
487 msg_error "Please specify command"
491 local _mode="${1}" _command="${2}"
492 local _dmc_args="-e ${USE_EDITOR} -m ${_mode}"
496 local _command_args="${*}"
497 : "${_command_args-""}" # サブコマンドの引数が何も指定されなかった場合に空文字を代入
501 if [[ "${NON_INTERACTIVE}" = true ]]; then
502 _dmc_args+=" --non-interactive"
504 if [[ "${NOROOT}" = true ]]; then
505 _dmc_args+=" --noroot"
507 if [[ "${NO_CHECK_TARGET}" = true ]]; then
508 _dmc_args+=" --no-check-target"
510 if [[ "${WRITE_ALL_FILES}" = true ]]; then
511 _dmc_args+=" --write-all-files"
514 bash -c "${SCRIPT_PATH}/$(basename "${0}") ${_dmc_args} ${_command} ${_command_args}"
519 #== LightDM用の汎用関数 ==#
521 lightdm_get_source_file(){
523 local source_name="$(lightdm --show-config 2>&1 | grep -E "^[A-Z] ${key}=" | cut -d ' ' -f 1)"
524 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")"
525 if [[ -n "${source_path}" ]]; then
526 echo -n "${source_path}"
534 lightdm_set_config(){
535 local key="${1}" value="${2}" file=${3-${DISPLAY_MANAGER_CONFIG["lightdm"]}}
536 if [[ "${WRITE_ALL_FILES}" = true ]] && [[ -n "$(lightdm_get_source_file "${1}")" ]]; then
537 crudini --set "$(lightdm_get_source_file "${1}")" 'Seat:*' "${key}" "${value}"
539 crudini --set "${file}" 'Seat:*' "${key}" "${value}"
542 if [[ ! "$(lightdm_get_value "${key}")" = "${value}" ]]; then
543 msg_error "Failed to change the setting value. A value has already been set for $(lightdm_get_source_file "${1}")"
544 msg_error "lightdm-config does not manipulate other configuration files for safety. Comment out the settings in that file."
549 lightdm_remove_key(){
550 local key="${1}" _config
551 if grep -E "^ ?${key}.+" "${DISPLAY_MANAGER_CONFIG["lightdm"]}" 1>/dev/null 2>&1; then
552 sed -i -r "s|^ ?${key} ?=.+||g" "${DISPLAY_MANAGER_CONFIG["lightdm"]}"
553 sed -i '/^$/d' "${DISPLAY_MANAGER_CONFIG["lightdm"]}"
558 lightdm_init_configs(){
560 if [[ ! -f "${DISPLAY_MANAGER_CONFIG["lightdm"]}" ]]; then
561 mkdir -p "$(dirname "${DISPLAY_MANAGER_CONFIG["lightdm"]}")"
562 touch "${DISPLAY_MANAGER_CONFIG["lightdm"]}"
563 echo "[Seat:*]" > "${DISPLAY_MANAGER_CONFIG["lightdm"]}"
569 local _current_value="$(lightdm --show-config 2>&1 | grep -E "^[A-Z] ${1}=" | sed "s|^[A-Z] ||g" | cut -d "=" -f "2")"
570 if [[ "${_current_value}" ]]; then
571 echo -n "${_current_value}"
579 lightdm_greeter_list(){
581 while read -r line; do
582 greeter_list+=("${line}")
583 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 )
584 printf "%s\n" "${greeter_list[@]}" | sort | uniq
589 command_lightdm_greeter_change() {
591 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
592 msg_error "Please specify Greeter."
596 # 指定されたGreeterが正しいか確認
597 if ! lightdm_greeter_list | grep -x "${1}" > /dev/null 2>&2; then
598 msg_error "The greeter (${1}) doesn't exist."
601 lightdm_set_config "greeter-session" "${1}"
606 command_lightdm_greeter_create(){
607 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
608 msg_error "Please specify Greeter."
611 if [[ ! -f "${1}" ]]; then
612 msg_error "${1} does not exist."
615 if [[ ! -x "${1}" ]]; then
616 msg_error "hoge is not an executable file."
621 local filename="$(basename "${1}")"
623 if [[ -f "/usr/share/xgreeters/${filename}.desktop" ]]; then
624 msg_error "Greeter with the same name already exists."
627 cat > "/usr/share/xgreeters/${filename}.desktop" <<EOF
629 Name=LightDM custom Greeter ${filename}
630 Comment=LightDM Greeter
637 command_lightdm_greeter_list() {
638 echo "Available Lightdm greeter list:"
640 for _greeter in $(lightdm_greeter_list); do
641 if [[ "${_greeter}" = "${LIGHTDM_CURRENT_GREETER}" ]]; then
642 echo " * ${_greeter}"
650 run_greeter_wizard(){
652 if (( $(lightdm_greeter_list | wc -l) < 1 )); then
653 msg_error "LightDM Greeter was not found."
659 if ! _greeter="$(ask_question -p "Please select the greeter to use." -d "${LIGHTDM_CURRENT_GREETER}" $(lightdm_greeter_list))"; then
665 if [[ -n "${_greeter}" ]]; then
666 command_lightdm_greeter_change "${_greeter}"
672 if [[ ! "${LIGHTDM_CURRENT_GREETER}" = "${_greeter}" ]]; then
673 echo "Changed greeter to ${_greeter}"
678 command_lightdm_remove(){
679 if [[ ! -f "${DISPLAY_MANAGER_CONFIG["lightdm"]}" ]]; then
683 echo -ne "Are you sure you want to delete all settings?\nThis change is irreversible.\n (y or n) > "
684 read -r -n 1 _yes_or_no
685 if [[ "${_yes_or_no}" = "y" ]]; then
686 mv "${DISPLAY_MANAGER_CONFIG["lightdm"]}" "${DISPLAY_MANAGER_CONFIG["lightdm"]}.disabled"
692 command_lightdm_greeter_edit(){
693 if [[ "${NON_INTERACTIVE}" = true ]]; then
694 msg_error "You cannot use this command in non-interactive mode."
697 local _greeter="${1:-${LIGHTDM_CURRENT_GREETER}}"
698 if [[ -z "${GREETER_CONFIG["${_greeter}"]+SET}" ]]; then
699 msg_error "This Greeter is not currently supported."
700 msg_error "Please report the problem here."
701 msg_error "https://github.com/FascodeNet/lightdm-config/issues"
704 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
705 msg_warn "Greeter was not specified. Open the currently configured Greeter configuration file."
706 echo -n "(Enter to continue) > "
710 bash -c "${USE_EDITOR} ${GREETER_CONFIG["${_greeter}"]}"
716 command_lightdm_edit(){
717 if [[ "${NON_INTERACTIVE}" = true ]]; then
718 msg_error "You cannot use this command in non-interactive mode."
721 local loaded_config_list
722 while read -r line; do
723 loaded_config_list+=("${line}")
724 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 " ")
725 for _config in "${loaded_config_list[@]}"; do
726 echo -ne "Edit ${_config} ? (y or n)> "
727 read -r -n 1 _yes_or_no
729 if [[ "${_yes_or_no}" = "y" ]]; then
730 bash -c "${USE_EDITOR} ${_config}"
736 command_lightdm_auto_login(){
737 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
738 # 既に自動ログインが設定されているかを確認
739 local autologin_user="$(lightdm_get_value autologin-user)"
740 if [[ -n "${autologin_user}" ]]; then
742 for _autologin in "autologin-guest" "autologin-user" "autologin-user-timeout" "autologin-in-background" "autologin-session"; do
743 remove_key "${_autologin}"
745 echo "Canceled automatic login of ${autologin_user}"
748 local autologin_user="${1}" autologin_session
750 autologin_session="${2}"
753 # セッションを設定 (WayLandのセッションは現在サポートされていません)
754 if [[ -z "${autologin_session+SET}" ]]; then
755 autologin_session="$(ask_session)"
758 check_session "${autologin_session}"
762 add_user_to_group "${autologin_user}" "autologin"
765 lightdm_set_config "autologin-guest" "false"
766 lightdm_set_config "autologin-user" "${autologin_user}"
767 lightdm_set_config "autologin-user-timeout" "0"
768 lightdm_set_config "autologin-in-background" "false"
769 lightdm_set_config "autologin-session" "${autologin_session}"
771 echo "${autologin_user} will automatically log in with ${autologin_session}"
777 command_lightdm_show_config(){
778 lightdm --show-config 2>&1
784 if [[ ! -f "/etc/dconf/profile/gdm" ]]; then
785 mkdir -p "/etc/dconf/profile"
786 touch "/etc/dconf/profile/gdm"
787 echo -e "user-db:user\nsystem-db:gdm\nfile-db:/usr/share/gdm/greeter-dconf-defaults" > "/etc/dconf/profile/gdm"
791 for _file in "${DISPLAY_MANAGER_CONFIG["gdm-dconf"]}" "${DISPLAY_MANAGER_CONFIG["gdm-custom"]}"; do
792 if [[ ! -f "${_file}" ]]; then
793 mkdir -p "$(dirname "${_file}")"
799 # gdm_dconf_set_config <dconf path> <key> <value>
800 gdm_dconf_set_config(){
801 if check_int "${3}" || check_bool "${3}"; then
802 crudini --set "${DISPLAY_MANAGER_CONFIG["gdm-dconf"]}" "${1}" "${2}" "${3}"
804 crudini --set "${DISPLAY_MANAGER_CONFIG["gdm-dconf"]}" "${1}" "${2}" "\"${3}\""
809 # gdm_dconf_get_value <dconf path> <key>
810 gdm_dconf_get_value(){
811 find "/etc/dconf/db/gdm.d/" -type f -print0 | xargs -0i cat {} | crudini --get - "${1}" "${2}" | sed "s|^[\"\']||g" | sed "s|[\"\']$||g"
814 # gdm_custom_get_value <section> <key>
815 gdm_custom_get_value(){
816 crudini --get "${DISPLAY_MANAGER_CONFIG["gdm-custom"]}" "${1}" "${2}"
819 # gdm_custom_set_config <section> <key> <value>
820 gdm_custom_set_config(){
821 if check_int "${3}" || check_bool "${3}"; then
822 crudini --set "${DISPLAY_MANAGER_CONFIG["gdm-custom"]}" "${1}" "${2}" "${3}"
824 crudini --set "${DISPLAY_MANAGER_CONFIG["gdm-custom"]}" "${1}" "${2}" "\"${3}\""
836 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
837 msg_error "Please specify the image of background"
840 if [[ ! -f "${1}" ]]; then
841 msg_error "${1} was not found."
845 local _backgrounf_file="${BACKGROUND_DIR}/gdm/background"
846 mkdir -p "$(dirname "${_backgrounf_file}")"
847 cp "${1}" "${_backgrounf_file}"
848 chmod 644 "${_backgrounf_file}"
850 gdm_dconf_set_config "org/gnome/login-screen" "logo" "${_backgrounf_file}"
853 command_gdm_cursor_wizard(){
855 local cursor_themes _current_theme="$(gdm_dconf_get_value "org/gnome/desktop/interface" "cursor-theme")"
856 while read -r line; do cursor_themes+=("${line}"); done < <(get_cursor_theme)
859 if ! _cursor_theme="$(ask_question -d "${_current_theme}" -p "Please select the cursor theme to use." "${cursor_themes[@]}")"; then
864 if [[ -n "${_cursor_theme}" ]]; then
865 command_gdm_cursor_change "${_cursor_theme}"
867 command_gdm_cursor_wizard
871 if [[ ! "${_current_theme}" = "${_cursor_theme}" ]]; then
872 echo "Changed cursor to ${_cursor_theme}"
876 command_gdm_cursor_change(){
877 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
878 msg_error "Please specify the cursor theme"
882 while read -r line; do cursor_themes+=("${line}"); done < <(get_cursor_theme)
883 if ! printf "%s\n" "${cursor_themes[@]}" | grep -x "${1}" 1>/dev/null 2>&1; then
884 msg_error "The cursor theme (${1}) was not found"
887 gdm_dconf_set_config "org/gnome/desktop/interface" "cursor-theme" "${1}"
891 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
892 if ! check_bool "${_arg}"; then
893 msg_error "Please specify true or false"
896 gdm_dconf_set_config "org/gnome/desktop/sound" "event-sounds" "${_arg}"
900 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
901 if ! check_bool "${_arg}"; then
902 msg_error "Please specify true or false"
905 gdm_dconf_set_config "org/gnome/desktop/peripherals/touchpad" "tap-to-click" "${_arg}"
909 command_gdm_auto_login(){
910 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
911 # 既に自動ログインが設定されているかを確認
912 local autologin="$(gdm_custom_get_value daemon AutomaticLoginEnable)"
913 if [[ "${autologin}" = "True" ]]; then
914 gdm_custom_set_config "daemon" "AutomaticLoginEnable" "False"
915 echo "Canceled automatic login of $(gdm_custom_get_value "daemon" "AutomaticLogin")"
918 local autologin_user="${1}" autologin_session
920 autologin_session="${2}"
923 # セッションを設定 (WayLandのセッションは現在サポートされていません)
924 if [[ -z "${autologin_session+SET}" ]]; then
925 autologin_session="$(ask_session)"
928 check_session "${autologin_session}"
932 add_user_to_group "${autologin_user}" "autologin"
935 gdm_custom_set_config "daemon" "AutomaticLoginEnable" "True"
936 gdm_custom_set_config "daemon" "AutomaticLogin" "${autologin_user}"
939 crudini --set "/var/lib/AccountsService/users/${autologin_user}" "User" "Session" "${autologin_session}"
940 crudini --set "/var/lib/AccountsService/users/${autologin_user}" "User" "XSession" "${autologin_session}"
942 echo "${autologin_user} will automatically log in with ${autologin_session}"
948 command_gdm_accessibility(){
949 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
950 if ! check_bool "${_arg}"; then
951 msg_error "Please specify true or false"
954 gdm_dconf_set_config "org/gnome/desktop/interface" "toolkit-accessibility" "${_arg}"
958 command_gdm_root_login(){
959 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
960 if ! check_bool "${_arg}"; then
961 msg_error "Please specify true or false"
964 gdm_custom_set_config "daemon" "AllowRoot" "${_arg}"
967 #== Webkit2用の汎用関数 ==#
968 webkit2_init_configs(){
970 if [[ ! -f "${GREETER_CONFIG["lightdm-webkit2-greeter"]}" ]]; then
971 mkdir -p "$(dirname "${GREETER_CONFIG["lightdm-webkit2-greeter"]}")"
972 touch "${GREETER_CONFIG["lightdm-webkit2-greeter"]}"
976 # webkit2_get_value <section> <key>
978 crudini --get "${GREETER_CONFIG["lightdm-webkit2-greeter"]}" "${1}" "${2}"
981 # webkit2_set_config <section> <key> <value>
982 webkit2_set_config(){
983 crudini --set "${GREETER_CONFIG["lightdm-webkit2-greeter"]}" "${1}" "${2}" "${3}"
987 command_webkit2_theme_wizard(){
989 while read -r line; do
990 _theme_list+=("${line}")
991 done < <(ls /usr/share/lightdm-webkit/themes)
993 local _current_theme=$(webkit2_get_value greeter webkit_theme | sed "s|\"||g")
995 if ! _theme="$(ask_question -d "${_current_theme}" -p "Please select the theme to use." "${_theme_list[@]}")"; then
999 if [[ -n "${_theme}" ]]; then
1000 command_webkit2_theme_change "${_theme}"
1001 echo "Changed the theme to ${_theme}"
1003 command_webkit2_theme_wizard
1009 command_webkit2_theme_change(){
1010 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1011 msg_error "Please specify the theme name"
1014 if [[ ! -d "/usr/share/lightdm-webkit/themes/${1}" ]]; then
1015 msg_error "The specified theme (${1}) does not exist"
1019 webkit2_set_config "greeter" "webkit_theme" "${1}"
1022 #== Qtquick用の汎用関数 ==#
1023 qtquick_init_configs(){
1025 if [[ ! -f "${GREETER_CONFIG["lightdm-qtquick-greeter"]}" ]] || [[ -z "$(cat "${GREETER_CONFIG["lightdm-qtquick-greeter"]}")" ]]; then
1026 mkdir -p "$(dirname "${GREETER_CONFIG["lightdm-qtquick-greeter"]}")"
1027 touch "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1028 #echo -e "{\n\n}\n" > "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1029 qtquick_set_config background_path "file:///hoge/fuga.png"
1030 qtquick_set_config theme "qrc:/Login.qml"
1034 #qtquick_get_value <key>
1035 qtquick_get_value(){
1036 jq ".${1}" < "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1039 # command_qtquick_back <key> <value>
1040 qtquick_set_config(){
1041 local _tempfile="/tmp/$(basename "${GREETER_CONFIG["lightdm-qtquick-greeter"]}")-$(base64 < "/dev/urandom" | fold -w 10 | head -n 1)"
1042 cp "${GREETER_CONFIG["lightdm-qtquick-greeter"]}" "${_tempfile}"
1043 #cat "${_tempfile}" | jq -r ".${1}|=\"${2}\"" > "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1044 jq -r ".${1}|=\"${2}\"" < "${_tempfile}" > "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1045 chmod 644 "${GREETER_CONFIG["lightdm-qtquick-greeter"]}"
1048 #== Qtquick用コマンド ==#
1049 command_qtquick_back(){
1050 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1051 msg_error "Please specify the image of background"
1054 if [[ ! -f "${1}" ]]; then
1055 msg_error "${1} was not found."
1059 local _backgrounf_file="${BACKGROUND_DIR}/lightdm/qtquick-greeter"
1060 mkdir -p "$(dirname "${_backgrounf_file}")"
1061 cp "${1}" "${_backgrounf_file}"
1062 chmod 644 "${_backgrounf_file}"
1064 qtquick_set_config "background_path" "file://${_backgrounf_file}"
1069 crudini --get "${GREETER_CONFIG["lightdm-slick-greeter"]}" "Greeter" "${1}"
1073 crudini --set "${GREETER_CONFIG["lightdm-slick-greeter"]}" "Greeter" "${1}" "${2}"
1076 slick_init_configs(){
1078 if [[ ! -f "${GREETER_CONFIG["lightdm-slick-greeter"]}" ]]; then
1079 mkdir -p "$(dirname "${GREETER_CONFIG["lightdm-slick-greeter"]}")"
1080 touch "${GREETER_CONFIG["lightdm-slick-greeter"]}"
1081 echo "[Greeter]" > "${GREETER_CONFIG["lightdm-slick-greeter"]}"
1086 command_slick_grid(){
1087 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
1088 if ! check_bool "${_arg}"; then
1089 msg_error "Please specify true or false"
1092 slick_set_config "draw-grid" "${_arg}"
1095 command_slick_back(){
1096 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1097 msg_error "Please specify the image of background"
1100 if [[ ! -f "${1}" ]]; then
1101 msg_error "${1} was not found."
1105 local _backgrounf_file="${BACKGROUND_DIR}/lightdm/slick-greeter"
1106 mkdir -p "$(dirname "${_backgrounf_file}")"
1107 cp "${1}" "${_backgrounf_file}"
1108 chmod 644 "${_backgrounf_file}"
1110 slick_set_config "background" "${_backgrounf_file}"
1114 command_slick_gtk_wizard(){
1115 local _theme="$(ask_gtk_theme)"
1118 if [[ -n "${_theme}" ]]; then
1119 command_slick_gtk_change "${_theme}"
1123 echo "Changed theme to ${_theme}"
1126 command_slick_gtk_change(){
1127 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1128 msg_error "Please specify the theme"
1131 if [[ ! -d "/usr/share/themes/${1}" ]]; then
1132 msg_error "${1} was not found."
1135 slick_set_config "theme-name" "${1}"
1138 command_slick_icon_wizard(){
1140 while read -r line; do icons+=("${line}"); done < <(get_icon_theme)
1143 echo "Please select the icon theme to use."
1144 if ! _icon="$(ask_question "${icons[@]}")"; then
1145 command_slick_icon_wizard
1149 if [[ -n "${_icon}" ]]; then
1150 slick_set_config "icon-theme-name" "${_icon}"
1152 command_slick_icon_wizard
1155 echo "Changed icon theme to ${_icon}"
1158 command_slick_icon_chenge(){
1159 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1160 msg_error "Please specify the icon theme to use."
1163 if ! printf "%s\n" "$(get_icon_theme)" | grep -x "${1}" 1> /dev/null 2>&1; then
1164 msg_error "${1} was not found."
1167 slick_set_config "icon-theme-name" "${1}"
1172 # sddm_get_value <section> <key> <valye>
1174 crudini --set "${DISPLAY_MANAGER_CONFIG["sddm"]}" "${1}" "${2}"
1177 # sddm_set_config <section> <key> <value>
1179 crudini --set "${DISPLAY_MANAGER_CONFIG["sddm"]}" "${1}" "${2}" "${3}"
1182 # sddm_remove_key <section> <key>
1184 crudini --del "${DISPLAY_MANAGER_CONFIG["sddm"]}" "${1}" "${2}"
1188 sddm_init_configs(){
1190 if [[ ! -f "${DISPLAY_MANAGER_CONFIG["sddm"]}" ]]; then
1191 mkdir -p "$(dirname "${DISPLAY_MANAGER_CONFIG["sddm"]}")"
1192 sddm --example-config > "${DISPLAY_MANAGER_CONFIG["sddm"]}"
1197 command_sddm_auto_login(){
1198 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1199 # 既に自動ログインが設定されているかを確認
1200 local autologin_user="$(sddm_get_value Autologin User)"
1201 if [[ -n "${autologin_user}" ]]; then
1202 sddm_remove_key "Autologin" "User"
1203 echo "Canceled automatic login of ${autologin_user}"
1206 local autologin_user="${1}" autologin_session
1208 autologin_session="${2}"
1211 # セッションを設定 (WayLandのセッションは現在サポートされていません)
1212 if [[ -z "${autologin_session+SET}" ]]; then
1213 autologin_session="$(ask_session)"
1216 check_session "${autologin_session}"
1220 add_user_to_group "${autologin_user}" "autologin"
1223 sddm_set_config "Autologin" "User" "${autologin_user}"
1224 sddm_set_config "Autologin" "Session" "${autologin_session}"
1226 echo "${autologin_user} will automatically log in with ${autologin_session}"
1230 command_sddm_cursor_wizard(){
1232 local cursor_themes _current_theme="$(sddm_get_value "Theme" "CursorTheme")"
1233 while read -r line; do cursor_themes+=("${line}"); done < <(get_cursor_theme)
1236 if ! _cursor_theme="$(ask_question -d "${_current_theme}" -p "Please select the cursor theme to use." "${cursor_themes[@]}")"; then
1237 command_sddm_cursor_wizard
1241 if [[ -n "${_cursor_theme}" ]]; then
1242 command_sddm_cursor_change "${_cursor_theme}"
1244 command_sddm_cursor_change
1248 if [[ ! "${_current_theme}" = "${_cursor_theme}" ]]; then
1249 echo "Changed cursor to ${_cursor_theme}"
1253 command_sddm_cursor_change(){
1254 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1255 msg_error "Please specify the cursor theme"
1259 while read -r line; do cursor_themes+=("${line}"); done < <(get_cursor_theme)
1260 if ! printf "%s\n" "${cursor_themes[@]}" | grep -x "${1}" 1>/dev/null 2>&1; then
1261 msg_error "The cursor theme (${1}) was not found"
1264 sddm_set_config "Theme" "CursorTheme" "${1}"
1267 command_sddm_numlock(){
1268 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
1269 if ! check_bool "${_arg}"; then
1270 msg_error "Please specify true or false"
1274 if [[ "${_arg}" = true ]]; then
1279 sddm_set_config "General" "Numlock" "${_value}"
1283 if ! check_int "${1}" || (( "${1}" < 1 )); then
1284 msg_error "Please enter an integer greater than 1"
1287 sddm_set_config "X11" "MinimumVT" "${1}"
1290 command_sddm_theme_wizard(){
1292 while read -r line; do
1293 _theme_list+=("${line}")
1294 done < <(find "/usr/share/sddm/themes/" -maxdepth 1 -mindepth 1 -type d -print0 | xargs -0 -I{} basename {})
1296 local _theme _current_theme=$(sddm_get_value "Theme" "Current")
1297 if ! _theme="$(ask_question -d "${_current_theme}" -p "Please select the theme to use." "${_theme_list[@]}")"; then
1298 command_sddm_theme_wizard
1301 if [[ -n "${_theme}" ]]; then
1302 command_sddm_theme_change "${_theme}"
1303 echo "Changed the theme to ${_theme}"
1305 command_sddm_theme_wizard
1311 command_sddm_theme_change(){
1312 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1313 msg_error "Please specify the theme name"
1316 if [[ ! -d "/usr/share/sddm/themes/${1}" ]]; then
1317 msg_error "The specified theme (${1}) does not exist"
1321 sddm_set_config "Theme" "Current" "${1}"
1325 # sddm_get_value <section> <key> <valye>
1327 crudini --set "${DISPLAY_MANAGER_CONFIG["lxdm"]}" "${1}" "${2}"
1330 # sddm_set_config <section> <key> <value>
1332 crudini --set "${DISPLAY_MANAGER_CONFIG["lxdm"]}" "${1}" "${2}" "${3}"
1335 # sddm_remove_key <section> <key>
1337 crudini --del "${DISPLAY_MANAGER_CONFIG["lxdm"]}" "${1}" "${2}"
1341 lxdm_init_configs(){
1343 if [[ ! -f "${DISPLAY_MANAGER_CONFIG["lxdm"]}" ]]; then
1344 mkdir -p "$(dirname "${DISPLAY_MANAGER_CONFIG["lxdm"]}")"
1345 touch "${DISPLAY_MANAGER_CONFIG["lxdm"]}"
1350 command_lxdm_auto_login(){
1351 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1352 # 既に自動ログインが設定されているかを確認
1353 local autologin_user="$(lxdm_get_value "base" "autologin")"
1354 if [[ -n "${autologin_user}" ]]; then
1355 sddm_remove_key "base" "autologin"
1356 echo "Canceled automatic login of ${autologin_user}"
1359 local autologin_user="${1}" autologin_session
1361 autologin_session="${2}"
1364 # セッションを設定 (WayLandのセッションは現在サポートされていません)
1365 if [[ -z "${autologin_session+SET}" ]]; then
1366 autologin_session="$(ask_session)"
1369 check_session "${autologin_session}"
1373 add_user_to_group "${autologin_user}" "autologin"
1376 sddm_set_config "base" "autologin" "${autologin_user}"
1379 command_lxdm_session_change "${autologin_session}"
1381 echo "${autologin_user} will automatically log in with ${autologin_session}"
1385 command_lxdm_session_wizard(){
1386 command_lxdm_session_change "$(ask_session)"
1389 command_lxdm_session_change(){
1390 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1391 msg_error "Please specify the session name"
1394 local session="${1}"
1395 check_session "${session}"
1396 local session_exec="$(get_session "${session}")"
1397 lxdm_set_config "base" "session" "${session_exec}"
1400 command_lxdm_remove_last(){
1401 rm -rf "/var/lib/lxdm/lxdm.conf"
1402 echo "Removed last configs"
1405 comamnd_lxdm_edit_script(){
1407 "LoginReady : executed with root privileges when LXDM is ready to show the login window"
1408 "PreLogin : run as root before logging a user in"
1409 "PostLogin : run as the logged-in user right after they have logged in"
1410 "PostLogout : run as the logged-in user right after they have logged out"
1411 "PreReboot : run as root before rebooting with LXDM"
1412 "PreShutdown: run as root before poweroff with LXDM"
1414 if ! file=$(ask_question -p "Select the script you want to edit" "${_filelist[@]}" | cut -d ":" -f 1 | tr -d " "); then
1415 comamnd_lxdm_edit_script
1418 bash -c "${USE_EDITOR} ${file}"
1421 command_lxdm_back(){
1422 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1423 msg_error "Please specify the image of background"
1426 if [[ ! -f "${1}" ]]; then
1427 msg_error "${1} was not found."
1431 local _backgrounf_file="${BACKGROUND_DIR}/lxdm/background"
1432 mkdir -p "$(dirname "${_backgrounf_file}")"
1433 cp "${1}" "${_backgrounf_file}"
1434 chmod 644 "${_backgrounf_file}"
1436 lxdm_set_config "display" "bg" "file://${_backgrounf_file}"
1439 command_lxdm_gtk_wizard(){
1440 local _theme="$(ask_gtk_theme)"
1443 if [[ -n "${_theme}" ]]; then
1444 command_lxdm_gtk_change "${_theme}"
1448 echo "Changed theme to ${_theme}"
1451 command_lxdm_gtk_change(){
1452 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1453 msg_error "Please specify the theme"
1456 if [[ ! -d "/usr/share/themes/${1}" ]]; then
1457 msg_error "${1} was not found."
1460 lxdm_set_config "display" "gtk_theme" "${1}"
1463 #== GTk Greeter用の汎用関数 ==#
1464 # gtk_greeter_get_value <section> <key>
1465 gtk_greeter_get_value(){
1466 crudini --set "${GREETER_CONFIG["lightdm-gtk-greeter"]}" "${1}" "${2}"
1469 # gtk_greeter_set_config <section> <key> <value>
1470 gtk_greeter_set_config(){
1471 crudini --set "${GREETER_CONFIG["lightdm-gtk-greeter"]}" "${1}" "${2}" "${3}"
1474 # gtk_greeter_remove_key <section> <key>
1475 gtk_greeter_remove_key(){
1476 crudini --del "${GREETER_CONFIG["lightdm-gtk-greeter"]}" "${1}" "${2}"
1479 gtk_greeter_init_configs(){
1481 if [[ ! -f "${GREETER_CONFIG["lightdm-gtk-greeter"]}" ]]; then
1482 mkdir -p "$(dirname "${GREETER_CONFIG["lightdm-gtk-greeter"]}")"
1483 touch "${GREETER_CONFIG["lightdm-gtk-greeter"]}"
1487 #== GTk Greeter用のコマンド==#
1488 command_gtk_greeter_gtk_wizard(){
1489 local _theme="$(ask_gtk_theme)"
1492 if [[ -n "${_theme}" ]]; then
1493 gtk_greeter_set_config "greeter" "theme-name" "${_theme}"
1497 echo "Changed theme to ${_theme}"
1500 command_gtk_greeter_gtk_change(){
1501 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1502 msg_error "Please specify the theme"
1505 if ! printf "%s\n" "$(get_gtk_theme)" | grep -x "${1}" 1> /dev/null 2>&1; then
1506 msg_error "${1} was not found."
1509 gtk_greeter_set_config "greeter" "theme-name" "${1}"
1512 command_gtk_greeter_icon_wizard(){
1514 while read -r line; do icons+=("${line}"); done < <(get_icon_theme)
1517 echo "Please select the icon theme to use."
1518 if ! _icon="$(ask_question "${icons[@]}")"; then
1519 command_gtk_greeter_icon_wizard
1523 if [[ -n "${_icon}" ]]; then
1524 gtk_greeter_set_config "greeter" "icon-theme-name" "${_icon}"
1526 command_gtk_greeter_icon_wizard
1529 echo "Changed icon theme to ${_icon}"
1532 command_gtk_greeter_icon_chenge(){
1533 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1534 msg_error "Please specify the icon theme to use."
1537 if ! printf "%s\n" "$(get_icon_theme)" | grep -x "${1}" 1> /dev/null 2>&1; then
1538 msg_error "${1} was not found."
1541 gtk_greeter_set_config "greeter" "icon-theme-name" "${_icon}"
1546 declare -A GREETER_CONFIG=(
1547 ["lightdm-webkit2-greeter"]="/etc/lightdm/lightdm-webkit2-greeter.conf"
1548 ["lightdm-slick-greeter"]="/etc/lightdm/slick-greeter.conf"
1549 ["lightdm-gtk-greeter"]="/etc/lightdm/lightdm-gtk-greeter.conf"
1550 ["io.elementary.greeter"]="/etc/lightdm/io.elementary.greeter.conf"
1551 ["lightdm-mini-greeter"]="/etc/lightdm/lightdm-mini-greeter.conf"
1552 ["lightdm-qtquick-greeter"]="/etc/lightdm/lightdm-qtquick-greeter.json"
1555 declare -A DISPLAY_MANAGER_CONFIG=(
1556 ["lightdm"]="/etc/lightdm/lightdm.conf.d/00-dmc-lightdm.conf"
1557 ["gdm-dconf"]="/etc/dconf/db/gdm.d/00-dmc-gdm"
1558 ["gdm-custom"]="/etc/gdm/custom.conf"
1559 ["sddm"]="/etc/sddm.conf.d/sddm.conf"
1560 ["lxdm"]="/etc/lxdm/lxdm.conf"
1563 declare -A MAIN_BINARY=(
1564 ["lightdm"]="/usr/bin/lightdm"
1565 ["gdm"]="/usr/bin/gdm"
1566 ["sddm"]="/usr/bin/sddm"
1567 ["webkit2"]="/usr/bin/lightdm-webkit2-greeter"
1568 ["slick"]="/usr/bin/slick-greeter"
1569 ["gtkg"]="/usr/bin/lightdm-gtk-greeter"
1570 ["elementary"]="/usr/bin/io.elementary.greeter"
1571 ["mini"]="/usr/bin/lightdm-mini-greeter"
1572 ["qtquick"]="/usr/bin/lightdm-qtquick-greeter"
1573 ["lxdm"]="/usr/bin/lxdm"
1576 declare -A GREETER_MODE=(
1577 ["lightdm-webkit2-greeter"]="webkit2"
1578 ["lightdm-slick-greeter"]="slick"
1579 ["io.elementary.greeter"]="elementary"
1580 ["lightdm-mini-greeter"]="mini"
1581 ["lightdm-qtquick-greeter"]="qtquick"
1582 ["lightdm-gtk-greeter"]="gtkg"
1587 # LightDM - Greeterのディレクトリ
1588 LIGHTDM_GREETERS_DIR="$(lightdm_get_value "greeters-directory")"
1589 : "${LIGHTDM_GREETERS_DIR:="/usr/share/xgreeters"}"
1591 # LightDM - 現在設定されているGreeter
1592 LIGHTDM_CURRENT_GREETER="$(lightdm --show-config 2>&1 | grep "greeter-session" | cut -d "=" -f 2)"
1593 : "${LIGHTDM_CURRENT_GREETER:="lightdm-gtk-greeter"}"
1596 USE_EDITOR="${EDITOR:-vi}"
1598 # Global - 背景画像をコピーするディレクトリ
1599 BACKGROUND_DIR="/usr/share/backgrounds"
1601 # Global - 現在のディスプレイマネージャ名
1602 CURRENT_DM="$(basename "$(readlink "/etc/systemd/system/display-manager.service")" | sed "s|.service$||g")"
1605 DISPLAY_MANAGER="${CURRENT_DM}"
1606 : "${DISPLAY_MANAGER:="lightdm"}"
1609 NON_INTERACTIVE=false
1610 WRITE_ALL_FILES=false
1612 NO_CHECK_TARGET=false
1617 OPTL="mode:,editor:,help,non-interactive,noroot,write-all-files,no-check-target,lightdm-greeter"
1618 # shellcheck disable=SC2086
1619 if ! OPT="$(getopt -o ${OPTS} -l ${OPTL} -- ${ARGUMENT})"; then
1623 eval set -- "${OPT}"
1629 DISPLAY_MANAGER="${2}"
1640 -G | --lightdm-greeter)
1641 if [[ -n "${LIGHTDM_CURRENT_GREETER+SET}" ]]; then
1642 DISPLAY_MANAGER="${GREETER_MODE["${LIGHTDM_CURRENT_GREETER}"]}"
1644 msg_error "Failed to get the currently running Greeter."
1650 NON_INTERACTIVE=true
1658 NO_CHECK_TARGET=true
1662 WRITE_ALL_FILES=true
1673 COMMAND="${1:-null}"
1674 if (( "${#}" >= 1 )); then
1678 : "${COMMAND_ARGS-""}" # サブコマンドの引数が何も指定されなかった場合に空文字を代入
1680 if [[ "${COMMAND}" = "null" ]]; then
1686 if [[ "${NO_CHECK_TARGET}" = false ]]; then
1690 # コマンドとモードに応じて関数を実行する
1691 case "${COMMAND}" in
1693 check_command_dm "lightdm" "gdm" "sddm" "lxdm"
1694 case "${DISPLAY_MANAGER}" in
1696 lightdm_init_configs
1697 command_lightdm_auto_login "${COMMAND_ARGS}"
1701 command_gdm_auto_login "${COMMAND_ARGS}"
1705 command_sddm_auto_login "${COMMAND_ARGS}"
1709 command_lxdm_auto_login "${COMMAND_ARGS}"
1714 check_command_dm "lightdm"
1715 lightdm_init_configs
1719 check_command_dm "lightdm"
1720 lightdm_init_configs
1721 command_lightdm_greeter_change "${COMMAND_ARGS}"
1724 check_command_dm "lightdm"
1725 lightdm_init_configs
1726 command_lightdm_greeter_create "${COMMAND_ARGS}"
1729 check_command_dm "lightdm"
1730 command_lightdm_greeter_list
1733 check_command_dm "lightdm"
1735 command_lightdm_greeter_edit "${COMMAND_ARGS}"
1738 check_command_dm "lightdm"
1740 command_lightdm_remove
1743 check_command_dm "lightdm"
1745 command_lightdm_edit
1748 check_command_dm "lightdm"
1749 command_lightdm_show_config
1752 check_command_dm "gdm" "sddm"
1753 case "${DISPLAY_MANAGER}" in
1756 command_gdm_cursor_wizard
1760 command_sddm_cursor_wizard
1765 check_command_dm "gdm" "sddm"
1766 case "${DISPLAY_MANAGER}" in
1769 command_gdm_cursor_change "${COMMAND_ARGS}"
1773 command_sddm_cursor_change "${COMMAND_ARGS}"
1778 check_command_dm "gdm"
1780 command_gdm_sound "${COMMAND_ARGS}"
1783 check_command_dm "gdm" "slick"
1784 case "${DISPLAY_MANAGER}" in
1787 command_gdm_logo "${COMMAND_ARGS}"
1791 command_slick_logo "${COMMAND_ARGS}"
1796 check_command_dm "gdm"
1798 command_gdm_tap "${COMMAND_ARGS}"
1801 check_command_dm "gdm"
1803 command_gdm_accessibility "${COMMAND_ARGS}"
1806 check_command_dm "gdm"
1808 command_gdm_root_login "${COMMAND_ARGS}"
1811 check_command_dm "webkit2" "sddm"
1812 case "${DISPLAY_MANAGER}" in
1814 webkit2_init_configs
1815 command_webkit2_theme_wizard
1819 command_sddm_theme_wizard
1824 check_command_dm "webkit2" "sddm"
1825 case "${DISPLAY_MANAGER}" in
1827 webkit2_init_configs
1828 command_webkit2_theme_change "${COMMAND_ARGS}"
1832 command_sddm_theme_change
1837 check_command_dm "slick" "lxdm" "gtkg"
1838 case "${DISPLAY_MANAGER}" in
1841 command_slick_gtk_wizard
1845 command_lxdm_gtk_wizard
1848 gtk_greeter_init_configs
1849 command_gtk_greeter_gtk_wizard
1854 check_command_dm "slick" "lxdm" "gtkg"
1855 case "${DISPLAY_MANAGER}" in
1858 command_slick_gtk_change "${COMMAND_ARGS}"
1861 command_lxdm_gtk_change "${COMMAND_ARGS}"
1864 command_gtk_greeter_gtk_change "${COMMAND_ARGS}"
1869 check_command_dm "qtquick" "slick" "lxdm"
1870 case "${DISPLAY_MANAGER}" in
1872 qtquick_init_configs
1873 command_qtquick_back "${COMMAND_ARGS}"
1877 command_slick_back "${COMMAND_ARGS}"
1881 command_lxdm_back "${COMMAND_ARGS}"
1886 check_command_dm "slick"
1888 command_slick_grid "${COMMAND_ARGS}"
1891 check_command_dm "slick" "gtkg"
1892 case "${DISPLAY_MANAGER}" in
1895 command_slick_icon_wizard
1898 gtk_greeter_init_configs
1899 command_gtk_greeter_icon_wizard
1904 check_command_dm "slick" "gtkg"
1905 case "${DISPLAY_MANAGER}" in
1908 command_slick_icon_chenge "${COMMAND_ARGS}"
1911 gtk_greeter_init_configs
1912 command_gtk_greeter_icon_chenge "${COMMAND_ARGS}"
1917 check_command_dm "slick"
1919 command_slick_other_monitor "${COMMAND_ARGS}"
1922 check_command_dm "sddm"
1924 command_sddm_numlock "${COMMAND_ARGS}"
1927 check_command_dm "sddm"
1929 command_sddm_tty "${COMMAND_ARGS}"
1932 check_command_dm "lxdm"
1934 command_lxdm_session_wizard
1937 check_command_dm "lxdm"
1939 command_lxdm_session_change "${COMMAND_ARGS}"
1942 check_command_dm "lxdm"
1944 command_lxdm_remove_last
1947 check_command_dm "lxdm"
1949 comamnd_lxdm_edit_script
1952 command_general_dm "${COMMAND_ARGS}"
1954 "lightdm" | "gdm" | "sddm" | "lxdm" | "webkit2" | "qtquick" | "slick" | "gtkg")
1955 command_mode "${COMMAND}" "${COMMAND_ARGS}"
1958 msg_error "This command cannot be used in any mode"