Giter Site home page Giter Site logo

blugon's Introduction

blugon

A simple and configurable Blue Light Filter for X

AUR License

blugon is a simple and fast Blue Light Filter, that is highly configurable and provides a command line interface. The program can be run just once or as a daemon (manually or via systemd). There are several different backends available. blugon calculates the screen color from your local time and configuration.

blugon-comparison blugon-simulation

Comparison to other Blue Light Filters

blugon's main feature is the ability to control gamma values or color temperature at specific times of day.

blugon Redshift f.lux
written in Python C closed source
interface CLI CLI or GUI GUI
timing configuration user defined day and night day and night
gamma configuration RGB values or temperature temperature temperature
brightness configuration none none none

Usage

You can start blugon from the command line:

blugon

To run it in the background just use:

(blugon&)         # to start
killall blugon    # to stop

To run blugon with systemd you can enable the service as user:

systemctl --user enable blugon.service

You can use the current-mode to manually control color temperature (with keybinds for example; doesn't need daemon):

blugon --setcurrent="+600"    # for more blue
blugon --setcurrent="-600"    # for more red

For further help you can use the -h flag or the more intensive man-page:

man blugon

Options:

  • -o or --once to apply gamma values of the current time
  • -S or --setcurrent to set or change the current color temperature
  • -s or --simulation to quickly simulate the configuration for the whole day
  • -f or --fade to fade in screen color on startup
  • -i [secs] or --interval=[secs] to set time between refreshes
  • -c [path] or --configdir=[path] to specify configuration directory
  • -b [backend] or --backend=[backend] to choose the backend for communication with X

available backends:

  • xgamma - most compatible, requires optional dependency
  • scg - best result
  • tty - to run blugon on your TTY

Configuration

Examples for configurations can be found in /usr/share/blugon/configs/.

To use the default configuration as a template you can use:

mkdir -p ~/.config/blugon/
cp /usr/share/blugon/configs/default/gamma ~/.config/blugon/gamma
blugon --printconfig > ~/.config/blugon/config

Dependencies

  • python
  • libx11
  • libxrandr

optional:

  • xorg-xgamma as backend

Install

ArchLinux

There is an AUR-Package.

Nix

You can use the derivation from this nix-expression in nixpkgs.

from source

If you are on Linux you can build and install:

make
make install    # as root

To change the target directory of the installation use the following and change /usr/local to the desired directory:

make PREFIX=/usr/local
make install PREFIX=/usr/local

Configuration is supposed to be done after installing.

Contributing

Feel free to Fork, create Issues and make Pull Requests.

I am looking forward to finding Package Maintainers and will happily accept improvements in the source code.

blucontrol

A lot of functionality is being rewritten in blucontrol. If you have some Haskell knowledge feel free to try it out.

What it provides is fully functional, just the documentation is lacking.

blugon's People

Contributors

badeaffe avatar jumper149 avatar r-burns avatar temporaryrespite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

blugon's Issues

[scg] XCloseDisplay could be called before normal exit

from man 3 XCloseDisplay

The XCloseDisplay function closes the connection to the X server for
the display specified in the Display structure ...
...
Before exiting, you should call XCloseDisplay explicitly so that any pending
errors are reported as XCloseDisplay performs a final XSync operation.

an XRRFreeScreenResources might be nice too, so something like the following:

diff --git a/backends/scg/scg.c b/backends/scg/scg.c
index 57951dc..f152a80 100644
--- a/backends/scg/scg.c
+++ b/backends/scg/scg.c
@@ -41,14 +41,16 @@ int main(int argc, char **argv) {
 			crtc_gamma->green[i] = g * gamma_g;
 			crtc_gamma->blue[i]  = g * gamma_b;
 		}
 		XRRSetCrtcGamma(dpy, crtcxid, crtc_gamma);
 
 		XFree(crtc_gamma);
 	}
