sync
This commit is contained in:
parent
0fa4469835
commit
93f28a4155
11
src/usr/lib/pika/gnome-layouts/dconf-accent.sh
Executable file
11
src/usr/lib/pika/gnome-layouts/dconf-accent.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#! /usr/bin/bash
|
||||||
|
# Enable extension
|
||||||
|
gnome-extensions enable custom-accent-colors@demiskp
|
||||||
|
# Set accent color settings
|
||||||
|
dconf write /org/gnome/shell/extensions/custom-accent-colors/accent-color "'"$1"'"
|
||||||
|
dconf write /org/gnome/shell/extensions/custom-accent-colors/theme-flatpak true
|
||||||
|
dconf write /org/gnome/shell/extensions/custom-accent-colors/theme-gtk3 true
|
||||||
|
dconf write /org/gnome/shell/extensions/custom-accent-colors/theme-shell true
|
||||||
|
# Refresh Shell
|
||||||
|
dconf write /org/gnome/shell/extensions/user-theme/name "''"
|
||||||
|
dconf write /org/gnome/shell/extensions/user-theme/name "'CustomAccentColors'"
|
@ -196,6 +196,36 @@ class Application:
|
|||||||
subprocess.run(["/etc/pika/scripts/pika-layouts/layout-scripts/unity.sh"], shell=True)
|
subprocess.run(["/etc/pika/scripts/pika-layouts/layout-scripts/unity.sh"], shell=True)
|
||||||
### Settings ###
|
### Settings ###
|
||||||
|
|
||||||
|
### Accent Colors
|
||||||
|
|
||||||
|
def blue_accent_button_pressed_cb (self, widget):
|
||||||
|
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh blue"], shell=True)
|
||||||
|
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C blue"], shell=True)
|
||||||
|
def green_accent_button_pressed_cb (self, widget):
|
||||||
|
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh green"], shell=True)
|
||||||
|
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C green"], shell=True)
|
||||||
|
def yellow_accent_button_pressed_cb (self, widget):
|
||||||
|
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh yellow"], shell=True)
|
||||||
|
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C yellow"], shell=True)
|
||||||
|
def orange_accent_button_pressed_cb (self, widget):
|
||||||
|
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh orange"], shell=True)
|
||||||
|
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C orange"], shell=True)
|
||||||
|
def red_accent_button_pressed_cb (self, widget):
|
||||||
|
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh red"], shell=True)
|
||||||
|
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C red"], shell=True)
|
||||||
|
def magenta_accent_button_pressed_cb (self, widget):
|
||||||
|
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh magenta"], shell=True)
|
||||||
|
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C magenta"], shell=True)
|
||||||
|
def purple_accent_button_pressed_cb (self, widget):
|
||||||
|
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh purple"], shell=True)
|
||||||
|
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C purple"], shell=True)
|
||||||
|
def brown_accent_button_pressed_cb (self, widget):
|
||||||
|
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh brown"], shell=True)
|
||||||
|
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C brown"], shell=True)
|
||||||
|
def gray_accent_button_pressed_cb (self, widget):
|
||||||
|
subprocess.run(["/usr/lib/pika/gnome-layouts/dconf-accent.sh gray"], shell=True)
|
||||||
|
subprocess.run(["pkexec /usr/lib/pika/gnome-layouts/papirus-folders -u -C grey"], shell=True)
|
||||||
|
|
||||||
#### Desktop Switch ####
|
#### Desktop Switch ####
|
||||||
def on_desktop_switch_active_notify(self, switch, state):
|
def on_desktop_switch_active_notify(self, switch, state):
|
||||||
if switch.get_active() == True :
|
if switch.get_active() == True :
|
||||||
|
@ -358,11 +358,21 @@
|
|||||||
<property name="valign">start</property>
|
<property name="valign">start</property>
|
||||||
<property name="homogeneous">True</property>
|
<property name="homogeneous">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="blue">
|
<object class="GtkButton" id="blue_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Blue</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/blue.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="blue_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="blue_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Blue</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/blue.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -371,11 +381,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="green">
|
<object class="GtkButton" id="green_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Green</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/green.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="green_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="green_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Green</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/green.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -384,11 +404,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="yellow">
|
<object class="GtkButton" id="yellow_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Yellow</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/yellow.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="yellow_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="yellow_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Yellow</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/yellow.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -397,11 +427,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="orange">
|
<object class="GtkButton" id="orange_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Orange</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/orange.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="orange_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="orange_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Orange</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/orange.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -410,11 +450,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="red">
|
<object class="GtkButton" id="red_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Red</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/red.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="red_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="red_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Red</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/red.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -423,11 +473,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="magenta">
|
<object class="GtkButton" id="magenta_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Magenta</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/magenta.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="magenta_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="magenta_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Magenta</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/magenta.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -436,11 +496,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="purple">
|
<object class="GtkButton" id="purple_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Purple</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/purple.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="purple_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="purple_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Purple</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/purple.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -449,11 +519,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="brown">
|
<object class="GtkButton" id="brown_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Brown (please don't use this)</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/brown.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="brown_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="brown_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Brown (please don't use this)</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/brown.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -462,11 +542,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="gray">
|
<object class="GtkButton" id="gray_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Gray</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/gray.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="gray_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="gray_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Gray</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/gray.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<property name="width-request">700</property>
|
<property name="width-request">700</property>
|
||||||
<property name="height-request">535</property>
|
<property name="height-request">535</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="title" translatable="yes">Nobara Gnome Layouts</property>
|
<property name="title" translatable="yes">PikaOS Gnome Layouts</property>
|
||||||
<property name="default-width">700</property>
|
<property name="default-width">700</property>
|
||||||
<property name="default-height">535</property>
|
<property name="default-height">535</property>
|
||||||
<property name="show-menubar">False</property>
|
<property name="show-menubar">False</property>
|
||||||
@ -358,11 +358,21 @@
|
|||||||
<property name="valign">start</property>
|
<property name="valign">start</property>
|
||||||
<property name="homogeneous">True</property>
|
<property name="homogeneous">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="blue">
|
<object class="GtkButton" id="blue_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Blue</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../Downloads/accent/blue-svg.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="blue_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="blue_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Blue</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/blue.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -371,11 +381,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="green">
|
<object class="GtkButton" id="green_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Green</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../Downloads/accent/blue-svg.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="green_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="green_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Green</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/green.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -384,11 +404,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="yellow">
|
<object class="GtkButton" id="yellow_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Yellow</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../Downloads/accent/blue-svg.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="yellow_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="yellow_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Yellow</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/yellow.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -397,11 +427,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="orange">
|
<object class="GtkButton" id="orange_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Orange</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../Downloads/accent/blue-svg.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="orange_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="orange_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Orange</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/orange.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -410,11 +450,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="red">
|
<object class="GtkButton" id="red_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Red</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../Downloads/accent/blue-svg.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="red_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="red_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Red</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/red.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -423,11 +473,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="magenta">
|
<object class="GtkButton" id="magenta_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Magenta</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../Downloads/accent/blue-svg.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="magenta_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="magenta_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Magenta</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/magenta.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -436,11 +496,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="purple">
|
<object class="GtkButton" id="purple_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Purple</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../Downloads/accent/blue-svg.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="purple_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="purple_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Purple</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/purple.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -449,11 +519,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="brown">
|
<object class="GtkButton" id="brown_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Brown (please don't use this)</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../Downloads/accent/blue-svg.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="brown_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="brown_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Brown (please don't use this)</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/brown.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@ -462,11 +542,21 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage" id="gray">
|
<object class="GtkButton" id="gray_accent_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="tooltip-text" translatable="yes">Gray</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="pixbuf">../../../../../../../../Downloads/accent/blue-svg.svg</property>
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<signal name="pressed" handler="gray_accent_button_pressed_cb" swapped="no"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="gray_accent_image">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Gray</property>
|
||||||
|
<property name="pixbuf">../../../../../../../../../../usr/lib/pika/gnome-layouts/accent-colors/gray.svg</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
533
src/usr/lib/pika/gnome-layouts/papirus-folders
Executable file
533
src/usr/lib/pika/gnome-layouts/papirus-folders
Executable file
@ -0,0 +1,533 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# This script allows changing the color of folders in Papirus icon theme
|
||||||
|
#
|
||||||
|
# @author: Sergei Eremenko (https://github.com/SmartFinn)
|
||||||
|
# @license: MIT license (MIT)
|
||||||
|
# @link: https://github.com/PapirusDevelopmentTeam/papirus-folders
|
||||||
|
|
||||||
|
if test -z "$BASH_VERSION"; then
|
||||||
|
printf "Error: this script only works in bash.\n" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( BASH_VERSINFO[0] * 10 + BASH_VERSINFO[1] < 40 )); then
|
||||||
|
printf "Error: this script requires bash version >= 4.0\n" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set -x # Uncomment to debug this shell script
|
||||||
|
set -o errexit \
|
||||||
|
-o noclobber \
|
||||||
|
-o pipefail
|
||||||
|
|
||||||
|
readonly THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
||||||
|
readonly PROGNAME="$(basename "${BASH_SOURCE[0]}")"
|
||||||
|
readonly VERSION="1.12.0"
|
||||||
|
readonly -a ARGS=("$@")
|
||||||
|
|
||||||
|
msg() {
|
||||||
|
printf "%s: %b\n" "$PROGNAME" "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
verbose() {
|
||||||
|
[ -t 4 ] || return 0
|
||||||
|
msg "$@" >&4
|
||||||
|
}
|
||||||
|
|
||||||
|
err() {
|
||||||
|
msg "Error:" "$*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
_exit() {
|
||||||
|
msg "$*" "Exiting ..."
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fatal() {
|
||||||
|
err "$*"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<- EOF
|
||||||
|
USAGE
|
||||||
|
$ $PROGNAME [options] -t <theme> {-C --color} <color>
|
||||||
|
$ $PROGNAME [options] -t <theme> {-D --default}
|
||||||
|
$ $PROGNAME [options] -t <theme> {-R --restore}
|
||||||
|
OPERATIONS
|
||||||
|
-C --color <color> change color of folders
|
||||||
|
-D --default back to the default color
|
||||||
|
-R --restore restore the last used color from the config file
|
||||||
|
OPTIONS
|
||||||
|
-l --list show available colors
|
||||||
|
-o --once do not save the changes to the config file
|
||||||
|
-t --theme <theme> make changes to the specified theme (Default: Papirus)
|
||||||
|
-u --update-caches update icon caches for Papirus and siblings
|
||||||
|
-V --version print $PROGNAME version and exit
|
||||||
|
-v --verbose be verbose
|
||||||
|
-h --help show this help
|
||||||
|
EOF
|
||||||
|
|
||||||
|
exit "${1:-0}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_is_root_user() {
|
||||||
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
_is_user_dir() {
|
||||||
|
[ -n "$USER_HOME" ] || return 1
|
||||||
|
|
||||||
|
# if $THEME_DIR is placed in home dir
|
||||||
|
if [ -z "${THEME_DIR##"$USER_HOME"/*}" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
_is_writable() {
|
||||||
|
if [ -w "$THEME_DIR/48x48/places/folder.svg" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
_is_valid_color() {
|
||||||
|
local color="$1"
|
||||||
|
|
||||||
|
eval "$(declare_colors)"
|
||||||
|
|
||||||
|
for i in "${colors[@]}"; do
|
||||||
|
[ "$i" == "$color" ] || continue
|
||||||
|
return 0
|
||||||
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
declare_colors() {
|
||||||
|
local color=''
|
||||||
|
local -a colors=()
|
||||||
|
local -a valid_colors=("adwaita" "black" "blue" "bluegrey" "breeze" "brown"
|
||||||
|
"carmine" "cyan" "darkcyan" "deeporange" "green" "grey"
|
||||||
|
"indigo" "magenta" "nordic" "orange" "palebrown" "paleorange"
|
||||||
|
"pink" "purple" "red" "teal" "violet" "white" "yaru" "yellow")
|
||||||
|
|
||||||
|
for color in "${valid_colors[@]}"; do
|
||||||
|
if [ -e "$THEME_DIR/48x48/places/folder-$color.svg" ]; then
|
||||||
|
colors=( "${colors[@]}" "$color" )
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# return array of colors
|
||||||
|
declare -p colors
|
||||||
|
}
|
||||||
|
|
||||||
|
declare_current_color() {
|
||||||
|
local icon_file icon_name current_color=''
|
||||||
|
|
||||||
|
icon_file=$(readlink -f "$THEME_DIR/48x48/places/folder.svg")
|
||||||
|
icon_name=$(basename "$icon_file" .svg)
|
||||||
|
current_color="${icon_name##*-}"
|
||||||
|
|
||||||
|
declare -p current_color
|
||||||
|
}
|
||||||
|
|
||||||
|
get_theme_dir() {
|
||||||
|
local data_dir icons_dir
|
||||||
|
local -a data_dirs=()
|
||||||
|
local -a icons_dirs=(
|
||||||
|
"$USER_HOME/.icons"
|
||||||
|
"${XDG_DATA_HOME:-$USER_HOME/.local/share}/icons"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Get data directories from XDG_DATA_DIRS variable and
|
||||||
|
# convert colon-separated list into bash array
|
||||||
|
IFS=: read -ra data_dirs <<< "${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
|
||||||
|
|
||||||
|
for data_dir in "${data_dirs[@]}"; do
|
||||||
|
[ -d "$data_dir/icons" ] || continue
|
||||||
|
icons_dirs=( "${icons_dirs[@]}" "${data_dir%/}/icons" )
|
||||||
|
done
|
||||||
|
|
||||||
|
for icons_dir in "${icons_dirs[@]}"; do
|
||||||
|
[ -f "$icons_dir/$THEME_NAME/index.theme" ] || continue
|
||||||
|
printf '%s' "$icons_dir/$THEME_NAME"
|
||||||
|
verbose "'$THEME_NAME' is found in '$icons_dir'."
|
||||||
|
return 0
|
||||||
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
get_real_user() {
|
||||||
|
# return name of the user that runs the script
|
||||||
|
local user=''
|
||||||
|
|
||||||
|
if [ -n "$PKEXEC_UID" ]; then
|
||||||
|
user="$(id -nu "$PKEXEC_UID")"
|
||||||
|
elif [ -n "$SUDO_USER" ]; then
|
||||||
|
user="$SUDO_USER"
|
||||||
|
else
|
||||||
|
user="$(id -nu)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%s' "$user"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_user_home() {
|
||||||
|
local user="$1"
|
||||||
|
|
||||||
|
getent passwd "$user" | awk -F: '{print $(NF-1)}'
|
||||||
|
}
|
||||||
|
|
||||||
|
config() {
|
||||||
|
# usage: config [{-n --new}] {-s --set} key=value... | {-g --get} key...
|
||||||
|
local config_dir
|
||||||
|
local config_file
|
||||||
|
|
||||||
|
if _is_user_dir; then
|
||||||
|
config_dir="${XDG_CONFIG_HOME:-$USER_HOME/.config}/$PROGNAME"
|
||||||
|
else
|
||||||
|
config_dir="/var/lib/$PROGNAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
config_file="$config_dir/keep"
|
||||||
|
|
||||||
|
while (( "$#" )); do
|
||||||
|
case "$1" in
|
||||||
|
-g|--get) shift;
|
||||||
|
[ -f "$config_file" ] || return 1
|
||||||
|
|
||||||
|
for key; do
|
||||||
|
[ -n "$key" ] || continue
|
||||||
|
awk -F= -v key="$key" '
|
||||||
|
$1 == key {
|
||||||
|
print $2
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
' "$config_file"
|
||||||
|
done
|
||||||
|
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
-n|--new) shift;
|
||||||
|
rm -f "$config_file"
|
||||||
|
;;
|
||||||
|
-e|--exists) shift;
|
||||||
|
# return 1 if test config_file not exist or empty
|
||||||
|
if [ -f "$config_file" ] && [ -s "$config_file" ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-s|--set) shift;
|
||||||
|
[ "$ONCE" -eq "1" ] && break
|
||||||
|
[ -d "$config_dir" ] || mkdir -p "$config_dir"
|
||||||
|
[ -f "$config_file" ] || touch "$config_file"
|
||||||
|
|
||||||
|
verbose "Saving params to '$config_file' ..."
|
||||||
|
cat >> "$config_file" <<- EOF
|
||||||
|
$(for key_value; do echo "$key_value"; done)
|
||||||
|
EOF
|
||||||
|
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
err "illegal option -- '$1'"
|
||||||
|
return 1
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
change_color() {
|
||||||
|
local color="${1:?${FUNCNAME[-1]}: color is not set}"
|
||||||
|
local size prefix file_path file_name symlink_path
|
||||||
|
local -a sizes=(22x22 24x24 32x32 48x48 64x64)
|
||||||
|
local -a prefixes=("folder-$color" "user-$color")
|
||||||
|
|
||||||
|
for size in "${sizes[@]}"; do
|
||||||
|
for prefix in "${prefixes[@]}"; do
|
||||||
|
for file_path in "$THEME_DIR/$size/places/$prefix"{-*,}.svg; do
|
||||||
|
[ -f "$file_path" ] || continue # is a file
|
||||||
|
[ -L "$file_path" ] && continue # is not a symlink
|
||||||
|
|
||||||
|
file_name="${file_path##*/}"
|
||||||
|
symlink_path="${file_path/-$color/}" # remove color suffix
|
||||||
|
|
||||||
|
ln -sf "$file_name" "$symlink_path" || {
|
||||||
|
fatal "Fail to create '$symlink_path' symlink"
|
||||||
|
}
|
||||||
|
done
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
list_colors() {
|
||||||
|
local color='' prefix=''
|
||||||
|
|
||||||
|
eval "$(declare_colors)"
|
||||||
|
eval "$(declare_current_color)"
|
||||||
|
|
||||||
|
for color in "${colors[@]}"; do
|
||||||
|
if [ "$current_color" == "$color" ]; then
|
||||||
|
prefix='>'
|
||||||
|
else
|
||||||
|
prefix=''
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%2s %s\n' "$prefix" "$color"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
do_change_color() {
|
||||||
|
_is_valid_color "$SELECTED_COLOR" || {
|
||||||
|
fatal "Unable to find '$SELECTED_COLOR' color in '$THEME_NAME'"
|
||||||
|
}
|
||||||
|
|
||||||
|
verify_privileges
|
||||||
|
|
||||||
|
msg "Changing color of folders to '$SELECTED_COLOR' for '$THEME_NAME' ..."
|
||||||
|
change_color "$SELECTED_COLOR"
|
||||||
|
config --new --set "theme=$THEME_NAME" "color=$SELECTED_COLOR"
|
||||||
|
update_icon_cache
|
||||||
|
}
|
||||||
|
|
||||||
|
do_revert_default() {
|
||||||
|
verify_privileges
|
||||||
|
|
||||||
|
msg "Restoring default folder color for '$THEME_NAME' ..."
|
||||||
|
change_color "${DEFAULT_COLORS[$THEME_NAME]:-blue}"
|
||||||
|
config --new
|
||||||
|
update_icon_cache
|
||||||
|
}
|
||||||
|
|
||||||
|
do_restore_color() {
|
||||||
|
local saved_color=''
|
||||||
|
|
||||||
|
if config --exists; then
|
||||||
|
THEME_NAME="$(config --get theme)"
|
||||||
|
saved_color="$(config --get color)"
|
||||||
|
else
|
||||||
|
_exit "Unable to find config file."
|
||||||
|
fi
|
||||||
|
|
||||||
|
THEME_DIR="$(get_theme_dir)" || {
|
||||||
|
_exit "Unable to find '$THEME_NAME' icon theme."
|
||||||
|
}
|
||||||
|
|
||||||
|
_is_valid_color "$saved_color" || {
|
||||||
|
_exit "Unable to find '$saved_color' color in '$THEME_NAME'."
|
||||||
|
}
|
||||||
|
|
||||||
|
verify_privileges
|
||||||
|
|
||||||
|
change_color "$saved_color"
|
||||||
|
msg "'$saved_color' color of the folders has been restored."
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_icon_caches() {
|
||||||
|
local icon_cache real_user='' real_home=''
|
||||||
|
|
||||||
|
real_user="$(get_real_user)"
|
||||||
|
real_home="$(get_user_home "$real_user")"
|
||||||
|
|
||||||
|
declare -a icon_caches=(
|
||||||
|
# KDE 5 icon caches
|
||||||
|
"$real_home/.cache/icon-cache.kcache"
|
||||||
|
"/var/tmp/kdecache-$real_user/icon-cache.kcache"
|
||||||
|
)
|
||||||
|
|
||||||
|
verbose "Deleting icon caches ..."
|
||||||
|
for icon_cache in "${icon_caches[@]}"; do
|
||||||
|
[ -e "$icon_cache" ] || continue
|
||||||
|
rm -f "$icon_cache"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
update_icon_cache() {
|
||||||
|
[ -z "$DISABLE_UPDATE_ICON_CACHE" ] || return 0
|
||||||
|
|
||||||
|
delete_icon_caches
|
||||||
|
|
||||||
|
verbose "Rebuilding icon cache for '$THEME_NAME' ..."
|
||||||
|
gtk-update-icon-cache -qf "$THEME_DIR" || true
|
||||||
|
}
|
||||||
|
|
||||||
|
update_icon_caches() {
|
||||||
|
local theme=''
|
||||||
|
|
||||||
|
delete_icon_caches
|
||||||
|
|
||||||
|
for theme in "${!DEFAULT_COLORS[@]}"; do
|
||||||
|
[ -f "$THEME_DIR/../$theme/index.theme" ] || continue
|
||||||
|
verbose "Rebuilding icon cache for '$theme' ..."
|
||||||
|
gtk-update-icon-cache -qf "$THEME_DIR/../$theme" || true
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
verify_privileges() {
|
||||||
|
_is_root_user && return 0
|
||||||
|
_is_user_dir && return 0
|
||||||
|
_is_writable && return 0
|
||||||
|
|
||||||
|
verbose "This operation requires root privileges."
|
||||||
|
|
||||||
|
if command -v sudo > /dev/null; then
|
||||||
|
exec sudo USER_HOME="$USER_HOME" XDG_DATA_DIRS="$XDG_DATA_DIRS" \
|
||||||
|
"$THIS_SCRIPT" "${ARGS[@]}"
|
||||||
|
else
|
||||||
|
fatal "You need to be root to run this command."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_args() {
|
||||||
|
local arg='' opt=''
|
||||||
|
local -a args=()
|
||||||
|
|
||||||
|
# Show help if no argument is passed
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
usage 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Translate --gnu-long-options to -g (short options)
|
||||||
|
for arg; do
|
||||||
|
case "$arg" in
|
||||||
|
--help) args+=( -h ) ;;
|
||||||
|
--list) args+=( -l ) ;;
|
||||||
|
--once) args+=( -o ) ;;
|
||||||
|
--theme) args+=( -t ) ;;
|
||||||
|
--update-caches) args+=( -u ) ;;
|
||||||
|
--verbose) args+=( -v ) ;;
|
||||||
|
--color|--colour) args+=( -C ) ;;
|
||||||
|
--default) args+=( -D ) ;;
|
||||||
|
--restore) args+=( -R ) ;;
|
||||||
|
--version) args+=( -V ) ;;
|
||||||
|
--[0-9a-Z]*)
|
||||||
|
err "illegal option -- '$arg'"
|
||||||
|
usage 2
|
||||||
|
;;
|
||||||
|
*) args+=("$arg")
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Reset the positional parameters to the short options
|
||||||
|
set -- "${args[@]}"
|
||||||
|
|
||||||
|
while getopts ":C:DRlot:uvVh" opt; do
|
||||||
|
case "$opt" in
|
||||||
|
C ) OPERATIONS+=("change-color")
|
||||||
|
SELECTED_COLOR="$OPTARG"
|
||||||
|
;;
|
||||||
|
D ) OPERATIONS+=("revert-default") ;;
|
||||||
|
R ) OPERATIONS+=("restore-color") ;;
|
||||||
|
l ) OPERATIONS+=("list-colors") ;;
|
||||||
|
o ) ONCE=1 ;;
|
||||||
|
t ) THEME_NAME="$OPTARG" ;;
|
||||||
|
u ) OPERATIONS+=("update-icon-caches") ;;
|
||||||
|
v ) VERBOSE=1 ;;
|
||||||
|
V ) printf "%s %s\n" "$PROGNAME" "$VERSION"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
h ) usage 0 ;;
|
||||||
|
: ) err "option requires an argument -- '-$OPTARG'"
|
||||||
|
usage 2
|
||||||
|
;;
|
||||||
|
\?) err "illegal option -- '-$OPTARG'"
|
||||||
|
usage 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
# Return an error if any positional parameters are found
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
err "illegal parameter -- '$1'"
|
||||||
|
usage 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
# default values of options
|
||||||
|
declare THEME_NAME="${THEME_NAME:-Papirus}"
|
||||||
|
declare -i VERBOSE="${VERBOSE:-0}"
|
||||||
|
declare -i ONCE="${ONCE:-0}"
|
||||||
|
declare -A DEFAULT_COLORS=(
|
||||||
|
['ePapirus']='blue'
|
||||||
|
['Papirus']='blue'
|
||||||
|
['Papirus-Dark']='blue'
|
||||||
|
)
|
||||||
|
|
||||||
|
declare SELECTED_COLOR=''
|
||||||
|
declare -a OPERATIONS=()
|
||||||
|
|
||||||
|
parse_args "${ARGS[@]}"
|
||||||
|
|
||||||
|
if [ "$VERBOSE" -eq "1" ]; then
|
||||||
|
# open a file descriptor for verbose messages
|
||||||
|
exec 4>&1
|
||||||
|
# close the file descriptor before exiting
|
||||||
|
trap 'exec 4>&-' EXIT HUP INT TERM
|
||||||
|
fi
|
||||||
|
|
||||||
|
# set USER_HOME variable instead HOME to prevent changing user's icons
|
||||||
|
# when running with sudo
|
||||||
|
[ -n "$USER_HOME" ] || USER_HOME="$(get_user_home "$(id -nu)")"
|
||||||
|
|
||||||
|
if [ -f "$THEME_NAME/index.theme" ]; then
|
||||||
|
# THEME_NAME is a path to an icon theme
|
||||||
|
THEME_DIR="$(readlink -f "$THEME_NAME")"
|
||||||
|
THEME_NAME="$(basename "$THEME_DIR")"
|
||||||
|
verbose "The path to '$THEME_DIR' theme is specified."
|
||||||
|
else
|
||||||
|
THEME_DIR="$(get_theme_dir)" || {
|
||||||
|
fatal "Fail to find '$THEME_NAME' icon theme."
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
for operation in "${OPERATIONS[@]}"; do
|
||||||
|
case "$operation" in
|
||||||
|
change-color)
|
||||||
|
do_change_color
|
||||||
|
;;
|
||||||
|
revert-default)
|
||||||
|
do_revert_default
|
||||||
|
;;
|
||||||
|
restore-color)
|
||||||
|
do_restore_color
|
||||||
|
;;
|
||||||
|
list-colors)
|
||||||
|
if [ -t 1 ]; then
|
||||||
|
cat <<- EOF
|
||||||
|
List of available colors:
|
||||||
|
$(list_colors)
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
list_colors
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
update-icon-caches)
|
||||||
|
verify_privileges
|
||||||
|
update_icon_caches
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
verbose "Done!"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
|
|
||||||
|
exit 1
|
Loading…
x
Reference in New Issue
Block a user