фон/цвет текста терминала гнома набора из сценария удара

Используйте gnome-control-center присваивать сочетания клавиш различным рабочим столам. В зависимости от версии GNOME Вы используете объект, будет, вероятно, назван по-другому. На GNOME 2.32 это назвало Горячие клавиши.

22
22.07.2018, 06:46
2 ответа

Метод №1 - Использование dconf

Предпосылки

Для этого можно использовать инструмент dconf , однако это многоступенчатый процесс.

DESCRIPTION
       The dconf program can perform various operations on a dconf database, 
       such as reading or writing individual values or entire directories.
       This tool operates directly on the dconf database and does not read 
       gsettings schema information.Therefore, it cannot perform type and 
       consistency checks on values. The gsettings(1) utility is an 
       alternative if such checks are needed.

Использование

$ dconf
error: no command specified

Usage:
  dconf COMMAND [ARGS...]

Commands:
  help              Show this information
  read              Read the value of a key
  list              List the contents of a dir
  write             Change the value of a key
  reset             Reset the value of a key or dir
  update            Update the system databases
  watch             Watch a path for changes
  dump              Dump an entire subpath to stdout
  load              Populate a subpath from stdin

Use 'dconf help COMMAND' to get detailed help.

Общий подход

  1. Сначала вам нужно получить список ваших профилей gnome-terminal .

     $ dconf list / org / gnome / terminal / legacy / profiles: / 
     <идентификатор профиля> 
     
  2. Используя этот <идентификатор профиля> , вы можете затем получить список настраиваемых параметров

     $ dconf list / org / gnome / terminal / legacy / profiles: /  
    background-color 
    default-size-columns {{1} } use-theme-colors 
    use-custom-default-size 
    цвет переднего плана 
    use-system-font 
    font 
     
  3. Затем вы можете прочитать текущие цвета переднего или заднего плана

    переднего плана

     $ dconf read / org / gnome / terminal / legacy / profiles: /  / foreground-color 
     'rgb (255,255,255) '
     

    background

     $ dconf read / org / gnome / terminal / legacy / profiles: /  / background-color 
    ' rgb (0,0 , 0) '
     
  4. Вы также можете изменить цвета

    передний план

     $ dconf write / org / gnome / terminal / legacy / profiles: /  / foreground-color " 'rgb (255,255,255)' "
     

    фон

     $ dconf write / org / gnome / terminal / legacy / profiles: / <идентификатор профиля> / background-color" 'rgb (0,0,0) '"
     

Пример

  1. Получить идентификатор моего профиля

     $ dconf list / org / gnome / terminal / legacy / profiles: / 
    : b1dcc9dd -5262-4d8d-a863-c897e6d979b9 / 
     
  2. Используйте идентификатор профиля, чтобы получить список настроек

     $ dconf list / org / gnome / terminal / legacy / profiles: /: b1dcc9dd-5262- 4d8d-a863-c897e6d979b9 / 
    background-color 
    default-size-columns 
    use-theme-colors 
    use-custom-default-size {{1} } foreground-color 
    use-system-font 
    font 
     
  3. Измените синий фон

     $ dconf write / org / gnome / terminal / legacy / profiles: / : b1dcc9dd-5262-4d8d-a863-c897e6d979b9 / background-color "'rgb (0,0,255)'" 
     

ss #1

Примечание о цветах

Вы можете использовать любое обозначение rgb (R, G, B) при указании ваших цветов или хеш-нотации #RRGGBB .В обоих обозначениях аргументы - красный, зеленый и синий. Значения в первом представлении представляют собой целые числа от 0 до 255 для R, G или B. Во втором представлении значения представлены в шестнадцатеричном формате в диапазоне от 00 до FF для RR, GG или BB.

При предоставлении любого из них в dconf вам необходимо правильно заключить его в двойные кавычки с одинарными кавычками, вложенными внутрь. В противном случае dconf пожалуется.

  • "'rgb (0,0,0)'"
  • "'# FFFFFF'"
  • и т. Д.

Метод №2 - Использование gconftool-2

В моей системе Ubuntu 12.04 я смог изменить цвета через командную строку следующим образом.

ПРИМЕЧАНИЕ: Параметры в конечном итоге хранятся в этом файле, $ HOME / .gconf / apps / gnome-terminal / profiles / Default /% gconf.xml .