+	XRRFreeScreenResources(res);
+	XCloseDisplay(dpy);
 	return 0;
 }
 
 /*
  * This program is based on 'sct'.
  * Source: https://https.www.google.com.tedunangst.com/flak/post/sct-set-color-temperature
  *         https://https.www.google.com.tedunangst.com/flak/files/sct.c

How to check if blugon light-filter is running?

I'm trying to make a script that turns on and off blugon, and for that I need to check whether the light-filter is applied or not. Problem is, blugon's process is already dead milisecond later is executed, so there's no process to check. There is other method to tell the filter is up? I'm using the svg backend, and started blugon with an autostart.sh script

error with compiling of blugon.py

When I try to run blugon.py the error appears

Traceback (most recent call last):
  File "C:\Users\astrosander\Desktop\blugon-1.12.1\blugon.py", line 43, in <module>
    CONFIG_DIR = getenv('HOME') + '/.config'
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
[Finished in 92ms]

How can I solve it
(Windows 11)

FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.config/blugon/current'

$ /usr/bin/blugon -r
Traceback (most recent call last):
  File "/usr/bin/blugon", line 327, in read_current
    file_current = open(CONFIG_FILE_CURRENT, 'r')
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/.config/blugon/current'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/blugon", line 555, in <module>
    main()
  File "/usr/bin/blugon", line 486, in main
    CURRENT = read_current()
  File "/usr/bin/blugon", line 331, in read_current
    'To create this file use:\n' + '    blugon --setcurrent=' + str(NORMAL_TEMP))
ValueError: current configuration file not found at:
    /home/user/.config/blugon/current

To create this file use:
    blugon --setcurrent=6600.0
$ /usr/bin/blugon -p
[main]
readcurrent = False
interval = 120
backend = scg
wait_for_x = False
fade = False

[current]
min_temp = 1.0
max_temp = 20000.0

[wait_for_x]
sleep_after_failed_startup = 0.1
sleep_after_losing_x = 120.0

[fade]
steps = 10
duration = 3.0

[tty]
color0 = 000000
color1 = aa0000
color2 = 00aa00
color3 = aa5500
color4 = 0000aa
color5 = aa00aa
color6 = 00aaaa
color7 = aaaaaa
color8 = 555555
color9 = ff5555
color10 = 55ff55
color11 = ffff55
color12 = 5555ff
color13 = ff55ff
color14 = 55ffff
color15 = ffffff

$ blugon -V
Using gamma configuration file: '/home/user/.config/blugon/gamma'
Using fallback gamma configuration file: '/usr/share/blugon/configs/default/gamma'
Provide current minute 54.35
Calculated RGB Gamma values: 1.0 0.806038888888889 0.5701296296296297
Calling backend scg
Wait for 120 seconds

commit a77a202 (HEAD -> makepkg, origin/master, origin/HEAD, master)

exit code 11 aka (silent)segfault when backend scg is used on tty, or DISPLAY isn't set on X

Because dpy here[1] will be null when running eg. blugon -b scg -r -o:
[1]

Display *dpy = XOpenDisplay(NULL);

and there's no check & graceful exit.
The exit code for the above command is 11, but when running scg backend directly, on tty(rather than inside X), the segfault can be seen, eg.:
/lib/blugon/scg 1.0 0.6949030005552019 0.4310480202110507

$ /lib/blugon/scg 1.0 0.6949030005552019 0.4310480202110507
[ 1627.389262] scg[93373]: segfault at e0 ip 000055e14ea4d0dd sp 00007ffca8ec6e00 error 4 in scg[55e14ea4d000+1000]
[ 1627.390830] Code: 00 00 00 00 00 00 00 00 00 00 00 00 00 41 57 41 56 41 55 49 89 f5 41 54 55 89 fd 31 ff 53 48 83 ec 28 e8 a6 ff ff ff 48 89 c3 <48> 63 80 e0 00 00 00 48 89 df 48 c1 e0 07 48 03 83 e8 00 00 00 48
[ 1627.392435] potentially unexpected fatal signal 11.
[ 1627.394046] CPU: 1 PID: 93373 Comm: scg Kdump: loaded Tainted: G          I       5.4.10-g7a02c193298e #46

[ 1627.397178] RIP: 0033:0x55e14ea4d0dd
[ 1627.398696] Code: 00 00 00 00 00 00 00 00 00 00 00 00 00 41 57 41 56 41 55 49 89 f5 41 54 55 89 fd 31 ff 53 48 83 ec 28 e8 a6 ff ff ff 48 89 c3 <48> 63 80 e0 00 00 00 48 89 df 48 c1 e0 07 48 03 83 e8 00 00 00 48
[ 1627.400266] RSP: 002b:00007ffca8ec6e00 EFLAGS: 00010202
[ 1627.401848] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000090
[ 1627.403418] RDX: 0000000000000080 RSI: 00007ffca8ec6f48 RDI: 00007ff2eb6f5090
[ 1627.404968] RBP: 0000000000000004 R08: 0000000000000000 R09: 0000000000000000
[ 1627.406527] R10: 000055e14ea4c52c R11: 00007ff2eb680840 R12: 000055e14ea4d280
[ 1627.408031] R13: 00007ffca8ec6f48 R14: 0000000000000000 R15: 0000000000000000
[ 1627.409483] FS:  00007ff2eb414d80 GS:  0000000000000000
[ 1627.423791] systemd[1]: Started Process Core Dump (PID 93385/UID 0).
Segmentation fault (core dumped)
[ 1627.938066] systemd-coredump[93393]: Process 93373 (scg) of user 1000 dumped core.
[ 1627.938066]
[ 1627.938066] Stack trace of thread 93373:
[ 1627.938066] #0  0x000055e14ea4d0dd main (scg + 0x10dd)
[ 1627.938066] #1  0x00007ff2eb49e1b6 __libc_start_main (libc.so.6 + 0x271b6)
[ 1627.938066] #2  0x000055e14ea4d2ae _start (scg + 0x12ae)
[ 1627.938066]
[ 1627.948951] systemd[1]: [email protected]: Succeeded.

or this can also reproduce it:

$ DISPLAY= /lib/blugon/scg 1.0 0.6949030005552019 0.4310480202110507
Segmentation fault (core dumped)

$ DISPLAY= blugon -b scg -r -o; echo "exit code:$?"
exit code:11

I didn't want to make a PR for this because i don't know how you want this handled (if ever), but the idea is something like this:

///...
#include <stdio.h>      /* fprintf */
///...
  Display *dpy = XOpenDisplay(NULL);
  //If XOpenDisplay does not succeed, it returns NULL.
  if (NULL == dpy) {
    fprintf(stderr, "X is not running? or cannot open a connection to it. Is DISPLAY env var set?\n");
    return 1; // exit code 1
  }

