Enable Night mode from CLI (Ubuntu)

Last year in my Ubuntu I enabled auto night mode, but some times I need to disable it.
Every time I use the keyboard and I don’t like to use the mouse when I typing with the keyboard.
I memorized most of the shortcuts in gnome and vim and use it.
For example, when I want to open Firefox, instead of click on Activities and find Firefox icons in favourites icons, I use ALT+F2 then type
firefox example.com
Or to run play 2pac music type
2pac
Only disable and enable night mode was my trouble, sometimes when I change my web site CSS, I cannot saw the real colour, And I must disable night mode.
so I googled “How to enable Ubuntu night mode from CLI” and find these results(I cannot find which site I found these commands, because I found it in Jan 2018):
Enable night light #ubuntu from CLI:
$ gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true
to disable:
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled false
Oh my God, these are too long for typing.
I used alias instead these commands:
$ echo -e “\n alias nightmode=’gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true’” >> ~/.bashrc
$ echo -e “\n alias daymode=’gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled false’” >> ~/.bashrc
$ source ~./bashrc
But these commands (nightmode, daymode) only worked in terminal, I knew aliases not work in ALT+F2 box, so I used commands into files in bin directory:
$ sudo echo 'gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true' > /usr/bin/nightmode
$ sudo chmod +x /usr/bin/nightmode
$ sudo echo 'gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled false' > /usr/bin/daymode
$ sudo chmod +x /usr/bin/daymode
I hope this trick is helpful for You ;)


