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=("${@}")
533 if [[ "${NON_INTERACTIVE}" = true ]]; then
534 _dmc_args+=("--non-interactive")
536 if [[ "${NOROOT}" = true ]]; then
537 _dmc_args+=("--noroot")
539 if [[ "${NO_CHECK_TARGET}" = true ]]; then
540 _dmc_args+=("--no-check-target")
542 if [[ "${WRITE_ALL_FILES}" = true ]]; then
543 _dmc_args+=("--write-all-files")
546 bash "${SCRIPT_PATH}/$(basename "${0}")" "${_dmc_args[@]}" "${_command}" "${_command_args[@]}"
551 #== LightDM用の汎用関数 ==#
553 lightdm_get_source_file(){
555 local source_name="$(lightdm --show-config 2>&1 | grep -E "^[A-Z] ${key}=" | cut -d ' ' -f 1)"
556 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")"
557 if [[ -n "${source_path}" ]]; then
558 echo -n "${source_path}"
566 lightdm_set_config(){
567 local key="${1}" value="${2}" file=${3-${MODE_CONFIG["lightdm"]}}
568 if [[ "${WRITE_ALL_FILES}" = true ]] && [[ -n "$(lightdm_get_source_file "${1}")" ]]; then
569 crudini --set "$(lightdm_get_source_file "${1}")" 'Seat:*' "${key}" "${value}"
571 crudini --set "${file}" 'Seat:*' "${key}" "${value}"
574 if [[ ! "$(lightdm_get_value "${key}")" = "${value}" ]]; then
575 msg_error "Failed to change the setting value. A value has already been set for $(lightdm_get_source_file "${1}")"
576 msg_error "lightdm-config does not manipulate other configuration files for safety. Comment out the settings in that file."
581 lightdm_remove_key(){
582 local key="${1}" _config
583 if grep -E "^ ?${key}.+" "${MODE_CONFIG["lightdm"]}" 1>/dev/null 2>&1; then
584 sed -i -r "s|^ ?${key} ?=.+||g" "${MODE_CONFIG["lightdm"]}"
585 sed -i '/^$/d' "${MODE_CONFIG["lightdm"]}"
590 lightdm_init_configs(){
592 if [[ ! -f "${MODE_CONFIG["lightdm"]}" ]]; then
593 mkdir -p "$(dirname "${MODE_CONFIG["lightdm"]}")"
594 touch "${MODE_CONFIG["lightdm"]}"
595 echo "[Seat:*]" > "${MODE_CONFIG["lightdm"]}"
601 local _current_value="$(lightdm --show-config 2>&1 | grep -E "^[A-Z] ${1}=" | sed "s|^[A-Z] ||g" | cut -d "=" -f "2")"
602 if [[ "${_current_value}" ]]; then
603 echo -n "${_current_value}"
611 lightdm_greeter_list(){
613 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 )
614 printf "%s\n" "${greeter_list[@]}" | sort | uniq
619 command_lightdm_greeter_change() {
621 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
622 msg_error "Please specify Greeter."
626 # 指定されたGreeterが正しいか確認
627 if ! lightdm_greeter_list | grep -x "${1}" > /dev/null 2>&2; then
628 msg_error "The greeter (${1}) doesn't exist."
631 lightdm_set_config "greeter-session" "${1}"
636 command_lightdm_greeter_create(){
637 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
638 msg_error "Please specify Greeter."
641 if [[ ! -f "${1}" ]]; then
642 msg_error "${1} does not exist."
645 if [[ ! -x "${1}" ]]; then
646 msg_error "hoge is not an executable file."
651 local filename="$(basename "${1}")"
653 if [[ -f "/usr/share/xgreeters/${filename}.desktop" ]]; then
654 msg_error "Greeter with the same name already exists."
657 cat > "/usr/share/xgreeters/${filename}.desktop" <<EOF
659 Name=LightDM custom Greeter ${filename}
660 Comment=LightDM Greeter
667 command_lightdm_greeter_list() {
668 echo "Available Lightdm greeter list:"
670 for _greeter in $(lightdm_greeter_list); do
671 if [[ "${_greeter}" = "${LIGHTDM_CURRENT_GREETER}" ]]; then
672 echo " * ${_greeter}"
680 command_lightdm_greeter_wizard(){
682 if (( $(lightdm_greeter_list | wc -l) < 1 )); then
683 msg_error "LightDM Greeter was not found."
689 # shellcheck disable=SC2046
690 if ! _greeter="$(ask_question -p "Please select the greeter to use." -d "${LIGHTDM_CURRENT_GREETER}" $(lightdm_greeter_list))"; then
691 command_lightdm_greeter_wizard
696 if [[ -n "${_greeter}" ]]; then
697 command_lightdm_greeter_change "${_greeter}"
699 command_lightdm_greeter_wizard
703 if [[ ! "${LIGHTDM_CURRENT_GREETER}" = "${_greeter}" ]]; then
704 echo "Changed greeter to ${_greeter}"
709 command_lightdm_remove(){
710 common_remove_command "${MODE_CONFIG["lightdm"]}"
714 command_lightdm_greeter_edit(){
715 if [[ "${NON_INTERACTIVE}" = true ]]; then
716 msg_error "You cannot use this command in non-interactive mode."
719 local _greeter="${1:-${LIGHTDM_CURRENT_GREETER}}"
720 if [[ -z "${MODE_CONFIG[${GREETER_MODE["${_greeter}"]}]+SET}" ]]; then
721 msg_error "This Greeter is not currently supported."
722 msg_error "Please report the problem here."
723 msg_error "https://github.com/FascodeNet/lightdm-config/issues"
726 if [[ -z "${1}" ]] || [[ "${1}" = "" ]]; then
727 msg_warn "Greeter was not specified. Open the currently configured Greeter configuration file."
728 echo -n "(Enter to continue) > "
732 bash -c "${USE_EDITOR} ${MODE_CONFIG[${GREETER_MODE["${_greeter}"]}]}"
738 command_lightdm_edit(){
739 if [[ "${NON_INTERACTIVE}" = true ]]; then
740 msg_error "You cannot use this command in non-interactive mode."
743 local loaded_config_list
744 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 " ")
745 for _config in "${loaded_config_list[@]}"; do
746 echo -ne "Edit ${_config} ? (y or n)> "
747 read -r -n 1 _yes_or_no
749 if [[ "${_yes_or_no}" = "y" ]]; then
750 bash -c "${USE_EDITOR} ${_config}"
756 command_lightdm_auto_login(){
757 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
758 # 既に自動ログインが設定されているかを確認
759 local autologin_user="$(lightdm_get_value autologin-user)"
760 if [[ -n "${autologin_user}" ]]; then
762 for _autologin in "autologin-guest" "autologin-user" "autologin-user-timeout" "autologin-in-background" "autologin-session"; do
763 lightdm_remove_key "${_autologin}"
765 echo "Canceled automatic login of ${autologin_user}"
768 local autologin_user="${1}" autologin_session
770 autologin_session="${2}"
773 # セッションを設定 (WayLandのセッションは現在サポートされていません)
774 if [[ -z "${autologin_session+SET}" ]]; then
775 autologin_session="$(ask_session)"
778 check_session "${autologin_session}"
782 add_user_to_group "${autologin_user}" "autologin"
785 lightdm_set_config "autologin-guest" "false"
786 lightdm_set_config "autologin-user" "${autologin_user}"
787 lightdm_set_config "autologin-user-timeout" "0"
788 lightdm_set_config "autologin-in-background" "false"
789 lightdm_set_config "autologin-session" "${autologin_session}"
791 echo "${autologin_user} will automatically log in with ${autologin_session}"
797 command_lightdm_show_config(){
798 lightdm --show-config 2>&1
804 if [[ ! -f "/etc/dconf/profile/gdm" ]]; then
805 mkdir -p "/etc/dconf/profile"
806 touch "/etc/dconf/profile/gdm"
807 echo -e "user-db:user\nsystem-db:gdm\nfile-db:/usr/share/gdm/greeter-dconf-defaults" > "/etc/dconf/profile/gdm"
811 for _file in "${MODE_CONFIG["gdm-dconf"]}" "${MODE_CONFIG["gdm-custom"]}"; do
812 if [[ ! -f "${_file}" ]]; then
813 mkdir -p "$(dirname "${_file}")"
819 # gdm_dconf_set_config <dconf path> <key> <value>
820 gdm_dconf_set_config(){
821 if check_int "${3}" || check_bool "${3}"; then
822 crudini --set "${MODE_CONFIG["gdm-dconf"]}" "${1}" "${2}" "${3}"
824 crudini --set "${MODE_CONFIG["gdm-dconf"]}" "${1}" "${2}" "\"${3}\""
829 # gdm_dconf_get_value <dconf path> <key>
830 gdm_dconf_get_value(){
831 find "/etc/dconf/db/gdm.d/" -type f -print0 | xargs -0 -I{} cat {} | crudini --get - "${1}" "${2}" | sed "s|^[\"\']||g" | sed "s|[\"\']$||g"
834 # gdm_custom_get_value <section> <key>
835 gdm_custom_get_value(){
836 crudini --get "${MODE_CONFIG["gdm-custom"]}" "${1}" "${2}"
839 # gdm_custom_set_config <section> <key> <value>
840 gdm_custom_set_config(){
841 if check_int "${3}" || check_bool "${3}"; then
842 crudini --set "${MODE_CONFIG["gdm-custom"]}" "${1}" "${2}" "${3}"
844 crudini --set "${MODE_CONFIG["gdm-custom"]}" "${1}" "${2}" "\"${3}\""
856 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
857 msg_error "Please specify the image of background"
860 if [[ ! -f "${1}" ]]; then
861 msg_error "${1} was not found."
865 local _backgrounf_file="${BACKGROUND_DIR}/gdm/background"
866 mkdir -p "$(dirname "${_backgrounf_file}")"
867 cp "${1}" "${_backgrounf_file}"
868 chmod 644 "${_backgrounf_file}"
870 gdm_dconf_set_config "org/gnome/login-screen" "logo" "${_backgrounf_file}"
873 command_gdm_cursor_wizard(){
875 local cursor_themes _current_theme="$(gdm_dconf_get_value "org/gnome/desktop/interface" "cursor-theme")"
876 readarray -t cursor_themes < <(get_cursor_theme)
879 if ! _cursor_theme="$(ask_question -d "${_current_theme}" -p "Please select the cursor theme to use." "${cursor_themes[@]}")"; then
880 command_gdm_cursor_wizard
884 if [[ -n "${_cursor_theme}" ]]; then
885 command_gdm_cursor_change "${_cursor_theme}"
887 command_gdm_cursor_wizard
891 if [[ ! "${_current_theme}" = "${_cursor_theme}" ]]; then
892 echo "Changed cursor to ${_cursor_theme}"
896 command_gdm_cursor_change(){
897 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
898 msg_error "Please specify the cursor theme"
902 readarray -t cursor_themes < <(get_cursor_theme)
903 if ! printf "%s\n" "${cursor_themes[@]}" | grep -x "${1}" 1>/dev/null 2>&1; then
904 msg_error "The cursor theme (${1}) was not found"
907 gdm_dconf_set_config "org/gnome/desktop/interface" "cursor-theme" "${1}"
911 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
912 if ! check_bool "${_arg}"; then
913 msg_error "Please specify true or false"
916 gdm_dconf_set_config "org/gnome/desktop/sound" "event-sounds" "${_arg}"
920 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
921 if ! check_bool "${_arg}"; then
922 msg_error "Please specify true or false"
925 gdm_dconf_set_config "org/gnome/desktop/peripherals/touchpad" "tap-to-click" "${_arg}"
929 if [[ "${NON_INTERACTIVE}" = true ]]; then
930 msg_error "You cannot use this command in non-interactive mode."
933 bash -c "${USE_EDITOR} ${MODE_CONFIG["gdm-custom"]}"
936 command_gdm_remove(){
937 common_remove_command "${MODE_CONFIG["gdm-custom"]}"
941 command_gdm_auto_login(){
942 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
943 # 既に自動ログインが設定されているかを確認
944 local autologin="$(gdm_custom_get_value daemon AutomaticLoginEnable)"
945 if [[ "${autologin}" = "True" ]]; then
946 gdm_custom_set_config "daemon" "AutomaticLoginEnable" "False"
947 echo "Canceled automatic login of $(gdm_custom_get_value "daemon" "AutomaticLogin")"
950 local autologin_user="${1}" autologin_session
952 autologin_session="${2}"
955 # セッションを設定 (WayLandのセッションは現在サポートされていません)
956 if [[ -z "${autologin_session+SET}" ]]; then
957 autologin_session="$(ask_session)"
960 check_session "${autologin_session}"
964 add_user_to_group "${autologin_user}" "autologin"
967 gdm_custom_set_config "daemon" "AutomaticLoginEnable" "True"
968 gdm_custom_set_config "daemon" "AutomaticLogin" "${autologin_user}"
971 crudini --set "/var/lib/AccountsService/users/${autologin_user}" "User" "Session" "${autologin_session}"
972 crudini --set "/var/lib/AccountsService/users/${autologin_user}" "User" "XSession" "${autologin_session}"
974 echo "${autologin_user} will automatically log in with ${autologin_session}"
980 command_gdm_accessibility(){
981 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
982 if ! check_bool "${_arg}"; then
983 msg_error "Please specify true or false"
986 gdm_dconf_set_config "org/gnome/desktop/interface" "toolkit-accessibility" "${_arg}"
990 command_gdm_root_login(){
991 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
992 if ! check_bool "${_arg}"; then
993 msg_error "Please specify true or false"
996 gdm_custom_set_config "daemon" "AllowRoot" "${_arg}"
999 #== Webkit2用の汎用関数 ==#
1000 webkit2_init_configs(){
1002 if [[ ! -f "${MODE_CONFIG["webkit2"]}" ]]; then
1003 mkdir -p "$(dirname "${MODE_CONFIG["webkit2"]}")"
1004 touch "${MODE_CONFIG["webkit2"]}"
1008 # webkit2_get_value <section> <key>
1009 webkit2_get_value(){
1010 crudini --get "${MODE_CONFIG["webkit2"]}" "${1}" "${2}"
1013 # webkit2_set_config <section> <key> <value>
1014 webkit2_set_config(){
1015 crudini --set "${MODE_CONFIG["webkit2"]}" "${1}" "${2}" "${3}"
1018 #== webkit2用コマンド ==#
1019 command_webkit2_theme_wizard(){
1021 readarray -t _theme_list < <(ls /usr/share/lightdm-webkit/themes)
1023 local _current_theme=$(webkit2_get_value greeter webkit_theme | sed "s|\"||g")
1025 if ! _theme="$(ask_question -d "${_current_theme}" -p "Please select the theme to use." "${_theme_list[@]}")"; then
1026 command_webkit2_theme_wizard
1029 if [[ -n "${_theme}" ]]; then
1030 command_webkit2_theme_change "${_theme}"
1031 echo "Changed the theme to ${_theme}"
1033 command_webkit2_theme_wizard
1039 command_webkit2_theme_change(){
1040 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1041 msg_error "Please specify the theme name"
1044 if [[ ! -d "/usr/share/lightdm-webkit/themes/${1}" ]]; then
1045 msg_error "The specified theme (${1}) does not exist"
1049 webkit2_set_config "greeter" "webkit_theme" "${1}"
1052 command_webkit2_remove(){
1053 common_remove_command "${MODE_CONFIG["webkit2"]}"
1056 command_webkit2_debug(){
1057 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
1058 if ! check_bool "${_arg}"; then
1059 msg_error "Please specify true or false"
1062 webkit2_set_config "greeter" "debug_mode" "${_arg}"
1065 #== Qtquick用の汎用関数 ==#
1066 qtquick_init_configs(){
1068 if [[ ! -f "${MODE_CONFIG["qtquick"]}" ]] || [[ -z "$(cat "${MODE_CONFIG["qtquick"]}")" ]]; then
1069 mkdir -p "$(dirname "${MODE_CONFIG["qtquick"]}")"
1070 touch "${MODE_CONFIG["qtquick"]}"
1071 #echo -e "{\n\n}\n" > "${MODE_CONFIG["qtquick"]}"
1072 qtquick_set_config background_path "file:///hoge/fuga.png"
1073 qtquick_set_config theme "qrc:/Login.qml"
1077 #qtquick_get_value <key>
1078 qtquick_get_value(){
1079 jq ".${1}" < "${MODE_CONFIG["qtquick"]}"
1082 # command_qtquick_back <key> <value>
1083 qtquick_set_config(){
1084 local _tempfile="/tmp/$(basename "${MODE_CONFIG["qtquick"]}")-$(base64 < "/dev/urandom" | fold -w 10 | head -n 1)"
1085 cp "${MODE_CONFIG["qtquick"]}" "${_tempfile}"
1086 #cat "${_tempfile}" | jq -r ".${1}|=\"${2}\"" > "${MODE_CONFIG["qtquick"]}"
1087 jq -r ".${1}|=\"${2}\"" < "${_tempfile}" > "${MODE_CONFIG["qtquick"]}"
1088 chmod 644 "${MODE_CONFIG["qtquick"]}"
1091 qtquick_command_remove(){
1092 common_remove_command "${MODE_CONFIG["qtquick"]}"
1095 #== Qtquick用コマンド ==#
1096 command_qtquick_back(){
1097 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1098 msg_error "Please specify the image of background"
1101 if [[ ! -f "${1}" ]]; then
1102 msg_error "${1} was not found."
1106 local _backgrounf_file="${BACKGROUND_DIR}/lightdm/qtquick-greeter"
1107 mkdir -p "$(dirname "${_backgrounf_file}")"
1108 cp "${1}" "${_backgrounf_file}"
1109 chmod 644 "${_backgrounf_file}"
1111 qtquick_set_config "background_path" "file://${_backgrounf_file}"
1116 crudini --get "${MODE_CONFIG["slick"]}" "Greeter" "${1}"
1120 crudini --set "${MODE_CONFIG["slick"]}" "Greeter" "${1}" "${2}"
1123 slick_init_configs(){
1125 if [[ ! -f "${MODE_CONFIG["slick"]}" ]]; then
1126 mkdir -p "$(dirname "${MODE_CONFIG["slick"]}")"
1127 touch "${MODE_CONFIG["slick"]}"
1128 echo "[Greeter]" > "${MODE_CONFIG["slick"]}"
1133 command_slick_grid(){
1134 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
1135 if ! check_bool "${_arg}"; then
1136 msg_error "Please specify true or false"
1139 slick_set_config "draw-grid" "${_arg}"
1142 command_slick_back(){
1143 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1144 msg_error "Please specify the image of background"
1147 if [[ ! -f "${1}" ]]; then
1148 msg_error "${1} was not found."
1152 local _backgrounf_file="${BACKGROUND_DIR}/lightdm/slick-greeter"
1153 mkdir -p "$(dirname "${_backgrounf_file}")"
1154 cp "${1}" "${_backgrounf_file}"
1155 chmod 644 "${_backgrounf_file}"
1157 slick_set_config "background" "${_backgrounf_file}"
1160 command_slick_gtk_wizard(){
1161 local _theme="$(ask_gtk_theme)"
1164 if [[ -n "${_theme}" ]]; then
1165 command_slick_gtk_change "${_theme}"
1169 echo "Changed theme to ${_theme}"
1172 command_slick_gtk_change(){
1173 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1174 msg_error "Please specify the theme"
1177 if [[ ! -d "/usr/share/themes/${1}" ]]; then
1178 msg_error "${1} was not found."
1181 slick_set_config "theme-name" "${1}"
1184 command_slick_icon_wizard(){
1186 readarray -t icons < <(get_icon_theme)
1189 echo "Please select the icon theme to use."
1190 if ! _icon="$(ask_question "${icons[@]}")"; then
1191 command_slick_icon_wizard
1195 if [[ -n "${_icon}" ]]; then
1196 slick_set_config "icon-theme-name" "${_icon}"
1198 command_slick_icon_wizard
1201 echo "Changed icon theme to ${_icon}"
1204 command_slick_icon_chenge(){
1205 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1206 msg_error "Please specify the icon theme to use."
1209 if ! printf "%s\n" "$(get_icon_theme)" | grep -x "${1}" 1> /dev/null 2>&1; then
1210 msg_error "${1} was not found."
1213 slick_set_config "icon-theme-name" "${1}"
1216 command_slick_remove(){
1217 common_remove_command "${MODE_CONFIG["slick"]}"
1222 # sddm_get_value <section> <key> <valye>
1224 crudini --set "${MODE_CONFIG["sddm"]}" "${1}" "${2}"
1227 # sddm_set_config <section> <key> <value>
1229 crudini --set "${MODE_CONFIG["sddm"]}" "${1}" "${2}" "${3}"
1232 # sddm_remove_key <section> <key>
1234 crudini --del "${MODE_CONFIG["sddm"]}" "${1}" "${2}"
1238 sddm_init_configs(){
1240 if [[ ! -f "${MODE_CONFIG["sddm"]}" ]]; then
1241 mkdir -p "$(dirname "${MODE_CONFIG["sddm"]}")"
1242 sddm --example-config > "${MODE_CONFIG["sddm"]}"
1247 command_sddm_auto_login(){
1248 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1249 # 既に自動ログインが設定されているかを確認
1250 local autologin_user="$(sddm_get_value Autologin User)"
1251 if [[ -n "${autologin_user}" ]]; then
1252 sddm_remove_key "Autologin" "User"
1253 echo "Canceled automatic login of ${autologin_user}"
1256 local autologin_user="${1}" autologin_session
1258 autologin_session="${2}"
1261 # セッションを設定 (WayLandのセッションは現在サポートされていません)
1262 if [[ -z "${autologin_session+SET}" ]]; then
1263 autologin_session="$(ask_session)"
1266 check_session "${autologin_session}"
1270 add_user_to_group "${autologin_user}" "autologin"
1273 sddm_set_config "Autologin" "User" "${autologin_user}"
1274 sddm_set_config "Autologin" "Session" "${autologin_session}"
1276 echo "${autologin_user} will automatically log in with ${autologin_session}"
1280 command_sddm_cursor_wizard(){
1282 local cursor_themes _current_theme="$(sddm_get_value "Theme" "CursorTheme")"
1283 readarray -t cursor_themes < <(get_cursor_theme)
1286 if ! _cursor_theme="$(ask_question -d "${_current_theme}" -p "Please select the cursor theme to use." "${cursor_themes[@]}")"; then
1287 command_sddm_cursor_wizard
1291 if [[ -n "${_cursor_theme}" ]]; then
1292 command_sddm_cursor_change "${_cursor_theme}"
1294 command_sddm_cursor_change
1298 if [[ ! "${_current_theme}" = "${_cursor_theme}" ]]; then
1299 echo "Changed cursor to ${_cursor_theme}"
1303 command_sddm_cursor_change(){
1304 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1305 msg_error "Please specify the cursor theme"
1309 readarray -t cursor_themes < <(get_cursor_theme)
1310 if ! printf "%s\n" "${cursor_themes[@]}" | grep -x "${1}" 1>/dev/null 2>&1; then
1311 msg_error "The cursor theme (${1}) was not found"
1314 sddm_set_config "Theme" "CursorTheme" "${1}"
1317 command_sddm_numlock(){
1318 local _arg="$(echo "${1-""}" | tr "[:upper:]" "[:lower:]")"
1319 if ! check_bool "${_arg}"; then
1320 msg_error "Please specify true or false"
1324 if [[ "${_arg}" = true ]]; then
1329 sddm_set_config "General" "Numlock" "${_value}"
1333 if ! check_int "${1}" || (( "${1}" < 1 )); then
1334 msg_error "Please enter an integer greater than 1"
1337 sddm_set_config "X11" "MinimumVT" "${1}"
1340 command_sddm_theme_wizard(){
1342 readarray -t _theme_list < <(find "/usr/share/sddm/themes/" -maxdepth 1 -mindepth 1 -type d -print0 | xargs -0 -I{} basename {})
1344 local _theme _current_theme=$(sddm_get_value "Theme" "Current")
1345 if ! _theme="$(ask_question -d "${_current_theme}" -p "Please select the theme to use." "${_theme_list[@]}")"; then
1346 command_sddm_theme_wizard
1349 if [[ -n "${_theme}" ]]; then
1350 command_sddm_theme_change "${_theme}"
1351 echo "Changed the theme to ${_theme}"
1353 command_sddm_theme_wizard
1359 command_sddm_theme_change(){
1360 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1361 msg_error "Please specify the theme name"
1364 if [[ ! -d "/usr/share/sddm/themes/${1}" ]]; then
1365 msg_error "The specified theme (${1}) does not exist"
1369 sddm_set_config "Theme" "Current" "${1}"
1373 # sddm_get_value <section> <key> <valye>
1375 crudini --set "${MODE_CONFIG["lxdm"]}" "${1}" "${2}"
1378 # sddm_set_config <section> <key> <value>
1380 crudini --set "${MODE_CONFIG["lxdm"]}" "${1}" "${2}" "${3}"
1383 # sddm_remove_key <section> <key>
1385 crudini --del "${MODE_CONFIG["lxdm"]}" "${1}" "${2}"
1389 lxdm_init_configs(){
1391 if [[ ! -f "${MODE_CONFIG["lxdm"]}" ]]; then
1392 mkdir -p "$(dirname "${MODE_CONFIG["lxdm"]}")"
1393 touch "${MODE_CONFIG["lxdm"]}"
1398 command_lxdm_auto_login(){
1399 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1400 # 既に自動ログインが設定されているかを確認
1401 local autologin_user="$(lxdm_get_value "base" "autologin")"
1402 if [[ -n "${autologin_user}" ]]; then
1403 sddm_remove_key "base" "autologin"
1404 echo "Canceled automatic login of ${autologin_user}"
1407 local autologin_user="${1}" autologin_session
1409 autologin_session="${2}"
1412 # セッションを設定 (WayLandのセッションは現在サポートされていません)
1413 if [[ -z "${autologin_session+SET}" ]]; then
1414 autologin_session="$(ask_session)"
1417 check_session "${autologin_session}"
1421 add_user_to_group "${autologin_user}" "autologin"
1424 sddm_set_config "base" "autologin" "${autologin_user}"
1427 command_lxdm_session_change "${autologin_session}"
1429 echo "${autologin_user} will automatically log in with ${autologin_session}"
1433 command_lxdm_session_wizard(){
1434 command_lxdm_session_change "$(ask_session)"
1437 command_lxdm_session_change(){
1438 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1439 msg_error "Please specify the session name"
1442 local session="${1}"
1443 check_session "${session}"
1444 local session_exec="$(get_session "${session}")"
1445 lxdm_set_config "base" "session" "${session_exec}"
1448 command_lxdm_remove_last(){
1449 rm -rf "/var/lib/lxdm/lxdm.conf"
1450 echo "Removed last configs"
1453 comamnd_lxdm_edit_script(){
1455 "LoginReady : executed with root privileges when LXDM is ready to show the login window"
1456 "PreLogin : run as root before logging a user in"
1457 "PostLogin : run as the logged-in user right after they have logged in"
1458 "PostLogout : run as the logged-in user right after they have logged out"
1459 "PreReboot : run as root before rebooting with LXDM"
1460 "PreShutdown: run as root before poweroff with LXDM"
1462 if ! file=$(ask_question -p "Select the script you want to edit" "${_filelist[@]}" | cut -d ":" -f 1 | tr -d " "); then
1463 comamnd_lxdm_edit_script
1466 bash -c "${USE_EDITOR} ${file}"
1469 command_lxdm_back(){
1470 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1471 msg_error "Please specify the image of background"
1474 if [[ ! -f "${1}" ]]; then
1475 msg_error "${1} was not found."
1479 local _backgrounf_file="${BACKGROUND_DIR}/lxdm/background"
1480 mkdir -p "$(dirname "${_backgrounf_file}")"
1481 cp "${1}" "${_backgrounf_file}"
1482 chmod 644 "${_backgrounf_file}"
1484 lxdm_set_config "display" "bg" "file://${_backgrounf_file}"
1487 command_lxdm_gtk_wizard(){
1488 local _theme="$(ask_gtk_theme)"
1491 if [[ -n "${_theme}" ]]; then
1492 command_lxdm_gtk_change "${_theme}"
1496 echo "Changed theme to ${_theme}"
1499 command_lxdm_gtk_change(){
1500 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1501 msg_error "Please specify the theme"
1504 if [[ ! -d "/usr/share/themes/${1}" ]]; then
1505 msg_error "${1} was not found."
1508 lxdm_set_config "display" "gtk_theme" "${1}"
1511 #== GTk Greeter用の汎用関数 ==#
1512 # gtk_greeter_get_value <section> <key>
1513 gtk_greeter_get_value(){
1514 crudini --set "${MODE_CONFIG["gtkg"]}" "${1}" "${2}"
1517 # gtk_greeter_set_config <section> <key> <value>
1518 gtk_greeter_set_config(){
1519 crudini --set "${MODE_CONFIG["gtkg"]}" "${1}" "${2}" "${3}"
1522 # gtk_greeter_remove_key <section> <key>
1523 gtk_greeter_remove_key(){
1524 crudini --del "${MODE_CONFIG["gtkg"]}" "${1}" "${2}"
1527 gtk_greeter_init_configs(){
1529 if [[ ! -f "${MODE_CONFIG["gtkg"]}" ]]; then
1530 mkdir -p "$(dirname "${MODE_CONFIG["gtkg"]}")"
1531 touch "${MODE_CONFIG["gtkg"]}"
1535 #== GTk Greeter用のコマンド==#
1536 command_gtk_greeter_gtk_wizard(){
1537 local _theme="$(ask_gtk_theme)"
1540 if [[ -n "${_theme}" ]]; then
1541 gtk_greeter_set_config "greeter" "theme-name" "${_theme}"
1545 echo "Changed theme to ${_theme}"
1548 command_gtk_greeter_gtk_change(){
1549 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1550 msg_error "Please specify the theme"
1553 if ! printf "%s\n" "$(get_gtk_theme)" | grep -x "${1}" 1> /dev/null 2>&1; then
1554 msg_error "${1} was not found."
1557 gtk_greeter_set_config "greeter" "theme-name" "${1}"
1560 command_gtk_greeter_icon_wizard(){
1562 readarray -t icons < <(get_icon_theme)
1565 echo "Please select the icon theme to use."
1566 if ! _icon="$(ask_question "${icons[@]}")"; then
1567 command_gtk_greeter_icon_wizard
1571 if [[ -n "${_icon}" ]]; then
1572 gtk_greeter_set_config "greeter" "icon-theme-name" "${_icon}"
1574 command_gtk_greeter_icon_wizard
1577 echo "Changed icon theme to ${_icon}"
1580 command_gtk_greeter_icon_chenge(){
1581 if [[ -z "${1+SET}" ]] || [[ "${1}" = "" ]]; then
1582 msg_error "Please specify the icon theme to use."
1585 if ! printf "%s\n" "$(get_icon_theme)" | grep -x "${1}" 1> /dev/null 2>&1; then
1586 msg_error "${1} was not found."
1589 gtk_greeter_set_config "greeter" "icon-theme-name" "${_icon}"
1594 declare -A MODE_CONFIG=(
1595 ["lightdm"]="/etc/lightdm/lightdm.conf.d/00-dmc-lightdm.conf"
1596 ["gdm-dconf"]="/etc/dconf/db/gdm.d/00-dmc-gdm"
1597 ["gdm-custom"]="/etc/gdm/custom.conf"
1598 ["sddm"]="/etc/sddm.conf.d/sddm.conf"
1599 ["lxdm"]="/etc/lxdm/lxdm.conf"
1600 ["webkit2"]="/etc/lightdm/lightdm-webkit2-greeter.conf"
1601 ["slick"]="/etc/lightdm/slick-greeter.conf"
1602 ["gtkg"]="/etc/lightdm/lightdm-gtk-greeter.conf"
1603 ["elementary"]="/etc/lightdm/io.elementary.greeter.conf"
1604 ["mini"]="/etc/lightdm/lightdm-mini-greeter.conf"
1605 ["qtquick"]="/etc/lightdm/lightdm-qtquick-greeter.json"
1608 declare -A MAIN_BINARY=(
1609 ["lightdm"]="/usr/bin/lightdm"
1610 ["gdm"]="/usr/bin/gdm"
1611 ["sddm"]="/usr/bin/sddm"
1612 ["webkit2"]="/usr/bin/lightdm-webkit2-greeter"
1613 ["slick"]="/usr/bin/slick-greeter"
1614 ["gtkg"]="/usr/bin/lightdm-gtk-greeter"
1615 ["elementary"]="/usr/bin/io.elementary.greeter"
1616 ["mini"]="/usr/bin/lightdm-mini-greeter"
1617 ["qtquick"]="/usr/bin/lightdm-qtquick-greeter"
1618 ["lxdm"]="/usr/bin/lxdm"
1621 declare -A GREETER_MODE=(
1622 ["lightdm-webkit2-greeter"]="webkit2"
1623 ["lightdm-slick-greeter"]="slick"
1624 ["io.elementary.greeter"]="elementary"
1625 ["lightdm-mini-greeter"]="mini"
1626 ["lightdm-qtquick-greeter"]="qtquick"
1627 ["lightdm-gtk-greeter"]="gtkg"
1632 # LightDM - Greeterのディレクトリ
1633 LIGHTDM_GREETERS_DIR="$(lightdm_get_value "greeters-directory")"
1634 : "${LIGHTDM_GREETERS_DIR:="/usr/share/xgreeters"}"
1636 # LightDM - 現在設定されているGreeter
1637 LIGHTDM_CURRENT_GREETER="$(lightdm --show-config 2>&1 | grep "greeter-session" | cut -d "=" -f 2)"
1638 : "${LIGHTDM_CURRENT_GREETER:="lightdm-gtk-greeter"}"
1641 USE_EDITOR="${EDITOR:-vi}"
1643 # Global - 背景画像をコピーするディレクトリ
1644 BACKGROUND_DIR="/usr/share/backgrounds"
1646 # Global - 現在のディスプレイマネージャ名
1647 if [[ -f "/etc/systemd/system/display-manager.service" ]]; then
1648 CURRENT_DM="$(basename "$(readlink "/etc/systemd/system/display-manager.service")" | sed "s|.service$||g")"
1654 MODE="${CURRENT_DM}"
1655 : "${MODE:="lightdm"}"
1658 NON_INTERACTIVE=false
1659 WRITE_ALL_FILES=false
1661 NO_CHECK_TARGET=false
1666 OPTS=("m:" "e:" "h" "G")
1667 OPTL=("mode:" "editor:" "help" "non-interactive" "noroot" "write-all-files" "no-check-target" "lightdm-greeter" "remove")
1668 if ! readarray -t OPT < <(getopt -o "$(printf "%s," "${OPTS[@]}")" -l "$(printf "%s," "${OPTL[@]}")" -- "${ARGUMENT[@]}"); then
1672 eval set -- "${OPT[@]}"
1689 -G | --lightdm-greeter)
1690 if [[ -n "${LIGHTDM_CURRENT_GREETER+SET}" ]]; then
1691 MODE="${GREETER_MODE["${LIGHTDM_CURRENT_GREETER}"]}"
1693 msg_error "Failed to get the currently running Greeter."
1699 NON_INTERACTIVE=true
1707 NO_CHECK_TARGET=true
1711 WRITE_ALL_FILES=true
1726 COMMAND="${1:-null}"
1727 if (( "${#}" >= 1 )); then
1730 COMMAND_ARGS=("${@}")
1731 : "${COMMAND_ARGS=""}" # サブコマンドの引数が何も指定されなかった場合に空文字を代入
1733 if [[ "${COMMAND}" = "null" ]]; then
1739 if [[ "${NO_CHECK_TARGET}" = false ]]; then
1743 # コマンドとモードに応じて関数を実行する
1744 case "${COMMAND}" in
1746 check_command_dm "gdm"
1748 command_gdm_accessibility "${COMMAND_ARGS[@]}"
1751 check_command_dm "lightdm" "gdm" "sddm" "lxdm"
1754 lightdm_init_configs
1755 command_lightdm_auto_login "${COMMAND_ARGS[@]}"
1759 command_gdm_auto_login "${COMMAND_ARGS[@]}"
1763 command_sddm_auto_login "${COMMAND_ARGS[@]}"
1767 command_lxdm_auto_login "${COMMAND_ARGS[@]}"
1772 check_command_dm "qtquick" "slick" "lxdm"
1775 qtquick_init_configs
1776 command_qtquick_back "${COMMAND_ARGS[@]}"
1780 command_slick_back "${COMMAND_ARGS[@]}"
1784 command_lxdm_back "${COMMAND_ARGS[@]}"
1789 check_command_dm "gdm" "sddm"
1793 command_gdm_cursor_wizard
1797 command_sddm_cursor_wizard
1802 check_command_dm "gdm" "sddm"
1806 command_gdm_cursor_change "${COMMAND_ARGS[@]}"
1810 command_sddm_cursor_change "${COMMAND_ARGS[@]}"
1815 check_comamnd_dm "webkit2"
1816 command_webkit2_debug "${COMMAND_ARGS[@]}"
1819 command_general_dm "${COMMAND_ARGS[@]}"
1822 check_command_dm "lightdm" "gdm"
1826 command_lightdm_edit
1835 check_command_dm "lxdm"
1837 comamnd_lxdm_edit_script
1840 check_command_dm "slick" "lxdm" "gtkg"
1844 command_slick_gtk_wizard
1848 command_lxdm_gtk_wizard
1851 gtk_greeter_init_configs
1852 command_gtk_greeter_gtk_wizard
1857 check_command_dm "lightdm"
1858 lightdm_init_configs
1859 command_lightdm_greeter_wizard
1862 check_command_dm "lightdm"
1863 lightdm_init_configs
1864 command_lightdm_greeter_change "${COMMAND_ARGS[@]}"
1867 check_command_dm "lightdm"
1868 lightdm_init_configs
1869 command_lightdm_greeter_create "${COMMAND_ARGS[@]}"
1872 check_command_dm "lightdm"
1874 command_lightdm_greeter_edit "${COMMAND_ARGS[@]}"
1877 check_command_dm "lightdm"
1878 command_lightdm_greeter_list
1882 check_command_dm "slick"
1884 command_slick_grid "${COMMAND_ARGS[@]}"
1887 check_command_dm "slick" "lxdm" "gtkg"
1891 command_slick_gtk_change "${COMMAND_ARGS[@]}"
1894 command_lxdm_gtk_change "${COMMAND_ARGS[@]}"
1897 command_gtk_greeter_gtk_change "${COMMAND_ARGS[@]}"
1902 check_command_dm "slick" "gtkg"
1906 command_slick_icon_wizard
1909 gtk_greeter_init_configs
1910 command_gtk_greeter_icon_wizard
1915 check_command_dm "slick" "gtkg"
1919 command_slick_icon_chenge "${COMMAND_ARGS[@]}"
1922 gtk_greeter_init_configs
1923 command_gtk_greeter_icon_chenge "${COMMAND_ARGS[@]}"
1928 check_command_dm "gdm" "slick"
1932 command_gdm_logo "${COMMAND_ARGS[@]}"
1936 command_slick_logo "${COMMAND_ARGS[@]}"
1941 check_command_dm "sddm"
1943 command_sddm_numlock "${COMMAND_ARGS[@]}"
1946 check_command_dm "slick"
1948 command_slick_other_monitor "${COMMAND_ARGS[@]}"
1951 check_command_dm "lightdm" "gdm" "webkit2" "qtquick"
1953 eval "command_${MODE}_remove"
1956 check_command_dm "lxdm"
1958 command_lxdm_remove_last
1961 check_command_dm "gdm"
1963 command_gdm_root_login "${COMMAND_ARGS[@]}"
1966 check_command_dm "lxdm"
1968 command_lxdm_session_wizard
1971 check_command_dm "lxdm"
1973 command_lxdm_session_change "${COMMAND_ARGS[@]}"
1976 check_command_dm "lightdm"
1977 command_lightdm_show_config
1981 check_command_dm "gdm"
1983 command_gdm_sound "${COMMAND_ARGS[@]}"
1986 check_command_dm "gdm"
1988 command_gdm_tap "${COMMAND_ARGS[@]}"
1991 check_command_dm "webkit2" "sddm"
1994 webkit2_init_configs
1995 command_webkit2_theme_wizard
1999 command_sddm_theme_wizard
2004 check_command_dm "webkit2" "sddm"
2007 webkit2_init_configs
2008 command_webkit2_theme_change "${COMMAND_ARGS[@]}"
2012 command_sddm_theme_change
2017 check_command_dm "sddm"
2019 command_sddm_tty "${COMMAND_ARGS[@]}"
2025 "lightdm" | "gdm" | "sddm" | "lxdm" | "webkit2" | "qtquick" | "slick" | "gtkg")
2026 command_mode "${COMMAND}" "${COMMAND_ARGS[@]}"
2033 msg_error "This command cannot be used in any mode"