diff --git a/hm/desktop/browser/default.nix b/hm/desktop/browser/default.nix index 0a1be42..0051ae2 100644 --- a/hm/desktop/browser/default.nix +++ b/hm/desktop/browser/default.nix @@ -5,6 +5,9 @@ ... }: { + imports = [ + ./homepage.nix + ]; config = lib.mkIf config.frogeye.desktop.xorg { home.sessionVariables = { BROWSER = "qutebrowser"; @@ -21,7 +24,6 @@ profiles.hm = { extensions = with pkgs.nur.repos.rycee.firefox-addons; [ (buildFirefoxXpiAddon { - pname = "onetab"; version = "0.1.0"; addonId = "onetab@nated"; @@ -73,7 +75,6 @@ force = true; }; settings = { - "browser.startup.homepage" = "https://geoffrey.frogeye.fr/home.php"; "signon.rememberSignons" = false; # Don't save passwords "browser.newtabpage.enabled" = false; # Best would be homepage but not possible without extension? # Europe please @@ -146,11 +147,7 @@ show = "never"; tabs_are_windows = true; }; - url = rec { - open_base_url = true; - start_pages = lib.mkDefault "https://geoffrey.frogeye.fr/blank.html"; - default_page = start_pages; - }; + url.open_base_url = true; content = { # I had this setting below, not sure if it did something special # config.set("content.cookies.accept", "no-3rdparty", "chrome://*/*") @@ -187,7 +184,8 @@ }; }; xsession.windowManager.i3.config.keybindings = { - "${config.xsession.windowManager.i3.config.modifier}+m" = "exec ${config.programs.qutebrowser.package}/bin/qutebrowser --override-restore"; + "${config.xsession.windowManager.i3.config.modifier}+m" = + "exec ${config.programs.qutebrowser.package}/bin/qutebrowser --override-restore"; }; }; } diff --git a/hm/desktop/browser/homepage.css b/hm/desktop/browser/homepage.css new file mode 100644 index 0000000..88e209a --- /dev/null +++ b/hm/desktop/browser/homepage.css @@ -0,0 +1,85 @@ +html { + background-image: linear-gradient(#e6f0a3 0%, #d2e638 50%, #c3d825 51%, #dbf043 100%); + min-height: 100%; +} + +body { + font: 20px Helvetica, sans-serif; + padding: 5% 0; +} + + +article { + margin: 0 auto; + max-width: 95%; +} + +h1, h2 { + display: none; +} + +nav div, nav a { + background: rgba(255, 255, 255, 0.8); + width: 110px; + height: 100px; + display: inline-block; + padding: 15px 0; + margin: 0px 5px 10px; + border: 1px solid #ddd; + border-radius: 5px; + text-align: center; + vertical-align: top; + position: relative; +} + + +@media only screen and (min-width: 768px) { + nav { + margin-left: 110px; + position: relative; + } + + nav div { + position: absolute; + left: -130px; + } +} + +nav div img { + margin: auto; + max-width: 90%; + max-height: 70%; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; +} + +a { + text-decoration: none; + color: inherit; +} + +nav a:hover { + background: rgba(240, 240, 240, 0.8); +} + +nav a:active { + background: rgba(220, 220, 220, 0.8); +} + + +nav a>.fa, nav a>.fa-stack{ + width: 100%; + margin-top: .25em; + margin-bottom: .35em; + font-size: 32px; +} + +nav a span { + display: block; + margin-top: .55em; + font-weight: 400; +} + diff --git a/hm/desktop/browser/homepage.html.mustache b/hm/desktop/browser/homepage.html.mustache new file mode 100644 index 0000000..cf875c2 --- /dev/null +++ b/hm/desktop/browser/homepage.html.mustache @@ -0,0 +1,32 @@ +<!doctype html> +<html lang="fr"> +<head> + <title>Homepage</title> + <meta charset="utf-8"/> + <meta name="viewport" content="width=device-width;minimum-scale=0.5,maximum-scale=1.0; user-scalable=1;" /> + <link rel="stylesheet" type="text/css" href="{{css}}"/> + <link rel="stylesheet" type="text/css" href="{{fa_css}}"/> +</head> +<body> + <article> + <h1>Homepage</h1> +{{#sections}} + <h2>{{title}}</h2> + <nav style="color: {{color}};"> + {{#image}} + <div> + <img alt="Logo for {{title}}" src="{{image}}" /> + </div> + {{/image}} + {{#links}} + <a href="{{url}}"> + <i class="fa fa-{{icon}}" aria-label="Icon for {{name}} ({{icon}})"></i> + <span>{{name}}</span> + </a> + {{/links}} + </nav> + +{{/sections}} + </article> +</body> +</html> diff --git a/hm/desktop/browser/homepage.nix b/hm/desktop/browser/homepage.nix new file mode 100644 index 0000000..c72c731 --- /dev/null +++ b/hm/desktop/browser/homepage.nix @@ -0,0 +1,107 @@ +{ + pkgs, + lib, + config, + ... +}: +let + # TODO ForkAwesome is deprecated, find something else + fa = pkgs.fetchFromGitHub { + owner = "ForkAwesome"; + repo = "Fork-Awesome"; + rev = "1.2.0"; + sha256 = "sha256-zG6/0dWjU7/y/oDZuSEv+54Mchng64LVyV8bluskYzc="; + }; + data = config.frogeye.homepage // { + sections = builtins.attrValues config.frogeye.homepage.sections; + css = ./homepage.css; + fa_css = "${fa}/css/fork-awesome.min.css"; + }; + # Blatantly stolen from https://pablo.tools/blog/computers/nix-mustache-templates/ + homepage = builtins.toString ( + pkgs.stdenv.mkDerivation { + + name = "homepage.html"; + + nativeBuildInpts = [ pkgs.mustache-go ]; + + passAsFile = [ "jsonData" ]; + jsonData = builtins.toJSON data; + + phases = [ + "buildPhase" + "installPhase" + ]; + + buildPhase = '' + ${pkgs.mustache-go}/bin/mustache $jsonDataPath ${./homepage.html.mustache} > homepage.html + ''; + + installPhase = '' + cp homepage.html $out + ''; + } + ); +in +{ + config.programs = { + firefox.profiles.hm.settings."browser.startup.homepage" = homepage; + qutebrowser.settings.url = { + start_pages = homepage; + default_page = homepage; + }; + }; + options.frogeye.homepage = { + sections = lib.mkOption { + default = { }; + description = "Folders used by users"; + # Top-level so Syncthing can work for all users. Also there's no real home-manager syncthing module. + type = lib.types.attrsOf ( + lib.types.submodule ( + { config, name, ... }: + { + options = { + title = lib.mkOption { + type = lib.types.str; + default = "Section title"; + }; + color = lib.mkOption { + type = lib.types.str; + default = "#337ab7"; + }; + image = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = null; + }; + links = lib.mkOption { + default = [ ]; + type = lib.types.listOf ( + lib.types.submodule ( + { config, ... }: + { + options = { + name = lib.mkOption { + type = lib.types.str; + default = "Link"; + }; + url = lib.mkOption { + type = lib.types.str; + default = "about:blank"; + }; + icon = lib.mkOption { + type = lib.types.str; + default = "question-circle"; + }; + }; + } + ) + ); + }; + }; + } + ) + ); + }; + + }; +}