-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenameworkspace.py
executable file
·34 lines (25 loc) · 1.1 KB
/
renameworkspace.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/python3
import os
# Get workspace names
x = os.popen('gsettings get org.gnome.desktop.wm.preferences workspace-names').read()
# Get current workspace index
current_workspace = int(os.popen("xdotool get_desktop").read())
# Create an python array from x
workspaces = x[1:-2].replace("'","").split(", ")
# Ensure the list contains up to current_workspace index
if(len(workspaces) >= (current_workspace+1)):
current_name = workspaces[current_workspace]
else:
current_name = ''
workspaces.extend(['']*(1+current_workspace-len(workspaces)))
# Ask for new label
new_name = os.popen(f"zenity --entry --entry-text='{current_name}' --title='Workspace label' --text='New label'").read()
if(new_name == ''):
print("User cancelled the input, returning..")
else:
# Set new label in array ([0:-1] to remove \n)
workspaces[current_workspace] = new_name[0:-1]
# Apply changes
os.system(f'gsettings set org.gnome.desktop.wm.preferences workspace-names "{str(workspaces)}"')
# just to 'debug'
print(f'gsettings set org.gnome.desktop.wm.preferences workspace-names "{str(workspaces)}"')