Cannot kill blugon

I installed blugon using yay on Arch with Xorg and i3-gaps. I can't stop it.

~ $ blugon
^C (ctrl+c)
~ $ killall blugon
blugon: no process found
~ $ kill blugon
kill: illegal pid: blugon

ps -x, ps aux, gotop can't find the blugon. Blue filter is still enabled.

Blugon's filter keeps reverting

I use sxhkd and use key binding for blugon
blugon --setcurrent="+100"
and
blugon --setcurrent="-100"

The command works initially but after a short moment it reverts back and I have to use the command again via bindings.
Any help on how to make the command work permanently would be appreciated.

Compatibility with xscreensaver

At present and with default config, xscreensaver disables blugon when a screensaver is activated. Is there a way to have blugon run on top of screensavers?

Issues with installing blugon

Hi,

I had blugon intalled and working fine on linux mint but after re-installing my linux mint I don't seem to be able to install blugon again.
Here is the error I get:

~/blugon$ make
sed "s|MAKE_INSTALL_PREFIX = '.*'|MAKE_INSTALL_PREFIX = '/usr'|g" blugon.py > blugon
sed "s|MAKE_INSTALL_PREFIX|/usr|g" systemd/user/blugon.service > blugon.service
gzip --best --force --keep blugon.1
cd backends/scg && make build
make[1]: Entering directory '/home/flo/blugon/backends/scg'
gcc -O2 -std=c11 -D_POSIX_C_SOURCE=200809L -Wall -Wextra -Wpedantic -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXrandr -o scg scg.c
scg.c:1:10: fatal error: errno.h: No such file or directory
 #include <errno.h>
          ^~~~~~~~~
compilation terminated.
Makefile:7: recipe for target 'build' failed
make[1]: *** [build] Error 1
make[1]: Leaving directory '/home/flo/blugon/backends/scg'
Makefile:5: recipe for target 'build' failed
make: *** [build] Error 2

I have tried with a older release (1.11.4) but I get the same mistake... I'm quite puzzled because it was working just fine before...
Any idea what I could try?

Thank you!

Can this run without X?

I wanted to inquire whether Blugon can be used without X in the Linux console? As far as I understand, Blugon is similar to Redshift and adjusts the color temperature of the screen based on the time of day. However, I am currently using Linux without X and was wondering if Blugon could still function properly.

Thank you for your response in advance!

Systemd service error : "Failed to start... start request repeated too quickly"

Hello, just to let people know about fixing this issue.
Just after run systemctl --user enable blugon.service, at reboot, the service didn't start, giving (on systemctl --user status...) this error message telling "start request repeated too quickly". To fix it:

edit the service file (~/.config/systemd///blugon.service) and change the line RestartSec=0 to a slower value ; I put mine to 15 sec (RestartSec=15).

Now everything is working fine!
Thanks jumper for this light and efficient little programm !

blugon.service: Main process exited, code=exited, status=11/n/a

I noticed that the blugon service wasn't running after reboot. journalctl showed

-- Reboot --
Jan 16 18:02:03 archlinux systemd[1029]: Started Blue Light Filter.
Jan 16 18:02:04 archlinux systemd[1029]: blugon.service: Main process exited, code=exited, status=11/n/a
Jan 16 18:02:04 archlinux systemd[1029]: blugon.service: Failed with result 'exit-code'.
Jan 16 18:02:04 archlinux systemd[1029]: blugon.service: Service RestartSec=100ms expired, scheduling restart.
Jan 16 18:02:04 archlinux systemd[1029]: blugon.service: Scheduled restart job, restart counter is at 1.
Jan 16 18:02:04 archlinux systemd[1029]: Stopped Blue Light Filter.

The following 4 tries failed the same way.

I installed blugon using the AUR, and I'm using X, lightdm and awesomeWM.
Starting the service manually works fine.

"Failed to connect to bus" and "Failed to enable unit"

Hello!

I am on Manjaro 18.1 and I have installed blugon from the Arch AUR.
When I try to enable the blugon service only for the user, I get the following:

$ sudo systemctl --user enable blugon.service
Failed to connect to bus: No such file or directory

When I try to enable blugon system-wide, I get the following:
$ sudo systemctl enable blugon.service
Failed to enable unit: Unit file blugon.service does not exist.

Please let me know what else do you need to investigate this issue.

Thanks!

undefined reference to `XOpenDisplay'

Whenever I run the make file in the directory, I am encountering this issue : undefined reference to `XOpenDisplay' for the file scg.c. I tried manually linking lX11, still the issue persists. I am running Ubuntu 20.04.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.