wustho / epy

CLI Ebook (epub2, epub3, fb2, mobi) Reader
GNU General Public License v3.0
962 stars 52 forks source link

Startup color scheme #30

Open poetaman opened 3 years ago

poetaman commented 3 years ago

Hi, I like to read in dark or light color scheme. Currently there is a way to specify colors for the color schemes, but no way to select what color scheme to load while starting epy.

So, what I am asking for is a command like option --theme [dark|light] or a config option "Theme":"dark".

wustho commented 3 years ago

Ah, that is good idea, I should've thought that, I will try when I have the occasion. For now, maybe you can switch the dark and light color number in config file? Like, so default:

    "DarkColorFG": 252,
    "DarkColorBG": 235,
    "LightColorFG": 238,
    "LightColorBG": 253,

then exchange them light and dark value become:

    "DarkColorFG": 238,
    "DarkColorBG": 253,
    "LightColorFG": 252,
    "LightColorBG": 235,
wustho commented 3 years ago

Ah, sorry I just remember there is actually 3 colorschemes: default (transparent bg), dark and light. So, workaround above won't work. Will look for better alternative next time.

wustho commented 2 years ago

@reportaman hey there, just add this options: https://github.com/wustho/epy/commit/16a6ba5c634eefb832a4bfcf5c0d2f2742c667b1

But you may need to delete older config and reading state in ~/.config/epy which means you will lose reading progress sorry.

poetaman commented 2 years ago

@wustho On the latest commit I get:

Traceback (most recent call last):
  File "/usr/local/bin/epy", line 3785, in <module>
    main()
  File "/usr/local/bin/epy", line 3777, in main
    filepath = parse_cli_args()
  File "/usr/local/bin/epy", line 3673, in parse_cli_args
    last_read_in_history = app_state.get_last_read()
  File "/usr/local/bin/epy", line 1437, in get_last_read
    library = self.get_from_history()
  File "/usr/local/bin/epy", line 1405, in get_from_history
    cur.execute(
sqlite3.OperationalError: no such table: library
wustho commented 2 years ago

@reportaman ah sorry for that, there is major change in schema in lastest version, so you might need to delete states file in ~/.config/epy/states.db. sorry you might also lose your reading progress...

poetaman commented 2 years ago

@wustho Now for the latest commit, I get this error:

Traceback (most recent call last):
  File "/opt/homebrew/bin/epy", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 3969, in main
    filepath = curses.wrapper(preread, filepath)
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 3867, in preread
    reading_state_or_ebook = reader.read(reading_state)
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 3172, in read
    self.try_assign_letters_count(force_wait=True)
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 2433, in try_assign_letters_count
    self._process_counting_letter.join()
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 148, in join
    assert self._popen is not None, 'can only join a started process'
AssertionError: can only join a started process
wustho commented 2 years ago

@reportaman Hey there just fixed this issue with: https://github.com/wustho/epy/commit/b388412cb799fe439ea8424d9b5960d5cf5889b0 You can try upgrade epy via pypi.

Btw, that issue is kinda bit unexpected and might be machine related issue. Can you try running epy with:

DEBUG=1 epy

and post the error here? Thanks

poetaman commented 2 years ago

It was the same error traceback with DEBUG=1 epy ~/path/to/file.epub prior to upgrading, and message ERROR: Found no last read ebook file. with DEBUG=1 epy (without file name), also prior to upgrading.

After upgrading, the original error seems to have gone. But with DEBUG=1 epy I now get:

❯ DEBUG=1 epy
Traceback (most recent call last):
  File "/opt/homebrew/bin/epy", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 3971, in main
    filepath = curses.wrapper(preread, filepath)
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 3860, in preread
    reader.run_counting_letters()
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 2427, in run_counting_letters
    raise e
  File "/opt/homebrew/lib/python3.9/site-packages/epy.py", line 2424, in run_counting_letters
    self._process_counting_letter.start()
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 47, in _launch
    reduction.dump(process_obj, fp)
  File "/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle '_io.BufferedReader' object
wustho commented 2 years ago

Ah, sure thanks @reportaman. It should be fixed now, DEBUG=1 is just utilities made to see more what happening under the hood. You can just start epy normally (without DEBUG=1).

poetaman commented 2 years ago

@wustho Thanks! Also, it would be nice for color to be a hex value instead of 256 colors. That way a terminal that supports more colors can leverage more colors.