Вы можете «щелкнуть правой кнопкой мыши => Настройки» на переключателе рабочих пространств Gnome, чтобы переименовать рабочие пространства.
Мне интересно, можно ли настроить сочетание клавиш для запуска переименования текущего активного рабочего пространства.
Используйте dconf-editor
от Терминала, перейдите к gnome>desktop>wm>
и затем установите workspace-names
на
["Internet", "Oracle", "Gimp", "PHP"]
Нет никакого ярлыка, о котором я знаю, но можно записать сценарий для изменения маркировки рабочей области:
#!/bin/zsh
#get desktop number
n=$(xdotool get_desktop)
n=$[n+1]
#get current workspace label
et=$(cat ~/.workspacenames/names| sed -n "$n p")
#prompt user for new workspace label
label=$(zenity --entry --entry-text="$et" --title="Workspace label" --text="New label")
if [ "$label" = "" ] ; then exit; fi
#replace the workspace label in our local file
sed "$n s/.*/$label/" -i ~/.workspacenames/names
#convert lines of the local file to an array gsettings can understand
magic=$(cat ~/.workspacenames/names | tr '\r\n' '|' | sed "s/.$/\"/;s/^/\"/;s/|/\",\"/g"|sed 's/\(.*\)/\[\1\]/')
#update settings
gsettings set org.gnome.desktop.wm.preferences workspace-names "$magic"
Этот сценарий предполагает, что Вы имеете zenity, установленный, и имеете локальный файл, названный ~/.workspacenames/names
, который имеет название каждой рабочей области на новой строке. Можно поместить этот сценарий в тот же каталог как имена, и у Вас может быть ярлык (для меня, Супер + W ) для выполнения его.
Примечание: Этот ответ разветвлен от ответ Baldersmash . Кредит на поиск необходимых команд переходит к ответу Baldersmash.
#!/bin/bash
# Get total count of workspaces.
count=$(gsettings get org.gnome.desktop.wm.preferences num-workspaces)
# Get current workspace number
current_num=$(xdotool get_desktop)
# Get existing workspace names
existing_names=$(gsettings get org.gnome.desktop.wm.preferences workspace-names | grep -oP '\[.*')
# Let python worry about the indexing to find the name of current workspace.
existing_name=$(python <<< "print $existing_names[$current_num]" 2>/dev/null)
# Get the new name from the user. Exit the script if the user presses cancel.
new_name=$(zenity --entry --entry-text="$existing_name" --title="Workspace $((current_num+1)) label" --text="New label:") || exit 0
# Again abuse python to fill the array correctly.
new_names=$(python << EOF
a = ($existing_names + [''] * $count)[:$count] # Create the array of sufficient size.
a[$current_num] = "$new_name" # Set the current workspace's name (Assumes that it does not contain special characters.)
print a # Print the array.
EOF
)
# Set new array in gsettings.
gsettings set org.gnome.desktop.wm.preferences workspace-names "$new_names"
нижняя панель гнома имеет переключатель рабочей области с записями по умолчанию.
я добавил переключатель рабочей области в главной панели гнома (выровненный центр) с этими настройками:
И я добавил средство запуска пользовательского приложения только около него который точки к вышеупомянутому сценарию.
Более чистый сценарий (но потребности qdbus
). Вероятно, работы для удара также.
#!/usr/bin/env zsh
# Capture output in evaljs properly
IFS=$'\n'
function evaljs() {
eval_res=($(qdbus org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval "$1"))
echo $eval_res[2]
}
if [[ -z $1 ]]; then
name=$(zenity --entry --entry-text="" --title="Workspace label" --text="New label")
else
name=$1
fi
evaljs "
const Gio = imports.gi.Gio;
let i = global.screen.get_active_workspace_index();
let settings = new Gio.Settings({ schema_id:
'org.gnome.desktop.wm.preferences'});
let names = settings.get_strv('workspace-names');
let oldName = names[i];
names[i] = '$name';
settings.set_strv('workspace-names', names);
oldName;
"
Я любил и много использовал ответ @anishsane ... но я хотел изменить его так, чтобы он сбрасывал имя на "WP #", если было задано пустое имя. .
Поскольку решение @anishsane будет использовать Python дважды, моя версия просто переписана на Python:
#! /usr/bin/python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gio, Gtk, GLib
import subprocess
gs = Gio.Settings.new("org.gnome.desktop.wm.preferences")
names = list(gs.get_value("workspace-names"))
# Get existing workspace number
current = int(subprocess.check_output(['xdotool', 'get_desktop']).strip())
# Create and run dialog
dialog = Gtk.Dialog(title="Workspace {} label".format(current+1))
dialog.add_buttons(Gtk.STOCK_OK, Gtk.ResponseType.OK,
Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
dialog.set_default_response(Gtk.ResponseType.OK)
entry = Gtk.Entry(text=names[current])
entry.set_activates_default(True)
label = Gtk.Label(label="New label:")
a = dialog.get_content_area()
a.add(label)
a.add(entry)
a.show_all()
resp = dialog.run()
# If "OK" was clicked (or Enter was pressed)...
if resp == Gtk.ResponseType.OK:
value = entry.get_text().strip()
if value:
# ... either set the new name to the one chosen by the user...
names[current] = value
else:
# ... or to a placeholder if the user set the empty string.
names[current] = 'WP {}'.format(current + 1)
# Set the new names:
gs.set_value("workspace-names", GLib.Variant('as', value=names))