From 2b42b381315cba042001db9f71fdefdfda035ec4 Mon Sep 17 00:00:00 2001 From: Paper Date: Sun, 22 Mar 2020 19:01:22 +0100 Subject: [PATCH] Initial commit --- README.md | 27 +++++++++++++++++++++++ makefile | 11 ++++++++++ miniice | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 README.md create mode 100644 makefile create mode 100755 miniice diff --git a/README.md b/README.md new file mode 100644 index 0000000..df148db --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# miniice +Create "standalone" apps from websites using firefox. +Inspired by Peppermint OS's ice. + +# install +``` +$ make install +``` + +add ~/.local/share/miniice/bin to your $PATH + +# usage + +create a new webapp +``` +miniice add +``` + +Delete existing webapp +``` +miniice del +``` + +list all configured webapps +``` +miniice list +``` diff --git a/makefile b/makefile new file mode 100644 index 0000000..5ad5576 --- /dev/null +++ b/makefile @@ -0,0 +1,11 @@ +PREFIX = /usr/local + +all: + +install: + install -D -m 755 miniice $(DESTDIR)$(PREFIX)/bin/miniice + +uninstall: + rm $(DESTDIR)$(PREFIX)/bin/miniice + +.PHONY: all install uninstall diff --git a/miniice b/miniice new file mode 100755 index 0000000..0d3e0c0 --- /dev/null +++ b/miniice @@ -0,0 +1,64 @@ +#!/bin/sh -e +# inspired by peppermint OS's ice - user.js and userChrome.css is taken from them: +# https://github.com/peppermintos/ice +prefix="$HOME/.local/share/miniice" +mkdir -p "$prefix/bin" +mkdir -p "$prefix/firefox" + +help() { + echo 'usage: miniice [list|add |del |-h|--help|help] +miniice list - list all SSBs configured +miniice add - create a new SSB +miniice del - delete existing SSB +miniice [help|-h|--help] - show this help' +} + +add() { + # TODO: check if exists + name="$1" + url="$2" + + mkdir -p "$prefix/firefox/$name" + echo 'user_pref("browser.cache.disk.enable", false);user_pref("browser.cache.disk.capacity", 0);user_pref("browser.cache.disk.filesystem_reported", 1);user_pref("browser.cache.disk.smart_size.enabled", false);user_pref("browser.cache.disk.smart_size.first_run", false);user_pref("browser.cache.disk.smart_size.use_old_max", false);user_pref("browser.ctrlTab.previews", true);user_pref("browser.tabs.warnOnClose", false);user_pref("plugin.state.flash", 2);user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);' > "$prefix"/firefox/"$name"/user.js + + mkdir -p "$prefix/firefox/$name/chrome" + echo '#nav-bar, #identity-box, #tabbrowser-tabs, #TabsToolbar { visibility: collapse !important; }' > "$prefix"/firefox/"$name"/chrome/userChrome.css + + echo "firefox --class SSB-$name --profile $prefix/firefox/$name --no-remote $url" > "$prefix/bin/$name" + chmod 755 "$prefix/bin/$name" +} + +del() { + # TODO: check if exists + name="$1" + rm -rf "$prefix/firefox/$name" + rm "$prefix/bin/$name" +} + +list() { + cd "$prefix"/bin + for f in *; do + [ "$f" = '*' ] && continue + echo "$f" + done +} + +if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "help" ]; then + help + exit 0 +elif [ "$1" = add ]; then + shift + ! [ $# = 2 ] && help && exit 1 + add "$1" "$2" +elif [ "$1" = del ]; then + shift + ! [ $# = 1 ] && help && exit 1 + del "$1" +elif [ "$1" = list ]; then + shift + ! [ $# = 0 ] && help && exit 1 + list +else + help + exit 1 +fi