I frequently end up doing ~5 different manual actions when switching between using my laptop in dark environments and light environments, one of which is clicking Turn all styles off
in the Stylish extension toolbar button to disable my dark user styles. I'd like to automate this somehow, probably a script bound to a hotkey. Is there a way to have the same effect as clicking Turn all styles off
through the command line or some other way to accomplish this goal? I'm using Stylish in Chrome on Ubuntu.
Asked
Active
Viewed 377 times
0

Ross Patterson
- 5,702
- 20
- 38
-
1Go to Chrome settings, extensions, keyboard shortcuts, Stylish, and assign a hotkey. I'm using Alt-X. – wOxxOm Sep 24 '16 at 06:20
-
@wOxxOm I did not know about that, thanks! Is there any way to "trigger" that from a script or otherwise accomplish the goal above? – Ross Patterson Sep 24 '16 at 06:34
-
Try googling. What I know is it's easy to send hotkeys on Windows. – wOxxOm Sep 24 '16 at 06:41
-
Check out our [Stylish-Toggle](https://github.com/StylishThemes/Stylish-Toggle) userscript. It only works in Chrome. – Mottie Sep 24 '16 at 14:06
-
@Mottie I don't see from the README at that link how it would help accomplish my goal? – Ross Patterson Sep 24 '16 at 19:01
-
It shows how to disable styles programmatically from inside the browser regardless of a hotkey. – wOxxOm Sep 24 '16 at 20:12
-
Yes, essentially, it uses this selector `style.stylish[id*=stylish]` and disables or enables those stylesheets. – Mottie Sep 24 '16 at 20:27
1 Answers
0
My findings are that there isn't any way to change chrome extension settings from the command line and that the best way to do this is to set a key binding per @wOxxOm's comment and to use xdotool
to send the keystrokes to chrome. There are a lot of gotchas in getting this to work. This is the final command I ended up using:
xdotool search --class 'google-chrome' windowactivate --sync \
key --window 0 --clearmodifiers 'ctrl+shift+5'
Chrome doesn't accept the keystrokes if it's not active, so use windowactivate --sync
first. It seems that Chrome ignores XTEST
events so use --window 0
to force xdotool
to use XSendEvent
instead. Finally, I had to use --clearmodifiers
because I have Caps_Lock
and Control_L
swapped.

Community
- 1
- 1

Ross Patterson
- 5,702
- 20
- 38