changed setting loading

This commit is contained in:
itdominator 2021-09-03 22:57:00 -05:00
parent eec1eb4822
commit caec383da1
17 changed files with 66 additions and 26 deletions

View File

@ -15,6 +15,7 @@ class Window:
self.id = "" self.id = ""
self.name = "" self.name = ""
self.nickname = "" self.nickname = ""
self.isHidden = False
self.views = [] self.views = []
self.generate_id() self.generate_id()

View File

@ -13,14 +13,13 @@ class WindowController:
def __init__(self): def __init__(self):
USER_HOME = path.expanduser('~') USER_HOME = path.expanduser('~')
CONFIG_PATH = USER_HOME + "/.config/pyfm" CONFIG_PATH = USER_HOME + "/.config/pyfm"
self.config_file = CONFIG_PATH + "/session.json" self.session_file = CONFIG_PATH + "/session.json"
self.active_window_id = "" self.active_window_id = ""
self.active_tab_id = "" self.active_tab_id = ""
self.windows = [] self.windows = []
def set_active_data(self, wid, tid): def set_active_data(self, wid, tid):
self.active_window_id = str(wid) self.active_window_id = str(wid)
self.active_tab_id = str(tid) self.active_tab_id = str(tid)
@ -111,8 +110,8 @@ class WindowController:
print(f"\nID: {window.id}") print(f"\nID: {window.id}")
print(f"Name: {window.name}") print(f"Name: {window.name}")
print(f"Nickname: {window.nickname}") print(f"Nickname: {window.nickname}")
print(f"Is Hidden: {window.isHidden}")
print(f"View Count: {window.get_views_count()}") print(f"View Count: {window.get_views_count()}")
print("\n-------------------------\n") print("\n-------------------------\n")
@ -150,16 +149,17 @@ class WindowController:
"ID": window.id, "ID": window.id,
"Name": window.name, "Name": window.name,
"Nickname": window.nickname, "Nickname": window.nickname,
"isHidden": window.isHidden,
'views': views 'views': views
} }
} }
] ]
) )
with open(self.config_file, 'w') as outfile: with open(self.session_file, 'w') as outfile:
json.dump(windows, outfile, separators=(',', ':'), indent=4) json.dump(windows, outfile, separators=(',', ':'), indent=4)
def load_state(self): def load_state(self):
if path.isfile(self.config_file): if path.isfile(self.session_file):
with open(self.config_file) as infile: with open(self.session_file) as infile:
return json.load(infile) return json.load(infile)

View File