Общий подход

  1. Сначала вам нужно получить дерево для профиля gnome-terminal .

     $ gconftool-2 --get / apps / gnome-terminal / global / profile_list 
     [По умолчанию] 
     
  2. Используя получившееся дерево, мы можем узнать, какие атрибуты можно настраивать.

     $ gconftool-2 -a "/ apps / gnome-terminal / profiles / Default" | grep color 
    bold_color_same_as_fg = true 
    bold_color = # 000000000000 
    background_color = #FFFFFFFFFFFF 
    foreground_color = # 000000000000 
    use_theme_colors = false 
     
  3. Получить / установить атрибуты background_color & foreground_color

     $ gconftool-2 --get "/ apps / gnome-terminal / profiles / Default / foreground_color" {{1 }} # 000000000000 
     
     $ gconftool-2 --set "/ apps / gnome-terminal / profiles / Default / background_color" --type string "# 000000FFFFFF" 
     
  4. Подтвердите

     $ gconftool-2 -R / apps / gnome-terminal / profiles / Default | grep color 
    bold_color_same_as_fg = true 
    bold_color = # 000000000000 
    background_color = # 000000FFFFFF 
    foreground_color = # 000000000000 
    use_theme_colors = true 
     

Ссылки

20
27.01.2020, 19:43

Я создал несколько функций на основе кода Github из других потоков. Вы можете поместить эти функции в свой файл ~ / .bashrc . Как видите, если вы вызовете create_random_profile :

  1. , он проверит и удалит любой предыдущий случайный профиль, который вы создали.
  2. Это создаст профиль случайного имени в терминалах gnome.
  3. Это имя будет установлено в переменной среды, которую вы можете использовать для изменения цвета в предопределенных функциях. См. Последнюю функцию setcolord .

Это должно быть полезно, чтобы иметь много терминалов разного цвета. Кроме того, с помощью предустановленных функций вы можете менять эти цвета на лету.

function create_random_profile() {
    #delete previous profiles in case there were something
    #delete_one_random_profile
    prof="`mktemp -u HACK_PROFILE_XXXXXXXXXX`"
    gconftool-2 --set "/apps/gnome-terminal/profiles/$prof/use_theme_colors" --type bool false
    gconftool-2 --type list --list-type string --set $prof_list "`gconftool-2 --get $prof_list | sed "s/]/,$prof]/"`"
    file="`mktemp`"
    gconftool-2 --dump "/apps/gnome-terminal/profiles/Default" | sed "s,profiles/$2,profiles/$prof,g" > "$file"
    gconftool-2 --load "$file"
    gconftool-2 --type string --set "/apps/gnome-terminal/profiles/$prof/visible_name" "$prof"
    rm -f -- "$file"
    export __TERM_PROF=$prof
}

function delete_one_random_profile() {
    regular="HACK_PROFILE_"
    prof=$(gconftool-2 --get /apps/gnome-terminal/global/profile_list | sed -n "s/.*\(HACK_PROFILE_..........\).*/\1/p")
    if [ ! -z "$prof"]; then
        echo "size ${#prof}"
        echo "size of regular ${#regular}"
        echo "DO DELETE of $prof"
        #if not empty
        gconftool-2 --type list --list-type string --set $prof_list "`gconftool-2 --get $prof_list | sed "s/$prof//;s/\[,/[/;s/,,/,/;s/,]/]/"`"
        gconftool-2 --unset "/apps/gnome-terminal/profiles/$prof"
    else
        echo "NOTHING TO DELETE"
    fi
}

function setcolord() {
    echo "Dont forget to change to Profile0 in the menu of your terminal->Change Profile->Profile_0"
    gconftool-2 --set "/apps/gnome-terminal/profiles/$__TERM_PROF/background_color" --type string white
    gconftool-2 --set "/apps/gnome-terminal/profiles/$__TERM_PROF/foreground_color" --type string black
}

function setcolor_cyan() {
    echo "Dont forget to change to $__TERM_PROF in the menu of your terminal->Change Profile->Profile_0"
    gconftool-2 --set "/apps/gnome-terminal/profiles/$__TERM_PROF/background_color" --type string "#8DCBCC"
    gconftool-2 --set "/apps/gnome-terminal/profiles/$__TERM_PROF/foreground_color" --type string black
}
0
27.01.2020, 19:43

Теги

Похожие вопросы