feat: userChrome.css for Floorp
This commit is contained in:
parent
eb7c99115e
commit
bca922e0a1
2 changed files with 116 additions and 0 deletions
37
.ff-chrome/userChrome.css
Normal file
37
.ff-chrome/userChrome.css
Normal file
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Better Floorp vertical tabs
|
||||
*
|
||||
* This makes Floorp's (expanded) vertical tabs not affecting sites' width,
|
||||
* which can cause lag on heavy websites like Twitch and YouTube.
|
||||
*
|
||||
* This also fixed vertical tabs' width breaking when some preference related
|
||||
* to browser's "head" is changed
|
||||
*
|
||||
* Based on my changes fpr Pulse, but Pulse is dead.
|
||||
* REF: https://github.com/null2264/pulse/commit/fce966a110c2987b08d35bcd04c5992655b24b13
|
||||
*/
|
||||
:root {
|
||||
/* from Floorp source code, too big for me */
|
||||
/*--hoverd-verticaltab-width: 20em;*/
|
||||
|
||||
--hoverd-verticaltab-width: 16em;
|
||||
}
|
||||
|
||||
@charset "UTF-8";
|
||||
@-moz-document url(chrome://browser/content/browser.xhtml) {
|
||||
#TabsToolbar {
|
||||
position: relative !important;
|
||||
transition: all 300ms !important;
|
||||
min-width: var(--default-verticaltab-width) !important;
|
||||
max-width: var(--default-verticaltab-width) !important;
|
||||
z-index: 1; /* Probably not needed, since Floorp already handle this */
|
||||
}
|
||||
|
||||
#TabsToolbar:hover {
|
||||
transition: all 300ms !important;
|
||||
min-width: var(--hoverd-verticaltab-width) !important;
|
||||
max-width: var(--hoverd-verticaltab-width) !important;
|
||||
z-index: 2; /* Probably not needed, since Floorp already handle this */
|
||||
margin-right: calc((var(--hoverd-verticaltab-width) - var(--default-verticaltab-width)) * -1) !important;
|
||||
}
|
||||
}
|
79
user-chrome-setup.py
Executable file
79
user-chrome-setup.py
Executable file
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Install userChrome.css to $BROWSER's folder.
|
||||
|
||||
Written in Python because I'm too lazy to deal with INI parser using bash.
|
||||
"""
|
||||
|
||||
import configparser
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
from subprocess import run
|
||||
|
||||
def bool_from_string(string: str | None, default: bool | None = None) -> bool:
|
||||
lowered = (string or "").lower()
|
||||
|
||||
if lowered in ("yes", "y", "true", "t", "1", "enable", "on"):
|
||||
return True
|
||||
elif lowered in ("no", "n", "false", "f", "0", "disable", "off"):
|
||||
return False
|
||||
|
||||
if default is not None:
|
||||
return default
|
||||
raise ValueError("Invalid Input")
|
||||
|
||||
def die(message: str | None = None) -> None:
|
||||
if message:
|
||||
print(message, file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
home = os.getenv("HOME")
|
||||
browser = os.getenv("BROWSER")
|
||||
dotfiles = os.getenv("ZI_DOTFILES")
|
||||
|
||||
if not dotfiles:
|
||||
die("Please run pre-bootstrap first!")
|
||||
|
||||
if not browser:
|
||||
die("$BROWSER is not set!")
|
||||
|
||||
tmp = run([browser, "--version"], capture_output=True, text=True)
|
||||
if not tmp.stdout.startswith("Mozilla"):
|
||||
die("Chrome-based browser is not supported!")
|
||||
|
||||
if not "floorp" in tmp.stdout.lower():
|
||||
die("This script currently only support Floorp")
|
||||
|
||||
browser_path = f"{home}/.{browser}"
|
||||
|
||||
# Firefox doesn't support XDG path (yet?)
|
||||
try:
|
||||
# Firefox doesn't support XDG path (yet?)
|
||||
config.read(f"{browser_path}/profiles.ini")
|
||||
except:
|
||||
die("Unable to read profile list")
|
||||
|
||||
prompt = input("NOTE: Currently only support installing userChrome.css to default profile, continue anyway? [y/N] ")
|
||||
if not bool_from_string(prompt, False):
|
||||
exit(0)
|
||||
|
||||
# profiles = [p for p in config.sections() if p.startswith("Profile")]
|
||||
# default = next(config[p] for p in profiles if str(config[p].get("Default", "0")) == "1")
|
||||
|
||||
_install = [p for p in config.sections() if p.startswith("Install")]
|
||||
default_path = next(config[p] for p in _install)
|
||||
profile_path = f"{browser_path}/{default_path['Default']}"
|
||||
chrome_path = pathlib.Path(f"{profile_path}/chrome")
|
||||
chrome_path.mkdir(parents=True, exist_ok=True)
|
||||
user_chrome_path = chrome_path / "userChrome.css"
|
||||
try:
|
||||
user_chrome_path.symlink_to(f"{dotfiles}/.ff-chrome/userChrome.css")
|
||||
except FileExistsError:
|
||||
prompt = input("Overwrite existing userChrome.css? [y/N] ")
|
||||
if not bool_from_string(prompt, False):
|
||||
exit(0)
|
||||
user_chrome_path.unlink()
|
||||
user_chrome_path.symlink_to(f"{dotfiles}/.ff-chrome/userChrome.css")
|
||||
print("userChrome.css has successfully installed.")
|
Loading…
Add table
Add a link
Reference in a new issue