@ -1,4 +1,5 @@
# System import # System import
import json
import os import os
from os import path from os import path
@ -11,17 +12,12 @@ from os import path
class Settings: class Settings:
logger = None logger = None
lock_folder = False
go_past_home = True
GTK_ORIENTATION = 1 # HORIZONTAL (0) VERTICAL (1)
ABS_THUMBS_PTH = None # Used for thumbnail generation and is set by passing in
REMUX_FOLDER = None # Used for Remuxed files and is set by passing in
FFMPG_THUMBNLR = None # Used for thumbnail generator binary and is set by passing in
HIDE_HIDDEN_FILES = True
USER_HOME = path.expanduser('~') USER_HOME = path.expanduser('~')
CONFIG_PATH = USER_HOME + "/.config/pyfm" CONFIG_PATH = USER_HOME + "/.config/shellfm"
CONFIG_FILE = CONFIG_PATH + "/settings.json"
GTK_ORIENTATION = 1 # HORIZONTAL (0) VERTICAL (1)
DEFAULT_ICONS = CONFIG_PATH + "/icons" DEFAULT_ICONS = CONFIG_PATH + "/icons"
DEFAULT_ICON = DEFAULT_ICONS + "/text.png" DEFAULT_ICON = DEFAULT_ICONS + "/text.png"
FFMPG_THUMBNLR = CONFIG_PATH + "/ffmpegthumbnailer" # Thumbnail generator binary FFMPG_THUMBNLR = CONFIG_PATH + "/ffmpegthumbnailer" # Thumbnail generator binary
@ -36,17 +32,42 @@ class Settings:
VIDEO_ICON_WH = [128, 64] VIDEO_ICON_WH = [128, 64]
SYS_ICON_WH = [56, 56] SYS_ICON_WH = [56, 56]
subpath = "" # modify 'home' folder path # CONTAINER_ICON_WH = [128, 128]
locked_folders = "venv::::flasks".split("::::") # VIDEO_ICON_WH = [96, 48]
mplayer_options = "-quiet -really-quiet -xy 1600 -geometry 50%:50%".split() # SYS_ICON_WH = [96, 96]
music_app = "/opt/deadbeef/bin/deadbeef"
media_app = "mpv" subpath = ""
image_app = "mirage" go_past_home = None
office_app = "libreoffice" lock_folder = None
pdf_app = "evince" locked_folders = None
text_app = "leafpad" mplayer_options = None
file_manager_app = "spacefm" music_app = None
remux_folder_max_disk_usage = "8589934592" media_app = None
image_app = None
office_app = None
pdf_app = None
text_app = None
file_manager_app = None
remux_folder_max_disk_usage = None
if path.isfile(CONFIG_FILE):
with open(CONFIG_FILE) as infile:
settings = json.load(infile)["settings"]
subpath = settings["base_of_home"]
HIDE_HIDDEN_FILES = True if settings["hide_hidden_files"] == "true" else False
go_past_home = True if settings["go_past_home"] == "true" else False
lock_folder = True if settings["lock_folder"] == "true" else False
locked_folders = settings["locked_folders"].split("::::")
mplayer_options = settings["mplayer_options"].split()
music_app = settings["music_app"]
media_app = settings["media_app"]
image_app = settings["image_app"]
office_app = settings["office_app"]
pdf_app = settings["pdf_app"]
text_app = settings["text_app"]
file_manager_app = settings["file_manager_app"]
remux_folder_max_disk_usage = settings["remux_folder_max_disk_usage"]
# Filters # Filters
fvideos = ('.mkv', '.avi', '.flv', '.mov', '.m4v', '.mpg', '.wmv', '.mpeg', '.mp4', '.webm') fvideos = ('.mkv', '.avi', '.flv', '.mov', '.m4v', '.mpg', '.wmv', '.mpeg', '.mp4', '.webm')

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 858 B

After

Width:  |  Height:  |  Size: 858 B

View File

Before

Width:  |  Height:  |  Size: 850 B

After

Width:  |  Height:  |  Size: 850 B

View File

Before

Width:  |  Height:  |  Size: 702 B

After

Width:  |  Height:  |  Size: 702 B

View File

Before

Width:  |  Height:  |  Size: 925 B

After

Width:  |  Height:  |  Size: 925 B

View File

Before

Width:  |  Height:  |  Size: 882 B

After

Width:  |  Height:  |  Size: 882 B

View File

Before

Width:  |  Height:  |  Size: 707 B

After

Width:  |  Height:  |  Size: 707 B

View File

Before

Width:  |  Height:  |  Size: 798 B

After

Width:  |  Height:  |  Size: 798 B

View File

Before

Width:  |  Height:  |  Size: 989 B

After

Width:  |  Height:  |  Size: 989 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,18 @@
{
"settings": {
"base_of_home": "",
"hide_hidden_files": "true",
"go_past_home": "true",
"lock_folder": "false",
"locked_folders": "venv::::flasks",
"mplayer_options": "-quiet -really-quiet -xy 1600 -geometry 50%:50%",
"music_app": "/opt/deadbeef/bin/deadbeef",
"media_app": "mpv",
"image_app": "mirage",
"office_app": "libreoffice",
"pdf_app": "evince",
"text_app": "leafpad",
"file_manager_app": "spacefm",
"remux_folder_max_disk_usage": "8589934592"
}
}