6 # Email : hayao@fascode.net
8 # (c) 2019-2021 Fascode Network.
10 # dmc - display manager config tool
12 # Tool to change display manager settings
13 # It supports various display managers.
15 # LICENSE: THE SUSHI-WARE LICENSE
16 # https://github.com/MakeNowJust/sushi-ware
20 # https://qiita.com/laikuaut/items/4bc07eabce56ee30812d
21 # https://qiita.com/t_nakayama0714/items/80b4c94de43643f4be51
23 SCRIPT_PATH="$( cd -P "$( dirname "$(readlink -f "${0}")" )" && pwd )"
26 echo "usage: dmc [options] [command]"
28 echo "Tool to change display manager settings"
30 echo " General command:"
31 echo " dm [display manager] Set display manager"
32 echo " [mode] [command] You can specify the mode as a command"
33 echo " gtk-list Show a list of GTK theme"
34 echo " help Show this help document"
36 echo " LightDM command:"
37 echo " autologin [username] [session] Set up automatic login (with blank username to disable)"
38 echo " greeter Run greeter setup wizard"
39 echo " greeter-create [file] Set the specified executable file as Greeter"
40 echo " greeter-change [greeter] Specify the greeter to use"
41 echo " greeter-edit [greeter] Edit the greeter configs"
42 echo " greeter-list Show a list of currently installed Greeters"
43 echo " remove Removes all changes made by this command"
44 echo " edit Edit lightdm config"
45 echo " show-config Show current settings"
48 echo " autologin [username] [session] Set up automatic login (with blank username to disable)"
49 echo " cursor Run cursor selection wizard"
50 echo " cursor-change [cursor] Specify the cursor theme"
51 echo " cursor-list Show a list of cursor theme"
52 echo " edit Edit config file"
53 echo " sound [true or false] Toggle the sound when an event occurs"
54 echo " logo [image] Specify the logo of the login screen"
55 echo " tap [true or false] Toggle whether to recognize the tap as a click"
56 echo " accessibility [true or false] Toggle whether to show accessibility menu"
57 echo " root-login [true or false] Toggle whether to enable root login"
58 echo " remove Removes all settings"
60 echo " GTKG command: (lightdm-gtk-greeter)"
61 echo " gtk Run gtk theme selection wizard"
62 echo " gtk-change [theme] Specify gtk theme"
63 echo " icon Run icon theme selection wizard"
64 echo " icon-change [icon] Specify the icon theme"
66 echo " Webkit2 command: (lightdm-webkit2-greeter)"
67 echo " theme Run theme selection wizard"
68 echo " theme-change [theme] Specify the theme"
69 echo " remove Removes all settings"
70 echo " debug [true or false] Toggle debug mode"
72 echo " Qtquick command: (lightdm-qtquick-greeter)"
73 echo " back Specify the background image"
74 echo " remove Removes all settings"
76 echo " Slick command: (lightdm-slick-greeter)"
77 echo " back [image] Specify the background image"
78 echo " grid [true or false] Toggle whether to show grid"
79 echo " icon Run icon theme selection wizard"
80 echo " icon-change [icon] Specify the icon theme"
81 echo " gtk Run gtk theme selection wizard"
82 echo " gtk-change [theme] Specify gtk theme"
85 echo " autologin [username] [session] Set up automatic login (with blank username to disable)"
86 echo " cursor Run cursor selection wizard"
87 echo " cursor-change [cursor] Specify the cursor theme"
88 echo " numlock [true or false] Toggle whether to enable Numlock force"
89 echo " tty [int number] The lowest virtual terminal number that will be used"
90 echo " theme Run theme selection wizard"
91 echo " theme-change [theme] Specify the theme"
94 echo " autologin [username] [session] Set up automatic login (with blank username to disable)"
95 echo " back [image] Specify the background image"
96 echo " session Run default session selection wizard"
97 echo " session-change [session] Specify the default session"
98 echo " remove-last Remove last selected setting"
99 echo " edit-script Edit the script"
100 echo " gtk Run gtk theme selection wizard"
101 echo " gtk-change [theme] Specify gtk theme"
103 echo " General option:"
104 echo " -G | --lightdm-greeter Automatically get the current greeter and set as mode (Only LightDM)"
105 echo " -m | --mode [mode name] Specifiy the target you want to set"
106 echo " -e | --editer [editor path] Specifiy the editor to use for editing"
107 echo " -h | --help This help message and exit"
108 echo " --non-interactive Run in non-interactive mode"
109 echo " --no-check-target No check the target for the selected mode"
110 echo " --noroot No check root permission"
111 echo " --write-all-files Allows rewriting of all configuration files"
112 echo " --remove Remove the file instead of renaming it with the remove command"
114 echo " Supported modes:"
115 echo " Display managers: lightdm, gdm, sddm, lxdm"
116 echo " LightDM greeters: webkit2, qtquick, slick, gtkg"
118 echo " Default mode: ${MODE}"
120 echo " This tool is incomplete and still under development."
121 echo " If you find a bug, please report it on GitHub."
122 echo " https://github.com/FascodeNet/dmc"
140 if [[ "${NOROOT}" = false ]] && (( "${UID}" != 0 )); then
141 msg_error "You have to run as root"
148 if printf "%s" "${1}" | grep -E "^[0-9]+$" 1>/dev/null 2>&1; then
156 if [[ -n "${1}" ]] && { [[ "${1}" = "true" ]] ||[[ "${1}" = "false" ]]; }; then
165 local _command="${1}"
167 if which "${_command}" >/dev/null 2>&1; then
168 $(which "${_command}") "${@}"
170 msg_error "${_command} was not found"
177 wrapper crudini "${@}"
185 # 指定されたコマンドが現在のモードで実行可能かどうかを判定する
187 if ! printf "%s\n" "${@}" | grep -xE "${MODE}" >/dev/null 2>&1; then
188 msg_error "This command (${COMMAND}) is not available in the current mode (${MODE})."
193 # 現在のモードのメインバイナリが存在しているかどうか確認する
195 if [[ -z "${MAIN_BINARY["${MODE}"]+SET}" ]]; then
196 msg_warn "The main binary for the selected mode is not set."
197 elif [[ ! -f "${MAIN_BINARY["${MODE}"]}" ]]; then
198 msg_error "The target for the selected mode is not installed."
206 # 参考: 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
207 # 参考: https://wiki.archlinux.jp/index.php/GDM
208 #echo "Searching cursor themes..." 1>&2
209 local _dir _cursor_theme_dir_list _find_cursor_dir_list=("/usr/share/icons" "${HOME}/.local/share/icons" "${HOME}/.icons")
210 for _dir in "${_find_cursor_dir_list[@]}"; do
211 if [[ -d "${_dir}" ]]; then
212 while read -r line; do
213 _cursor_theme_dir_list+=("${line}")
214 done < <(find "${_dir}" -type d -name "cursors" -print0 | xargs -0 -I{} dirname {} | sort)
217 unset _dir _find_cursor_dir_list
219 local _cursor_theme _cursor_theme_name _name
220 for _cursor_theme in "${_cursor_theme_dir_list[@]}"; do
221 _name="$(grep -E "^Name=" "${_cursor_theme}/cursor.theme" 2> /dev/null | sed "s|^Name=||g")"
222 if [[ -z "${_name}" ]]; then
223 _name="$(basename "${_cursor_theme}")"
225 _cursor_theme_name+=("${_name}")
227 printf "%s\n" "${_cursor_theme_name[@]}"
232 echo "Loading GTK themes..." >&2
233 local _dir _find_theme_dir_list=("/usr/share/themes" "${HOME}/.local/share/themes" "${HOME}/.themes")
234 for _dir in "${_find_theme_dir_list[@]}"; do
235 if [[ -d "${_dir}" ]]; then
236 while read -r line; do
237 _gtk_theme_dir_list+=("${line}")
238 done < <(find "${_dir}" -type d -name "gtk-*" -print0 | xargs -0 -I{} dirname {} | tr " " "\n" | sort | uniq)
243 for _dir in "${_gtk_theme_dir_list[@]}"; do
244 _theme_name="$(crudini --get "${_dir}/index.theme" 'Desktop Entry' "Name" 2> /dev/null ;:)"
245 if [[ -z "${_theme_name}" ]]; then
248 _gtk_theme_name_list+=("${_theme_name}")
252 printf "%s\n" "${_gtk_theme_name_list[@]}" | sort | uniq
256 echo "Loading icons..." >&2
257 local _dir _find_theme_dir_list=("/usr/share/icons" "${HOME}/.local/share/icons" "${HOME}/.icons")
258 for _dir in "${_find_theme_dir_list[@]}"; do
259 if [[ -d "${_dir}" ]]; then
260 while read -r line; do
261 _icon_theme_dir_list+=("${line}")
262 done < <(find "${_dir}" -type f -name "index.theme" -print0 | xargs -0 -I{} dirname {} | tr " " "\n" | sort | uniq)
267 for _dir in "${_icon_theme_dir_list[@]}"; do
268 _theme_name="$(crudini --get "${_dir}/index.theme" 'Icon Theme' "Name" 2> /dev/null ;:)"
269 if [[ -z "${_theme_name}" ]]; then
272 _gtk_theme_name_list+=("${_theme_name}")
276 printf "%s\n" "${_gtk_theme_name_list[@]}" | sort | uniq
280 find "/usr/share/xsessions" -type f -print0 -name "*.desktop" | xargs -0 -I{} bash -c 'basename {} | sed "s|.desktop||g"'
283 get_wayland_session(){
284 find "/usr/share/wayland-sessions" -type f -print0 -name "*.desktop" | xargs -0 -I{} bash -c 'basename {} | sed "s|.desktop||g"'
288 # Returns only the selected result to standard output
289 # ask_question -d <デフォルト値> -p <質問文> <選択肢1> <選択肢2> ...
291 local arg OPTARG OPTIND _default="" _choice_list _count _choice _question
292 while getopts "d:p:" arg; do
294 d) _default="${OPTARG}" ;;
295 p) _question="${OPTARG}" ;;
299 shift "$((OPTIND - 1))"
300 _choice_list=("${@}")
304 if (( ${#_choice_list[@]} < 0 )); then
305 msg_error "An exception error has occurred."
309 # 選択肢が1つしか無いならばそのまま値を返す
310 if (( ${#_choice_list[@]} <= 1 )); then
311 echo "${_choice_list[*]}"
315 if [[ -v _question ]] && [[ ! "${_question}" = "" ]]; then
316 echo -e "${_question}" >&2
319 for (( _count=1; _count<=${#_choice_list[@]}; _count++)); do
320 _choice="${_choice_list[$(( _count - 1 ))]}"
321 if [[ ! "${_default}" = "" ]] && [[ "${_choice}" = "${_default}" ]]; then
322 printf " * %${_digit}d: ${_choice}\n" "${_count}" >&2
324 printf " %${_digit}d: ${_choice}\n" "${_count}" >&2
328 echo -n "(1 ~ ${#_choice_list[@]}) > " >&2
332 if check_int "${_input}"; then
334 if (( 1 <= _input)) && (( _input <= ${#_choice_list[@]} )); then
335 _choice="${_choice_list[$(( _input - 1 ))]}"
341 if printf "%s\n" "${_choice_list[@]}" | grep -x "${_input}" 1>/dev/null 2>&1; then
354 if (( $(get_xorg_session | wc -l) <= 1 )); then
355 _session="$(get_xorg_session)"
356 elif [[ "${NON_INTERACTIVE}" = true ]]; then
359 _session="$(grep -E '^Session=' "${HOME}/.dmrc" 2> /dev/null | cut -d '=' -f 2)"
360 if [[ -z "${autologin_session}" ]]; then
361 msg_error "Failed to set the session."
362 msg_error "Not specified and ~/.dmrc does not exist either."
366 readarray -t _session_list < <(get_xorg_session)
367 if ! session="$(ask_question -p "Select the desktop session to autologin" "${_session_list[@]}")"; then
368 msg_error "Please enter the correct session name."
371 if [[ -f "/usr/share/xsessions/${session}.desktop" ]]; then
372 _session="${session}"
374 msg_error "Please enter the correct session name."
383 local gtk_themes _theme
384 readarray -t gtk_themes < <(get_gtk_theme)
387 if ! _theme="$(ask_question -p "Please select the theme to use" "${gtk_themes[@]}")"; then
388 msg_error "Please select the correct theme"
395 # check_session <session>
397 if [[ ! -f "/usr/share/xsessions/${1}.desktop" ]]; then
399 msg_error "This is a session (${1}) that does not exist."
405 # get_session <session name>
408 local session_exec="$(crudini --get "/usr/share/xsessions/${1}.desktop" "Desktop Entry" "Exec")"
409 if [[ ! -f "${session_exec}" ]]; then
410 session_exec="$(type -p "${session_exec}")"
412 echo -n "${session_exec}"
417 # add_user_to_group <user> <group>
419 if ! getent passwd "${1}" 1> /dev/null 2>&1; then
420 echo "${1} is a non-existent user."
424 if ! getent group "${2}" 1> /dev/null 2>&1; then
425 LANG=C groupadd -r "${2}"
427 LANG=C gpasswd -a "${1}" "${2}"
431 # get_filetype <file>
433 file -inb "${1}" | cut -d ";" -f 1
438 # check_filetype <ファイルタイプ> <ファイルパス>
440 local _type="${1}" _path="${2}"
442 # ファイルタイプに/が含まれているかどうか
443 if echo "${_type}" | grep -E "^.+/.+$" >/dev/null 2<&1; then
444 # 含まれていたらファイルタイプを完全一致で判定する\
445 if [[ "${_type}" = "$(get_filetype "${_path}")" ]]; then
449 # 含まれていなかったらファイルタイプをメインタイプのみで判定する
450 if [[ "${_type}" = "$(get_filetype "${_path}" | cut -d "/" -f 1 )" ]]; then
458 # systemdのunitが存在しているか確認
459 check_systemd_unit(){
460 if [[ ! -v 1 ]]; then
462 elif systemctl cat "${1}" 1> /dev/null 2>&1; then
470 common_remove_command(){
471 local _file _yes_or_no
472 for _file in "${@}"; do
473 if [[ -f "${_file}" ]]; then
474 if [[ "${NON_INTERACTIVE}" = true ]]; then
477 echo -e "Remove ${_file} ? It is irreversible"
478 echo -ne "(y or n) > "
479 read -r -n 1 _yes_or_no
482 if [[ "${_yes_or_no}" = "y" ]]; then
483 if [[ "${REMOVE_FILES}" = true ]]; then
484 echo "Removed ${_file}"
487 echo "Moved ${_file} ${_file}.disabled"
488 mv "${_file}" "${_file}.disabled"
498 command_general_dm(){
499 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
500 msg_error "Please specify display manager"
505 if [[ -n "${CURRENT_DM+SET}" ]]; then
506 systemctl disable "${CURRENT_DM}.service"
509 # 指定されたディスプレイマネージャを有効化
510 if check_systemd_unit "${1}"; then
511 systemctl enable "${1}.service"
513 msg_error "Wrong display manager name"
517 # モードをコマンドとして扱い自身を再実行する
518 # command_mode <mode> <command> <args>
520 if [[ -z "${2+SET}" ]] || [[ "${2}" = "" ]]; then
521 msg_error "Please specify command"
525 local _mode="${1}" _command="${2}"
526 local _dmc_args="-e ${USE_EDITOR} -m ${_mode}"
530 local _command_args="${*}"
531 : "${_command_args-""}" # サブコマンドの引数が何も指定されなかった場合に空文字を代入
535 if [[ "${NON_INTERACTIVE}" = true ]]; then
536 _dmc_args+=" --non-interactive"
538 if [[ "${NOROOT}" = true ]]; then
539 _dmc_args+=" --noroot"
541 if [[ "${NO_CHECK_TARGET}" = true ]]; then
542 _dmc_args+=" --no-check-target"
544 if [[ "${WRITE_ALL_FILES}" = true ]]; then
545 _dmc_args+=" --write-all-files"
548 bash -c "${SCRIPT_PATH}/$(basename "${0}") ${_dmc_args} ${_command} ${_command_args}"
553 #== LightDM用の汎用関数 ==#
555 lightdm_get_source_file(){
557 local source_name="$(lightdm --show-config 2>&1 | grep -E "^[A-Z] ${key}=" | cut -d ' ' -f 1)"
558 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")"
559 if [[ -n "${source_path}" ]]; then
560 echo -n "${source_path}"
568 lightdm_set_config(){
569 local key="${1}" value="${2}" file=${3-${MODE_CONFIG["lightdm"]}}
570 if [[ "${WRITE_ALL_FILES}" = true ]] && [[ -n "$(lightdm_get_source_file "${1}")" ]]; then
571 crudini --set "$(lightdm_get_source_file "${1}")" 'Seat:*' "${key}" "${value}"
573 crudini --set "${file}" 'Seat:*' "${key}" "${value}"
576 if [[ ! "$(lightdm_get_value "${key}")" = "${value}" ]]; then
577 msg_error "Failed to change the setting value. A value has already been set for $(lightdm_get_source_file "${1}")"
578 msg_error "lightdm-config does not manipulate other configuration files for safety. Comment out the settings in that file."
583 lightdm_remove_key(){
584 local key="${1}" _config
585 if grep -E "^ ?${key}.+" "${MODE_CONFIG["lightdm"]}" 1>/dev/null 2>&1; then
586 sed -i -r "s|^ ?${key} ?=.+||g" "${MODE_CONFIG["lightdm"]}"
587 sed -i '/^$/d' "${MODE_CONFIG["lightdm"]}"
592 lightdm_init_configs(){
594 if [[ ! -f "${MODE_CONFIG["lightdm"]}" ]]; then
595 mkdir -p "$(dirname "${MODE_CONFIG["lightdm"]}")"
596 touch "${MODE_CONFIG["lightdm"]}"
597 echo "[Seat:*]" > "${MODE_CONFIG["lightdm"]}"
603 local _current_value="$(lightdm --show-config 2>&1 | grep -E "^[A-Z] ${1}=" | sed "s|^[A-Z] ||g" | cut -d "=" -f "2")"
604 if [[ "${_current_value}" ]]; then
605 echo -n "${_current_value}"
613 lightdm_greeter_list(){
615 readarray -t greeter_list < <( (find "${LIGHTDM_GREETERS_DIR}" -print0 -type f | xargs -0 -I{} basename {} | grep -E ".desktop$" | sed "s|.desktop$||g" | grep -xv "xgreeters") 2> /dev/null )
616 printf "%s\n" "${greeter_list[@]}" | sort | uniq
621 command_lightdm_greeter_change() {
623 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
624 msg_error "Please specify Greeter."
628 # 指定されたGreeterが正しいか確認
629 if ! lightdm_greeter_list | grep -x "${1}" > /dev/null 2>&2; then
630 msg_error "The greeter (${1}) doesn't exist."
633 lightdm_set_config "greeter-session" "${1}"
638 command_lightdm_greeter_create(){
639 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
640 msg_error "Please specify Greeter."
643 if [[ ! -f "${1}" ]]; then
644 msg_error "${1} does not exist."
647 if [[ ! -x "${1}" ]]; then
648 msg_error "hoge is not an executable file."
653 local filename="$(basename "${1}")"
655 if [[ -f "/usr/share/xgreeters/${filename}.desktop" ]]; then
656 msg_error "Greeter with the same name already exists."
659 cat > "/usr/share/xgreeters/${filename}.desktop" <<EOF
661 Name=LightDM custom Greeter ${filename}
662 Comment=LightDM Greeter
669 command_lightdm_greeter_list() {
670 echo "Available Lightdm greeter list:"
672 for _greeter in $(lightdm_greeter_list); do
673 if [[ "${_greeter}" = "${LIGHTDM_CURRENT_GREETER}" ]]; then
674 echo " * ${_greeter}"
682 command_lightdm_greeter_wizard(){
684 if (( $(lightdm_greeter_list | wc -l) < 1 )); then
685 msg_error "LightDM Greeter was not found."
691 # shellcheck disable=SC2046
692 if ! _greeter="$(ask_question -p "Please select the greeter to use." -d "${LIGHTDM_CURRENT_GREETER}" $(lightdm_greeter_list))"; then
693 command_lightdm_greeter_wizard
698 if [[ -n "${_greeter}" ]]; then
699 command_lightdm_greeter_change "${_greeter}"
701 command_lightdm_greeter_wizard
705 if [[ ! "${LIGHTDM_CURRENT_GREETER}" = "${_greeter}" ]]; then
706 echo "Changed greeter to ${_greeter}"
711 command_lightdm_remove(){
712 common_remove_command "${MODE_CONFIG["lightdm"]}"
716 command_lightdm_greeter_edit(){
717 if [[ "${NON_INTERACTIVE}" = true ]]; then
718 msg_error "You cannot use this command in non-interactive mode."
721 local _greeter="${1:-${LIGHTDM_CURRENT_GREETER}}"
722 if [[ -z "${MODE_CONFIG[${GREETER_MODE["${_greeter}"]}]+SET}" ]]; then
723 msg_error "This Greeter is not currently supported."
724 msg_error "Please report the problem here."
725 msg_error "https://github.com/FascodeNet/lightdm-config/issues"
728 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
729 msg_warn "Greeter was not specified. Open the currently configured Greeter configuration file."
730 echo -n "(Enter to continue) > "
734 bash -c "${USE_EDITOR} ${MODE_CONFIG[${GREETER_MODE["${_greeter}"]}]}"
740 command_lightdm_edit(){
741 if [[ "${NON_INTERACTIVE}" = true ]]; then
742 msg_error "You cannot use this command in non-interactive mode."
745 local loaded_config_list
746 readarray -t loaded_config_list < <(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 " ")
747 for _config in "${loaded_config_list[@]}"; do
748 echo -ne "Edit ${_config} ? (y or n)> "
749 read -r -n 1 _yes_or_no
751 if [[ "${_yes_or_no}" = "y" ]]; then
752 bash -c "${USE_EDITOR} ${_config}"
758 command_lightdm_auto_login(){
759 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
760 # 既に自動ログインが設定されているかを確認
761 local autologin_user="$(lightdm_get_value autologin-user)"
762 if [[ -n "${autologin_user}" ]]; then
764 for _autologin in "autologin-guest" "autologin-user" "autologin-user-timeout" "autologin-in-background" "autologin-session"; do
765 lightdm_remove_key "${_autologin}"
767 echo "Canceled automatic login of ${autologin_user}"
770 local autologin_user="${1}" autologin_session
772 autologin_session="${2}"
775 # セッションを設定 (WayLandのセッションは現在サポートされていません)
776 if [[ -z "${autologin_session+SET}" ]]; then
777 autologin_session="$(ask_session)"
780 check_session "${autologin_session}"
784 add_user_to_group "${autologin_user}" "autologin"
787 lightdm_set_config "autologin-guest" "false"
788 lightdm_set_config "autologin-user" "${autologin_user}"
789 lightdm_set_config "autologin-user-timeout" "0"
790 lightdm_set_config "autologin-in-background" "false"
791 lightdm_set_config "autologin-session" "${autologin_session}"
793 echo "${autologin_user} will automatically log in with ${autologin_session}"
799 command_lightdm_show_config(){
800 lightdm --show-config 2>&1
806 if [[ ! -f "/etc/dconf/profile/gdm" ]]; then
807 mkdir -p "/etc/dconf/profile"
808 touch "/etc/dconf/profile/gdm"
809 echo -e "user-db:user\nsystem-db:gdm\nfile-db:/usr/share/gdm/greeter-dconf-defaults" > "/etc/dconf/profile/gdm"
813 for _file in "${MODE_CONFIG["gdm-dconf"]}" "${MODE_CONFIG["gdm-custom"]}"; do
814 if [[ ! -f "${_file}" ]]; then
815 mkdir -p "$(dirname "${_file}")"
821 # gdm_dconf_set_config <dconf path> <key> <value>
822 gdm_dconf_set_config(){
823 if check_int "${3}" || check_bool "${3}"; then
824 crudini --set "${MODE_CONFIG["gdm-dconf"]}" "${1}" "${2}" "${3}"
826 crudini --set "${MODE_CONFIG["gdm-dconf"]}" "${1}" "${2}" "\"${3}\""
831 # gdm_dconf_get_value <dconf path> <key>
832 gdm_dconf_get_value(){
833 find "/etc/dconf/db/gdm.d/" -type f -print0 | xargs -0 -I{} cat {} | crudini --get - "${1}" "${2}" | sed "s|^[\"\']||g" | sed "s|[\"\']$||g"
836 # gdm_custom_get_value <section> <key>
837 gdm_custom_get_value(){
838 crudini --get "${MODE_CONFIG["gdm-custom"]}" "${1}" "${2}"
841 # gdm_custom_set_config <section> <key> <value>
842 gdm_custom_set_config(){
843 if check_int "${3}" || check_bool "${3}"; then
844 crudini --set "${MODE_CONFIG["gdm-custom"]}" "${1}" "${2}" "${3}"
846 crudini --set "${MODE_CONFIG["gdm-custom"]}" "${1}" "${2}" "\"${3}\""
858 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
859 msg_error "Please specify the image of background"
862 if [[ ! -f "${1}" ]]; then
863 msg_error "${1} was not found."
867 local _backgrounf_file="${BACKGROUND_DIR}/gdm/background"
868 mkdir -p "$(dirname "${_backgrounf_file}")"
869 cp "${1}" "${_backgrounf_file}"
870 chmod 644 "${_backgrounf_file}"
872 gdm_dconf_set_config "org/gnome/login-screen" "logo" "${_backgrounf_file}"
875 command_gdm_cursor_wizard(){
877 local cursor_themes _current_theme="$(gdm_dconf_get_value "org/gnome/desktop/interface" "cursor-theme")"
878 readarray -t cursor_themes < <(get_cursor_theme)
881 if ! _cursor_theme="$(ask_question -d "${_current_theme}" -p "Please select the cursor theme to use." "${cursor_themes[@]}")"; then
882 command_gdm_cursor_wizard
886 if [[ -n "${_cursor_theme}" ]]; then
887 command_gdm_cursor_change "${_cursor_theme}"
889 command_gdm_cursor_wizard
893 if [[ ! "${_current_theme}" = "${_cursor_theme}" ]]; then
894 echo "Changed cursor to ${_cursor_theme}"
898 command_gdm_cursor_change(){
899 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
900 msg_error "Please specify the cursor theme"
904 readarray -t cursor_themes < <(get_cursor_theme)
905 if ! printf "%s\n" "${cursor_themes[@]}" | grep -x "${1}" 1>/dev/null 2>&1; then
906 msg_error "The cursor theme (${1}) was not found"
909 gdm_dconf_set_config "org/gnome/desktop/interface" "cursor-theme" "${1}"
913 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
914 if ! check_bool "${_arg}"; then
915 msg_error "Please specify true or false"
918 gdm_dconf_set_config "org/gnome/desktop/sound" "event-sounds" "${_arg}"
922 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
923 if ! check_bool "${_arg}"; then
924 msg_error "Please specify true or false"
927 gdm_dconf_set_config "org/gnome/desktop/peripherals/touchpad" "tap-to-click" "${_arg}"
931 if [[ "${NON_INTERACTIVE}" = true ]]; then
932 msg_error "You cannot use this command in non-interactive mode."
935 bash -c "${USE_EDITOR} ${MODE_CONFIG["gdm-custom"]}"
938 command_gdm_remove(){
939 common_remove_command "${MODE_CONFIG["gdm-custom"]}"
943 command_gdm_auto_login(){
944 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
945 # 既に自動ログインが設定されているかを確認
946 local autologin="$(gdm_custom_get_value daemon AutomaticLoginEnable)"
947 if [[ "${autologin}" = "True" ]]; then
948 gdm_custom_set_config "daemon" "AutomaticLoginEnable" "False"
949 echo "Canceled automatic login of $(gdm_custom_get_value "daemon" "AutomaticLogin")"
952 local autologin_user="${1}" autologin_session
954 autologin_session="${2}"
957 # セッションを設定 (WayLandのセッションは現在サポートされていません)
958 if [[ -z "${autologin_session+SET}" ]]; then
959 autologin_session="$(ask_session)"
962 check_session "${autologin_session}"
966 add_user_to_group "${autologin_user}" "autologin"
969 gdm_custom_set_config "daemon" "AutomaticLoginEnable" "True"
970 gdm_custom_set_config "daemon" "AutomaticLogin" "${autologin_user}"
973 crudini --set "/var/lib/AccountsService/users/${autologin_user}" "User" "Session" "${autologin_session}"
974 crudini --set "/var/lib/AccountsService/users/${autologin_user}" "User" "XSession" "${autologin_session}"
976 echo "${autologin_user} will automatically log in with ${autologin_session}"
982 command_gdm_accessibility(){
983 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
984 if ! check_bool "${_arg}"; then
985 msg_error "Please specify true or false"
988 gdm_dconf_set_config "org/gnome/desktop/interface" "toolkit-accessibility" "${_arg}"
992 command_gdm_root_login(){
993 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
994 if ! check_bool "${_arg}"; then
995 msg_error "Please specify true or false"
998 gdm_custom_set_config "daemon" "AllowRoot" "${_arg}"
1001 #== Webkit2用の汎用関数 ==#
1002 webkit2_init_configs(){
1004 if [[ ! -f "${MODE_CONFIG["webkit2"]}" ]]; then
1005 mkdir -p "$(dirname "${MODE_CONFIG["webkit2"]}")"
1006 touch "${MODE_CONFIG["webkit2"]}"
1010 # webkit2_get_value <section> <key>
1011 webkit2_get_value(){
1012 crudini --get "${MODE_CONFIG["webkit2"]}" "${1}" "${2}"
1015 # webkit2_set_config <section> <key> <value>
1016 webkit2_set_config(){
1017 crudini --set "${MODE_CONFIG["webkit2"]}" "${1}" "${2}" "${3}"
1020 #== webkit2用コマンド ==#
1021 command_webkit2_theme_wizard(){
1023 readarray -t _theme_list < <(ls /usr/share/lightdm-webkit/themes)
1025 local _current_theme=$(webkit2_get_value greeter webkit_theme | sed "s|\"||g")
1027 if ! _theme="$(ask_question -d "${_current_theme}" -p "Please select the theme to use." "${_theme_list[@]}")"; then
1028 command_webkit2_theme_wizard
1031 if [[ -n "${_theme}" ]]; then
1032 command_webkit2_theme_change "${_theme}"
1033 echo "Changed the theme to ${_theme}"
1035 command_webkit2_theme_wizard
1041 command_webkit2_theme_change(){
1042 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1043 msg_error "Please specify the theme name"
1046 if [[ ! -d "/usr/share/lightdm-webkit/themes/${1}" ]]; then
1047 msg_error "The specified theme (${1}) does not exist"
1051 webkit2_set_config "greeter" "webkit_theme" "${1}"
1054 command_webkit2_remove(){
1055 common_remove_command "${MODE_CONFIG["webkit2"]}"
1058 command_webkit2_debug(){
1059 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
1060 if ! check_bool "${_arg}"; then
1061 msg_error "Please specify true or false"
1064 webkit2_set_config "greeter" "debug_mode" "${_arg}"
1067 #== Qtquick用の汎用関数 ==#
1068 qtquick_init_configs(){
1070 if [[ ! -f "${MODE_CONFIG["qtquick"]}" ]] || [[ -z "$(cat "${MODE_CONFIG["qtquick"]}")" ]]; then
1071 mkdir -p "$(dirname "${MODE_CONFIG["qtquick"]}")"
1072 touch "${MODE_CONFIG["qtquick"]}"
1073 #echo -e "{\n\n}\n" > "${MODE_CONFIG["qtquick"]}"
1074 qtquick_set_config background_path "file:///hoge/fuga.png"
1075 qtquick_set_config theme "qrc:/Login.qml"
1079 #qtquick_get_value <key>
1080 qtquick_get_value(){
1081 jq ".${1}" < "${MODE_CONFIG["qtquick"]}"
1084 # command_qtquick_back <key> <value>
1085 qtquick_set_config(){
1086 local _tempfile="/tmp/$(basename "${MODE_CONFIG["qtquick"]}")-$(base64 < "/dev/urandom" | fold -w 10 | head -n 1)"
1087 cp "${MODE_CONFIG["qtquick"]}" "${_tempfile}"
1088 #cat "${_tempfile}" | jq -r ".${1}|=\"${2}\"" > "${MODE_CONFIG["qtquick"]}"
1089 jq -r ".${1}|=\"${2}\"" < "${_tempfile}" > "${MODE_CONFIG["qtquick"]}"
1090 chmod 644 "${MODE_CONFIG["qtquick"]}"
1093 qtquick_command_remove(){
1094 common_remove_command "${MODE_CONFIG["qtquick"]}"
1097 #== Qtquick用コマンド ==#
1098 command_qtquick_back(){
1099 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1100 msg_error "Please specify the image of background"
1103 if [[ ! -f "${1}" ]]; then
1104 msg_error "${1} was not found."
1108 local _backgrounf_file="${BACKGROUND_DIR}/lightdm/qtquick-greeter"
1109 mkdir -p "$(dirname "${_backgrounf_file}")"
1110 cp "${1}" "${_backgrounf_file}"
1111 chmod 644 "${_backgrounf_file}"
1113 qtquick_set_config "background_path" "file://${_backgrounf_file}"
1118 crudini --get "${MODE_CONFIG["slick"]}" "Greeter" "${1}"
1122 crudini --set "${MODE_CONFIG["slick"]}" "Greeter" "${1}" "${2}"
1125 slick_init_configs(){
1127 if [[ ! -f "${MODE_CONFIG["slick"]}" ]]; then
1128 mkdir -p "$(dirname "${MODE_CONFIG["slick"]}")"
1129 touch "${MODE_CONFIG["slick"]}"
1130 echo "[Greeter]" > "${MODE_CONFIG["slick"]}"
1135 command_slick_grid(){
1136 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
1137 if ! check_bool "${_arg}"; then
1138 msg_error "Please specify true or false"
1141 slick_set_config "draw-grid" "${_arg}"
1144 command_slick_back(){
1145 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1146 msg_error "Please specify the image of background"
1149 if [[ ! -f "${1}" ]]; then
1150 msg_error "${1} was not found."
1154 local _backgrounf_file="${BACKGROUND_DIR}/lightdm/slick-greeter"
1155 mkdir -p "$(dirname "${_backgrounf_file}")"
1156 cp "${1}" "${_backgrounf_file}"
1157 chmod 644 "${_backgrounf_file}"
1159 slick_set_config "background" "${_backgrounf_file}"
1162 command_slick_gtk_wizard(){
1163 local _theme="$(ask_gtk_theme)"
1166 if [[ -n "${_theme}" ]]; then
1167 command_slick_gtk_change "${_theme}"
1171 echo "Changed theme to ${_theme}"
1174 command_slick_gtk_change(){
1175 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1176 msg_error "Please specify the theme"
1179 if [[ ! -d "/usr/share/themes/${1}" ]]; then
1180 msg_error "${1} was not found."
1183 slick_set_config "theme-name" "${1}"
1186 command_slick_icon_wizard(){
1188 readarray -t icons < <(get_icon_theme)
1191 echo "Please select the icon theme to use."
1192 if ! _icon="$(ask_question "${icons[@]}")"; then
1193 command_slick_icon_wizard
1197 if [[ -n "${_icon}" ]]; then
1198 slick_set_config "icon-theme-name" "${_icon}"
1200 command_slick_icon_wizard
1203 echo "Changed icon theme to ${_icon}"
1206 command_slick_icon_chenge(){
1207 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1208 msg_error "Please specify the icon theme to use."
1211 if ! printf "%s\n" "$(get_icon_theme)" | grep -x "${1}" 1> /dev/null 2>&1; then
1212 msg_error "${1} was not found."
1215 slick_set_config "icon-theme-name" "${1}"
1218 command_slick_remove(){
1219 common_remove_command "${MODE_CONFIG["slick"]}"
1224 # sddm_get_value <section> <key> <valye>
1226 crudini --set "${MODE_CONFIG["sddm"]}" "${1}" "${2}"
1229 # sddm_set_config <section> <key> <value>
1231 crudini --set "${MODE_CONFIG["sddm"]}" "${1}" "${2}" "${3}"
1234 # sddm_remove_key <section> <key>
1236 crudini --del "${MODE_CONFIG["sddm"]}" "${1}" "${2}"
1240 sddm_init_configs(){
1242 if [[ ! -f "${MODE_CONFIG["sddm"]}" ]]; then
1243 mkdir -p "$(dirname "${MODE_CONFIG["sddm"]}")"
1244 sddm --example-config > "${MODE_CONFIG["sddm"]}"
1249 command_sddm_auto_login(){
1250 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1251 # 既に自動ログインが設定されているかを確認
1252 local autologin_user="$(sddm_get_value Autologin User)"
1253 if [[ -n "${autologin_user}" ]]; then
1254 sddm_remove_key "Autologin" "User"
1255 echo "Canceled automatic login of ${autologin_user}"
1258 local autologin_user="${1}" autologin_session
1260 autologin_session="${2}"
1263 # セッションを設定 (WayLandのセッションは現在サポートされていません)
1264 if [[ -z "${autologin_session+SET}" ]]; then
1265 autologin_session="$(ask_session)"
1268 check_session "${autologin_session}"
1272 add_user_to_group "${autologin_user}" "autologin"
1275 sddm_set_config "Autologin" "User" "${autologin_user}"
1276 sddm_set_config "Autologin" "Session" "${autologin_session}"
1278 echo "${autologin_user} will automatically log in with ${autologin_session}"
1282 command_sddm_cursor_wizard(){
1284 local cursor_themes _current_theme="$(sddm_get_value "Theme" "CursorTheme")"
1285 readarray -t cursor_themes < <(get_cursor_theme)
1288 if ! _cursor_theme="$(ask_question -d "${_current_theme}" -p "Please select the cursor theme to use." "${cursor_themes[@]}")"; then
1289 command_sddm_cursor_wizard
1293 if [[ -n "${_cursor_theme}" ]]; then
1294 command_sddm_cursor_change "${_cursor_theme}"
1296 command_sddm_cursor_change
1300 if [[ ! "${_current_theme}" = "${_cursor_theme}" ]]; then
1301 echo "Changed cursor to ${_cursor_theme}"
1305 command_sddm_cursor_change(){
1306 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1307 msg_error "Please specify the cursor theme"
1311 readarray -t cursor_themes < <(get_cursor_theme)
1312 if ! printf "%s\n" "${cursor_themes[@]}" | grep -x "${1}" 1>/dev/null 2>&1; then
1313 msg_error "The cursor theme (${1}) was not found"
1316 sddm_set_config "Theme" "CursorTheme" "${1}"
1319 command_sddm_numlock(){
1320 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
1321 if ! check_bool "${_arg}"; then
1322 msg_error "Please specify true or false"
1326 if [[ "${_arg}" = true ]]; then
1331 sddm_set_config "General" "Numlock" "${_value}"
1335 if ! check_int "${1}" || (( "${1}" < 1 )); then
1336 msg_error "Please enter an integer greater than 1"
1339 sddm_set_config "X11" "MinimumVT" "${1}"
1342 command_sddm_theme_wizard(){
1344 readarray -t _theme_list < <(find "/usr/share/sddm/themes/" -maxdepth 1 -mindepth 1 -type d -print0 | xargs -0 -I{} basename {})
1346 local _theme _current_theme=$(sddm_get_value "Theme" "Current")
1347 if ! _theme="$(ask_question -d "${_current_theme}" -p "Please select the theme to use." "${_theme_list[@]}")"; then
1348 command_sddm_theme_wizard
1351 if [[ -n "${_theme}" ]]; then
1352 command_sddm_theme_change "${_theme}"
1353 echo "Changed the theme to ${_theme}"
1355 command_sddm_theme_wizard
1361 command_sddm_theme_change(){
1362 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1363 msg_error "Please specify the theme name"
1366 if [[ ! -d "/usr/share/sddm/themes/${1}" ]]; then
1367 msg_error "The specified theme (${1}) does not exist"
1371 sddm_set_config "Theme" "Current" "${1}"
1375 # sddm_get_value <section> <key> <valye>
1377 crudini --set "${MODE_CONFIG["lxdm"]}" "${1}" "${2}"
1380 # sddm_set_config <section> <key> <value>
1382 crudini --set "${MODE_CONFIG["lxdm"]}" "${1}" "${2}" "${3}"
1385 # sddm_remove_key <section> <key>
1387 crudini --del "${MODE_CONFIG["lxdm"]}" "${1}" "${2}"
1391 lxdm_init_configs(){
1393 if [[ ! -f "${MODE_CONFIG["lxdm"]}" ]]; then
1394 mkdir -p "$(dirname "${MODE_CONFIG["lxdm"]}")"
1395 touch "${MODE_CONFIG["lxdm"]}"
1400 command_lxdm_auto_login(){
1401 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1402 # 既に自動ログインが設定されているかを確認
1403 local autologin_user="$(lxdm_get_value "base" "autologin")"
1404 if [[ -n "${autologin_user}" ]]; then
1405 sddm_remove_key "base" "autologin"
1406 echo "Canceled automatic login of ${autologin_user}"
1409 local autologin_user="${1}" autologin_session
1411 autologin_session="${2}"
1414 # セッションを設定 (WayLandのセッションは現在サポートされていません)
1415 if [[ -z "${autologin_session+SET}" ]]; then
1416 autologin_session="$(ask_session)"
1419 check_session "${autologin_session}"
1423 add_user_to_group "${autologin_user}" "autologin"
1426 sddm_set_config "base" "autologin" "${autologin_user}"
1429 command_lxdm_session_change "${autologin_session}"
1431 echo "${autologin_user} will automatically log in with ${autologin_session}"
1435 command_lxdm_session_wizard(){
1436 command_lxdm_session_change "$(ask_session)"
1439 command_lxdm_session_change(){
1440 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1441 msg_error "Please specify the session name"
1444 local session="${1}"
1445 check_session "${session}"
1446 local session_exec="$(get_session "${session}")"
1447 lxdm_set_config "base" "session" "${session_exec}"
1450 command_lxdm_remove_last(){
1451 rm -rf "/var/lib/lxdm/lxdm.conf"
1452 echo "Removed last configs"
1455 comamnd_lxdm_edit_script(){
1457 "LoginReady : executed with root privileges when LXDM is ready to show the login window"
1458 "PreLogin : run as root before logging a user in"
1459 "PostLogin : run as the logged-in user right after they have logged in"
1460 "PostLogout : run as the logged-in user right after they have logged out"
1461 "PreReboot : run as root before rebooting with LXDM"
1462 "PreShutdown: run as root before poweroff with LXDM"
1464 if ! file=$(ask_question -p "Select the script you want to edit" "${_filelist[@]}" | cut -d ":" -f 1 | tr -d " "); then
1465 comamnd_lxdm_edit_script
1468 bash -c "${USE_EDITOR} ${file}"
1471 command_lxdm_back(){
1472 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1473 msg_error "Please specify the image of background"
1476 if [[ ! -f "${1}" ]]; then
1477 msg_error "${1} was not found."
1481 local _backgrounf_file="${BACKGROUND_DIR}/lxdm/background"
1482 mkdir -p "$(dirname "${_backgrounf_file}")"
1483 cp "${1}" "${_backgrounf_file}"
1484 chmod 644 "${_backgrounf_file}"
1486 lxdm_set_config "display" "bg" "file://${_backgrounf_file}"
1489 command_lxdm_gtk_wizard(){
1490 local _theme="$(ask_gtk_theme)"
1493 if [[ -n "${_theme}" ]]; then
1494 command_lxdm_gtk_change "${_theme}"
1498 echo "Changed theme to ${_theme}"
1501 command_lxdm_gtk_change(){
1502 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1503 msg_error "Please specify the theme"
1506 if [[ ! -d "/usr/share/themes/${1}" ]]; then
1507 msg_error "${1} was not found."
1510 lxdm_set_config "display" "gtk_theme" "${1}"
1513 #== GTk Greeter用の汎用関数 ==#
1514 # gtk_greeter_get_value <section> <key>
1515 gtk_greeter_get_value(){
1516 crudini --set "${MODE_CONFIG["gtkg"]}" "${1}" "${2}"
1519 # gtk_greeter_set_config <section> <key> <value>
1520 gtk_greeter_set_config(){
1521 crudini --set "${MODE_CONFIG["gtkg"]}" "${1}" "${2}" "${3}"
1524 # gtk_greeter_remove_key <section> <key>
1525 gtk_greeter_remove_key(){
1526 crudini --del "${MODE_CONFIG["gtkg"]}" "${1}" "${2}"
1529 gtk_greeter_init_configs(){
1531 if [[ ! -f "${MODE_CONFIG["gtkg"]}" ]]; then
1532 mkdir -p "$(dirname "${MODE_CONFIG["gtkg"]}")"
1533 touch "${MODE_CONFIG["gtkg"]}"
1537 #== GTk Greeter用のコマンド==#
1538 command_gtk_greeter_gtk_wizard(){
1539 local _theme="$(ask_gtk_theme)"
1542 if [[ -n "${_theme}" ]]; then
1543 gtk_greeter_set_config "greeter" "theme-name" "${_theme}"
1547 echo "Changed theme to ${_theme}"
1550 command_gtk_greeter_gtk_change(){
1551 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1552 msg_error "Please specify the theme"
1555 if ! printf "%s\n" "$(get_gtk_theme)" | grep -x "${1}" 1> /dev/null 2>&1; then
1556 msg_error "${1} was not found."
1559 gtk_greeter_set_config "greeter" "theme-name" "${1}"
1562 command_gtk_greeter_icon_wizard(){
1564 readarray -t icons < <(get_icon_theme)
1567 echo "Please select the icon theme to use."
1568 if ! _icon="$(ask_question "${icons[@]}")"; then
1569 command_gtk_greeter_icon_wizard
1573 if [[ -n "${_icon}" ]]; then
1574 gtk_greeter_set_config "greeter" "icon-theme-name" "${_icon}"
1576 command_gtk_greeter_icon_wizard
1579 echo "Changed icon theme to ${_icon}"
1582 command_gtk_greeter_icon_chenge(){
1583 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1584 msg_error "Please specify the icon theme to use."
1587 if ! printf "%s\n" "$(get_icon_theme)" | grep -x "${1}" 1> /dev/null 2>&1; then
1588 msg_error "${1} was not found."
1591 gtk_greeter_set_config "greeter" "icon-theme-name" "${_icon}"
1596 declare -A MODE_CONFIG=(
1597 ["lightdm"]="/etc/lightdm/lightdm.conf.d/00-dmc-lightdm.conf"
1598 ["gdm-dconf"]="/etc/dconf/db/gdm.d/00-dmc-gdm"
1599 ["gdm-custom"]="/etc/gdm/custom.conf"
1600 ["sddm"]="/etc/sddm.conf.d/sddm.conf"
1601 ["lxdm"]="/etc/lxdm/lxdm.conf"
1602 ["webkit2"]="/etc/lightdm/lightdm-webkit2-greeter.conf"
1603 ["slick"]="/etc/lightdm/slick-greeter.conf"
1604 ["gtkg"]="/etc/lightdm/lightdm-gtk-greeter.conf"
1605 ["elementary"]="/etc/lightdm/io.elementary.greeter.conf"
1606 ["mini"]="/etc/lightdm/lightdm-mini-greeter.conf"
1607 ["qtquick"]="/etc/lightdm/lightdm-qtquick-greeter.json"
1610 declare -A MAIN_BINARY=(
1611 ["lightdm"]="/usr/bin/lightdm"
1612 ["gdm"]="/usr/bin/gdm"
1613 ["sddm"]="/usr/bin/sddm"
1614 ["webkit2"]="/usr/bin/lightdm-webkit2-greeter"
1615 ["slick"]="/usr/bin/slick-greeter"
1616 ["gtkg"]="/usr/bin/lightdm-gtk-greeter"
1617 ["elementary"]="/usr/bin/io.elementary.greeter"
1618 ["mini"]="/usr/bin/lightdm-mini-greeter"
1619 ["qtquick"]="/usr/bin/lightdm-qtquick-greeter"
1620 ["lxdm"]="/usr/bin/lxdm"
1623 declare -A GREETER_MODE=(
1624 ["lightdm-webkit2-greeter"]="webkit2"
1625 ["lightdm-slick-greeter"]="slick"
1626 ["io.elementary.greeter"]="elementary"
1627 ["lightdm-mini-greeter"]="mini"
1628 ["lightdm-qtquick-greeter"]="qtquick"
1629 ["lightdm-gtk-greeter"]="gtkg"
1634 # LightDM - Greeterのディレクトリ
1635 LIGHTDM_GREETERS_DIR="$(lightdm_get_value "greeters-directory")"
1636 : "${LIGHTDM_GREETERS_DIR:="/usr/share/xgreeters"}"
1638 # LightDM - 現在設定されているGreeter
1639 LIGHTDM_CURRENT_GREETER="$(lightdm --show-config 2>&1 | grep "greeter-session" | cut -d "=" -f 2)"
1640 : "${LIGHTDM_CURRENT_GREETER:="lightdm-gtk-greeter"}"
1643 USE_EDITOR="${EDITOR:-vi}"
1645 # Global - 背景画像をコピーするディレクトリ
1646 BACKGROUND_DIR="/usr/share/backgrounds"
1648 # Global - 現在のディスプレイマネージャ名
1649 if [[ -f "/etc/systemd/system/display-manager.service" ]]; then
1650 CURRENT_DM="$(basename "$(readlink "/etc/systemd/system/display-manager.service")" | sed "s|.service$||g")"
1656 MODE="${CURRENT_DM}"
1657 : "${MODE:="lightdm"}"
1660 NON_INTERACTIVE=false
1661 WRITE_ALL_FILES=false
1663 NO_CHECK_TARGET=false
1668 OPTS=("m:" "e:" "h" "G")
1669 OPTL=("mode:" "editor:" "help" "non-interactive" "noroot" "write-all-files" "no-check-target" "lightdm-greeter" "remove")
1670 if ! OPT=$(getopt -o "$(printf "%s," "${OPTS[@]}")" -l "$(printf "%s," "${OPTL[@]}")" -- "${ARGUMENT[@]}"); then
1674 eval set -- "${OPT}"
1691 -G | --lightdm-greeter)
1692 if [[ -n "${LIGHTDM_CURRENT_GREETER+SET}" ]]; then
1693 MODE="${GREETER_MODE["${LIGHTDM_CURRENT_GREETER}"]}"
1695 msg_error "Failed to get the currently running Greeter."
1701 NON_INTERACTIVE=true
1709 NO_CHECK_TARGET=true
1713 WRITE_ALL_FILES=true
1728 COMMAND="${1:-null}"
1729 if (( "${#}" >= 1 )); then
1732 COMMAND_ARGS=("${@}")
1733 : "${COMMAND_ARGS=""}" # サブコマンドの引数が何も指定されなかった場合に空文字を代入
1735 if [[ "${COMMAND}" = "null" ]]; then
1741 if [[ "${NO_CHECK_TARGET}" = false ]]; then
1745 # コマンドとモードに応じて関数を実行する
1746 case "${COMMAND}" in
1748 check_command_dm "gdm"
1750 command_gdm_accessibility "${COMMAND_ARGS[@]}"
1753 check_command_dm "lightdm" "gdm" "sddm" "lxdm"
1756 lightdm_init_configs
1757 command_lightdm_auto_login "${COMMAND_ARGS[@]}"
1761 command_gdm_auto_login "${COMMAND_ARGS[@]}"
1765 command_sddm_auto_login "${COMMAND_ARGS[@]}"
1769 command_lxdm_auto_login "${COMMAND_ARGS[@]}"
1774 check_command_dm "qtquick" "slick" "lxdm"
1777 qtquick_init_configs
1778 command_qtquick_back "${COMMAND_ARGS[@]}"
1782 command_slick_back "${COMMAND_ARGS[@]}"
1786 command_lxdm_back "${COMMAND_ARGS[@]}"
1791 check_command_dm "gdm" "sddm"
1795 command_gdm_cursor_wizard
1799 command_sddm_cursor_wizard
1804 check_command_dm "gdm" "sddm"
1808 command_gdm_cursor_change "${COMMAND_ARGS[@]}"
1812 command_sddm_cursor_change "${COMMAND_ARGS[@]}"
1817 check_comamnd_dm "webkit2"
1818 command_webkit2_debug "${COMMAND_ARGS[@]}"
1821 command_general_dm "${COMMAND_ARGS[@]}"
1824 check_command_dm "lightdm" "gdm"
1828 command_lightdm_edit
1837 check_command_dm "lxdm"
1839 comamnd_lxdm_edit_script
1842 check_command_dm "slick" "lxdm" "gtkg"
1846 command_slick_gtk_wizard
1850 command_lxdm_gtk_wizard
1853 gtk_greeter_init_configs
1854 command_gtk_greeter_gtk_wizard
1859 check_command_dm "lightdm"
1860 lightdm_init_configs
1861 command_lightdm_greeter_wizard
1864 check_command_dm "lightdm"
1865 lightdm_init_configs
1866 command_lightdm_greeter_change "${COMMAND_ARGS[@]}"
1869 check_command_dm "lightdm"
1870 lightdm_init_configs
1871 command_lightdm_greeter_create "${COMMAND_ARGS[@]}"
1874 check_command_dm "lightdm"
1876 command_lightdm_greeter_edit "${COMMAND_ARGS[@]}"
1879 check_command_dm "lightdm"
1880 command_lightdm_greeter_list
1884 check_command_dm "slick"
1886 command_slick_grid "${COMMAND_ARGS[@]}"
1889 check_command_dm "slick" "lxdm" "gtkg"
1893 command_slick_gtk_change "${COMMAND_ARGS[@]}"
1896 command_lxdm_gtk_change "${COMMAND_ARGS[@]}"
1899 command_gtk_greeter_gtk_change "${COMMAND_ARGS[@]}"
1904 check_command_dm "slick" "gtkg"
1908 command_slick_icon_wizard
1911 gtk_greeter_init_configs
1912 command_gtk_greeter_icon_wizard
1917 check_command_dm "slick" "gtkg"
1921 command_slick_icon_chenge "${COMMAND_ARGS[@]}"
1924 gtk_greeter_init_configs
1925 command_gtk_greeter_icon_chenge "${COMMAND_ARGS[@]}"
1930 check_command_dm "gdm" "slick"
1934 command_gdm_logo "${COMMAND_ARGS[@]}"
1938 command_slick_logo "${COMMAND_ARGS[@]}"
1943 check_command_dm "sddm"
1945 command_sddm_numlock "${COMMAND_ARGS[@]}"
1948 check_command_dm "slick"
1950 command_slick_other_monitor "${COMMAND_ARGS[@]}"
1953 check_command_dm "lightdm" "gdm" "webkit2" "qtquick"
1955 eval "command_${MODE}_remove"
1958 check_command_dm "lxdm"
1960 command_lxdm_remove_last
1963 check_command_dm "gdm"
1965 command_gdm_root_login "${COMMAND_ARGS[@]}"
1968 check_command_dm "lxdm"
1970 command_lxdm_session_wizard
1973 check_command_dm "lxdm"
1975 command_lxdm_session_change "${COMMAND_ARGS[@]}"
1978 check_command_dm "lightdm"
1979 command_lightdm_show_config
1983 check_command_dm "gdm"
1985 command_gdm_sound "${COMMAND_ARGS[@]}"
1988 check_command_dm "gdm"
1990 command_gdm_tap "${COMMAND_ARGS[@]}"
1993 check_command_dm "webkit2" "sddm"
1996 webkit2_init_configs
1997 command_webkit2_theme_wizard
2001 command_sddm_theme_wizard
2006 check_command_dm "webkit2" "sddm"
2009 webkit2_init_configs
2010 command_webkit2_theme_change "${COMMAND_ARGS[@]}"
2014 command_sddm_theme_change
2019 check_command_dm "sddm"
2021 command_sddm_tty "${COMMAND_ARGS[@]}"
2027 "lightdm" | "gdm" | "sddm" | "lxdm" | "webkit2" | "qtquick" | "slick" | "gtkg")
2028 command_mode "${COMMAND}" "${COMMAND_ARGS[@]}"
2035 msg_error "This command cannot be used in any mode"