|
| 1 | +#! /bin/bash |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +###################################################################### |
| 5 | +# Copyright 2024 Andy Fingerhut |
| 6 | +# |
| 7 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +# you may not use this file except in compliance with the License. |
| 9 | +# You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +# See the License for the specific language governing permissions and |
| 17 | +# limitations under the License. |
| 18 | +###################################################################### |
| 19 | + |
| 20 | +# Customize some GNOME desktop settings that I prefer. |
| 21 | + |
| 22 | +# This command will show the GNOME version number installed/running on |
| 23 | +# the system: |
| 24 | +# gnome-shell --version |
| 25 | +# The output on all versions I checked was of the form: |
| 26 | +# GNOME Shell <dotted decimal version string> |
| 27 | + |
| 28 | +# This command can be used to see what names that the version of GNOME |
| 29 | +# installed on a system uses for the applications that have been |
| 30 | +# pinned in the Dash: |
| 31 | +# gsettings get org.gnome.shell favorite-apps |
| 32 | + |
| 33 | +which gnome-shell > /dev/null |
| 34 | +exit_status=$? |
| 35 | +if [ ${exit_status} -ne 0 ] |
| 36 | +then |
| 37 | + 1>&2 echo "No command 'gnome-shell' found in command path." |
| 38 | + 1>&2 echo "Does this system have GNOME installed? Aborting." |
| 39 | + exit 1 |
| 40 | +fi |
| 41 | + |
| 42 | +which gsettings > /dev/null |
| 43 | +exit_status=$? |
| 44 | +if [ ${exit_status} -ne 0 ] |
| 45 | +then |
| 46 | + 1>&2 echo "No command 'gsettings' found in command path." |
| 47 | + 1>&2 echo "Does this system have GNOME installed? Aborting." |
| 48 | + exit 1 |
| 49 | +fi |
| 50 | + |
| 51 | +GNOME_VERSION_STR=`gnome-shell --version | awk '{print $3;}'` |
| 52 | + |
| 53 | +TERMINAL_NAME="org.gnome.Terminal.desktop" |
| 54 | +NAUTILUS_NAME="org.gnome.Nautilus.desktop" |
| 55 | +UPDATE_MANAGER_NAME="update-manager.desktop" |
| 56 | +HELP_NAME="yelp.desktop" |
| 57 | + |
| 58 | +supported_version=0 |
| 59 | +case ${GNOME_VERSION_STR} in |
| 60 | + 3.36.9) |
| 61 | + # I have seen GNOME version 3.36.9 installed on systems running: |
| 62 | + # Ubuntu 20.04 |
| 63 | + supported_version=1 |
| 64 | + FIREFOX_NAME="firefox.desktop" |
| 65 | + SETTINGS_NAME="gnome-control-center.desktop" |
| 66 | + ;; |
| 67 | + 42.9) |
| 68 | + # I have seen GNOME version 42.9 installed on systems running: |
| 69 | + # Ubuntu 22.04 |
| 70 | + supported_version=1 |
| 71 | + FIREFOX_NAME="firefox_firefox.desktop" |
| 72 | + SETTINGS_NAME="gnome-control-center.desktop" |
| 73 | + ;; |
| 74 | + 46.0|47.0) |
| 75 | + # I have seen GNOME version 46.0 installed on systems running: |
| 76 | + # Ubuntu 24.04 |
| 77 | + # I have seen GNOME version 47.0 installed on systems running: |
| 78 | + # Ubuntu 24.10 |
| 79 | + supported_version=1 |
| 80 | + FIREFOX_NAME="firefox_firefox.desktop" |
| 81 | + SETTINGS_NAME="org.gnome.Settings.desktop" |
| 82 | + ;; |
| 83 | +esac |
| 84 | + |
| 85 | +if [ ${supported_version} -eq 1 ] |
| 86 | +then |
| 87 | + echo "Found supported GNOME version ${GNOME_VERSION_STR} installed." |
| 88 | +else |
| 89 | + 1>&2 echo "Found GNOME version ${GNOME_VERSION_STR} installed, but" |
| 90 | + 1>&2 echo "this script does not support that version of GNOME." |
| 91 | + 1>&2 echo "Consider updating the script so it does." |
| 92 | + exit 1 |
| 93 | +fi |
| 94 | + |
| 95 | +set -x |
| 96 | +# Update GNOME settings via the following corresponding gsettings |
| 97 | +# commands. |
| 98 | + |
| 99 | +# This command has the same effect as doing this in Settings app |
| 100 | +# in Ubuntu 24.04: |
| 101 | +# Privacy & Security -> Screen Lock -> Blank Screen Delay -> Never |
| 102 | +gsettings set org.gnome.desktop.session idle-delay 0 |
| 103 | + |
| 104 | +# Privacy & Security -> Screen Lock -> Automatic Screen Lock -> disabled |
| 105 | +gsettings set org.gnome.desktop.screensaver lock-enabled false |
| 106 | + |
| 107 | +# Ubuntu Desktop -> Dock -> Icon Size -> 24 |
| 108 | +gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 24 |
| 109 | + |
| 110 | +# Update the list of icons pinned in the Dash: |
| 111 | +gsettings set org.gnome.shell favorite-apps "['${TERMINAL_NAME}', '${FIREFOX_NAME}', '${NAUTILUS_NAME}', '${SETTINGS_NAME}', '${UPDATE_MANAGER_NAME}', '${HELP_NAME}']" |
| 112 | + |
| 113 | +# System -> Users -> user account "p4" -> Automatic Login -> enabled |
| 114 | +# Changing this does not change the output of the command: |
| 115 | +# gsettings list-recursively |
| 116 | +# It must modify something on the system elsewhere. |
| 117 | +# I learned that it causes a line like the following in file |
| 118 | +# /etc/gdm3/custom.conf to have the value after the = change from False to True: |
| 119 | +#AutomaticLoginEnable=False |
| 120 | +# This line is in a section labeled [daemon]. |
| 121 | +# It also causes this line to be created, or its value modified, |
| 122 | +# to the user account name: |
| 123 | +#AutomaticLogin=p4 |
| 124 | + |
| 125 | +# TODO: The best way to change this from a Bash script would be to |
| 126 | +# find a well-tested utility program that modifies or adds settings to |
| 127 | +# files with that format, which is like a Windows INI format file. |
0 commit comments