turing-smart-screen-python icon indicating copy to clipboard operation
turing-smart-screen-python copied to clipboard

Multiple disks support

Open smandon opened this issue 1 year ago • 4 comments

Hi,

I made some modifications to add support for multiple disks/partitions, by adding the possibility to set multiple disks in the stats section of the theme.yaml, each referenced by its mount point (e.g. drive letter on windows).

Unfortunately, it forces changes to the theme.yaml format that breaks compatibility with previous versions.

I changed the sensors disk functions to add a "path" parameter that is used with psutil.disk_usage. Stats was modified to add the mountpoint from theme.yaml in the disk functions calls. It also checks if the mount points path exists each time the stats() method is called, which for now spams the logs with a warning, maybe this could be handled better, but at least the program wouldn't crash if a disk/partition becomes unavailable or is unmounted. The config's load_theme function had to be adapted to handle default values for disks via a seperate "default_disk.yaml" file.

All the default themes were modified accordingly, using "/" as mount point, as it was the case so far. I think that it should work on all platforms, I tested only on windows.

Pay attention to the theme.yaml, for each disk definition there is a necessary double indent, due to a subtlety of the yaml format.

smandon avatar May 14 '23 15:05 smandon

Hello, Thanks for this PR, I like the idea of being able to display multiple partitions, but I don't want to integrate breaking changes to theme.yaml format considering all the community themes people made and shared. The best way would be to avoid removing or changing entries, if not possible the python program should at least still allow and process old theme format.

Maybe the code in stats.pycould be changed to something like this to keep compatibility :

        if config.THEME_DATA['STATS']['DISK'].get("MOUNTS", False):
            for mount in config.THEME_DATA['STATS']['DISK']['MOUNTS']:
                mountpoint = [k for k, v in mount.items()][0]
                _display_partition(mountpoint=mountpoint, theme_data=mount[mountpoint])    # A new function where you check if the mountpoint exist and then display it
        else:
            _display_partition(mountpoint="/", theme_data=config.THEME_DATA['STATS']['DISK'])

Please note I did not test this code.

mathoudebine avatar Jun 09 '23 11:06 mathoudebine

I would love to have this feature and try the code out but unfortunately the code in stats.py was changed a lot in v3.4.0 and im not that good in programming to adjust the code myself. If someone could change the code, you could count on me for testing!

NurNano avatar Mar 28 '24 07:03 NurNano