add appimage stuff

This commit is contained in:
Izalia Mae 2022-09-24 06:57:21 -04:00
parent 5b0689181e
commit 9ada9ef2cf
15 changed files with 297 additions and 10 deletions

2
.gitignore vendored
View file

@ -126,3 +126,5 @@ test*.py
# glade backup files # glade backup files
*.ui~ *.ui~
# appimage build
/AppDir

10
appimage-main.py Normal file
View file

@ -0,0 +1,10 @@
import os
import sys
appdir = os.environ['APPDIR']
sys.path.insert(0, f'{appdir}/usr/src')
from barkshark_web.cli import main
main()

View file

@ -0,0 +1,6 @@
configobj@git+https://github.com/DiffSK/configobj
izzylib-http-async@git+https://git.barkshark.xyz/izaliamae/izzylib-http-async
izzylib-sql@git+https://git.barkshark.xyz/izaliamae/izzylib-sql
objgraph==3.5.0
pillow==8.3.2
pysftp==0.2.9

121
appimage.yaml Normal file
View file

@ -0,0 +1,121 @@
version: 1
script:
#- rm -rf AppDir | true
- mkdir -p AppDir/usr/src
- mkdir -p AppDir/usr/share/icons/hicolor/128x128/apps
- cp -R barkshark_web AppDir/usr/src/
- cp appimage-requirements.txt AppDir/usr/src/requirements.txt
- cp appimage-main.py AppDir/usr/src/main.py
- cp barkshark_web/resources/icon-128.png AppDir/usr/share/icons/hicolor/128x128/apps/barkshark-web.png
AppDir:
path: ./AppDir
app_info:
id: xyz.barkshark.Web
name: barkshark-web
icon: barkshark-web
version: 0.4.0
exec: usr/bin/python3
exec_args: "${APPDIR}/usr/src/main.py $@"
after_bundle:
- AppDir/usr/bin/python3 -m pip install --ignore-installed --prefix=/usr --root=AppDir -r appimage-requirements.txt
apt:
arch: amd64
allow_unauthenticated: true
sources:
- sourceline: 'deb [arch=amd64] https://deb.debian.org/debian bookworm main'
#key_url: 'https://deb.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2021.1.1.dsc'
- sourceline: 'deb [arch=amd64] https://deb.debian.org/debian bookworm-updates main'
#key_url: 'https://deb.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2021.1.1.dsc'
- sourceline: 'deb [arch=amd64] https://security.debian.org/debian-security bookworm-security main'
#key_url: 'https://security.debian.org/debian-security/pool/main/d/debian-archive-keyring/debian-archive-keyring_2017.5+deb9u2.dsc'
include:
- appmenu-gtk3-module
- gir1.2-glib-2.0
- gir1.2-gst-plugins-bad-1.0
- gir1.2-gst-plugins-base-1.0
- gir1.2-gtk-3.0
- gir1.2-webkit2-4.0
- gir1.2-notify-0.7
- git
- gstreamer1.0-plugins-bad
- gstreamer1.0-plugins-base
- gstreamer1.0-plugins-good
- gstreamer1.0-plugins-ugly
- libcairo-gobject2
- librsvg2-common
- openssl
- python3
- python3-bs4
- python3-click
- python3-dasbus
- python3-dnspython
- python3-gi
- python3-gi-cairo
- python3-lxml
- python3-mastodon
- python3-pip
- python3-pkg-resources
- python3-psutil
- python3-secretstorage
- python3-watchdog
- python3-wheel
- xapp
exclude:
- emacsen-common
- fdisk
- libapparmor1
- libasound2
- libasound2-data
- libmount
- libsystemd0
- libudev1
- mount
- systemd
- systemd-sysv
files:
exclude:
- usr/share/man
- usr/share/doc
#- usr/share/doc/*/README.*
#- usr/share/doc/*/changelog.*
#- usr/share/doc/*/NEWS.*
#- usr/share/doc/*/TODO.*
runtime:
env:
PYTHONHOME: '${APPDIR}/usr'
PYTHONPATH: '${APPDIR}/usr/lib/python3.10/site-packages'
test:
fedora:
image: appimagecrafters/tests-env:fedora-30
command: ./AppRun
use_host_x: true
debian:
image: appimagecrafters/tests-env:debian-stable
command: ./AppRun
use_host_x: true
arch:
image: appimagecrafters/tests-env:archlinux-latest
command: ./AppRun
use_host_x: true
centos:
image: appimagecrafters/tests-env:centos-7
command: ./AppRun
use_host_x: true
ubuntu:
image: appimagecrafters/tests-env:ubuntu-xenial
command: ./AppRun
use_host_x: true
AppImage:
update-information: 'zsync|https://static.barkshark.xyz/appimage-updates/{{APP_NAME}}-{{APP_VERSION}}-{{ARCH}}.AppImage.zsync'
sign-key: A12ACFEC461B90EAA89A43FD7519E7A4AD70227D
arch: x86_64

View file

@ -6,10 +6,13 @@ gir1.2-notify-0.7
libcairo-gobject2 libcairo-gobject2
libgirepository1.0-dev libgirepository1.0-dev
libjson-glib-dev libjson-glib-dev
librsvg2-common
libwebkit2gtk-4.0-dev libwebkit2gtk-4.0-dev
meson meson
ninja ninja
python-gi-dev python-gi-dev
python3-gi
python3-gi-cairo
python3-dev python3-dev
python3-pip python3-pip
python3-venv python3-venv

View file

@ -6,7 +6,9 @@ from os import environ as env
from . import __shortname__, __software__, __version__ from . import __shortname__, __software__, __version__
from .component.application import Application from .component.application import Application
from .database.base import default_config
from .dbus import Client from .dbus import Client
from .functions import install_desktop_file
context_settings = dict( context_settings = dict(
@ -27,6 +29,9 @@ def cli(ctx, profile):
dbus = Client() dbus = Client()
) )
if (deskfile := install_desktop_file(overwrite=False)):
logging.verbose(f'Installed new desktop file: {deskfile}')
if not ctx.invoked_subcommand: if not ctx.invoked_subcommand:
cli_run.callback([]) cli_run.callback([])
@ -64,6 +69,16 @@ def cli_run(ctx, urls):
ctx.obj.app.run([]) ctx.obj.app.run([])
@cli.command('install')
@click.pass_context
def cli_install(ctx):
if (deskfile := install_desktop_file(overwrite=True)):
click.echo(f'Installed new desktop file')
else:
click.echo('Failed to install new desktop file')
@cli.group('tab') @cli.group('tab')
@click.pass_context @click.pass_context
def cli_tab(ctx): def cli_tab(ctx):
@ -95,5 +110,46 @@ def cli_tab_new(ctx, urls):
ctx.obj.dbus.disconnect() ctx.obj.dbus.disconnect()
@cli.group('config')
@click.pass_context
def cli_config(ctx):
pass
@cli_config.command('list')
@click.pass_context
def cli_config_list(ctx):
click.echo('Current config:')
with ctx.obj.app.db.session as s:
for key in default_config.keys():
if key == 'version':
continue
value = s.get_config(key)
click.echo(f'- {key.replace("_", "-").ljust(25)}: {value}')
@cli_config.command('get')
@click.argument('key')
@click.pass_context
def cli_config_get(ctx, key):
with ctx.obj.app.db.session as s:
value = s.get_config(key.replace('-', '_'))
click.echo(f'{key} = {value}')
@cli_config.command('set')
@click.argument('key')
@click.argument('value')
@click.pass_context
def cli_config_set(ctx, key, value):
with ctx.obj.app.db.session as s:
value = s.put_config(key.replace('-', '_'), value)
click.echo(f'{key} = {value}')
def main(): def main():
cli(prog_name=__shortname__) cli(prog_name=__shortname__)

View file

@ -1,7 +1,8 @@
import sys import sys
from izzylib.enums import LogLevel
from izzylib.http_client import HttpClient from izzylib.http_client import HttpClient
from izzylib.misc import signal_handler from izzylib.misc import class_name, signal_handler
from izzylib_http_async import Template from izzylib_http_async import Template
from izzylib_sql import Database from izzylib_sql import Database
from urllib.parse import quote from urllib.parse import quote
@ -182,8 +183,15 @@ class Application(Gtk.Application):
self.window = Window(self) self.window = Window(self)
self.dbus = dbus.Server(self.window) self.dbus = dbus.Server(self.window)
self.add_window(self.window) try:
if logging.get_config('level') in [LogLevel.VERBOSE, LogLevel.DEBUG]:
self.window.themes.watcher_start()
except OSError as e:
logging.warning(f'Failed to start theme watcher')
logging.error(f'{class_name(e)}: {e}')
self.add_window(self.window)
self.setup_password_storage() self.setup_password_storage()
with self.db.session as s: with self.db.session as s:

View file

@ -441,6 +441,8 @@ class Window(BuilderBase, Gtk.ApplicationWindow):
def handle_window_close(self, *args): def handle_window_close(self, *args):
logging.verbose('Saving data') logging.verbose('Saving data')
self.hide()
self.app.password.stop() self.app.password.stop()
self.tabs_save() self.tabs_save()

View file

@ -393,13 +393,15 @@ class CustomSession(Session):
if value == None: if value == None:
value = default_config[key][0] value = default_config[key][0]
return self.put_cached('config', key, row = self.put_cached('config', key,
row = self.fetch('config', key=key).one(), row = self.fetch('config', key=key).one(),
key = key, key = key,
value = DotDict(value).to_json() if subtype == 'dict' else str(value), value = DotDict(value).to_json() if subtype == 'dict' else str(value),
type = subtype type = subtype
) )
return row.value
def put_extension(self, extension): def put_extension(self, extension):
if self.get_extension(extension.digest): if self.get_extension(extension.digest):

View file

@ -116,6 +116,10 @@ class Client():
return self.run_cmd('GetTabs') return self.run_cmd('GetTabs')
def Internal(self, data: str) -> str:
return self.run_command('Internal', data)
def Present(self): def Present(self):
return self.run_cmd('Present') return self.run_cmd('Present')

View file

@ -1,11 +1,14 @@
import cairo import cairo
import multiprocessing import multiprocessing
import random import random
import os
import socket import socket
import sys
import threading import threading
import time import time
import traceback import traceback
from configobj import ConfigObj
from ctypes import cdll, create_string_buffer, byref from ctypes import cdll, create_string_buffer, byref
from dns.resolver import NXDOMAIN, resolve from dns.resolver import NXDOMAIN, resolve
from izzylib.http_client import HttpClient from izzylib.http_client import HttpClient
@ -17,6 +20,7 @@ from . import __version__, var
js_cache = LruCache() js_cache = LruCache()
appimage_exec = os.environ.get('APPIMAGE')
client_options = {'appagent': f'PyWeb/{__version__}'} client_options = {'appagent': f'PyWeb/{__version__}'}
glib_types = { glib_types = {
bytes: GLib.Variant.new_byte, bytes: GLib.Variant.new_byte,
@ -27,6 +31,17 @@ glib_types = {
list: GLib.Variant.new_array list: GLib.Variant.new_array
} }
categories = ['Network', 'WebBrowser']
mimetypes = [
'application/x-extension-htm', 'application/x-extension-html',
'application/x-extension-shtml', 'application/x-extension-xht',
'application/x-extension-xhtml', 'application/x-extension-xml'
'text/html', 'text/xml',
'application/xhtml+xml', 'application/xml',
'x-scheme-handler/http', 'x-scheme-handler/https',
'x-scheme-handler/ftp', 'x-scheme-handler/file'
]
## Haven't implemented proxy support yet ## Haven't implemented proxy support yet
#if var.proxy: #if var.proxy:
#client_options.update({ #client_options.update({
@ -113,6 +128,57 @@ def icon_set(widget, *args, **kwargs):
return widget return widget
def install_desktop_file(overwrite=False):
app = get_app()
deskfile = Path.xdg.data.join('applications/barkshark-web.desktop')
deskfile.parent.mkdir()
workdir = app.path.script.parent
executable = appimage_exec or f'{sys.executable} -m barkshark_web'
if deskfile.exists() and not overwrite:
logging.debug(f'Desktop file already exists: {deskfile}')
return
config = ConfigObj()
config.filename = deskfile
config.update({
'Desktop Entry': {
'Name': 'Barkshark Web',
'GenericName': 'Web Browser',
'Comment': 'Browse the World Wide Web',
'Categories': ';'.join(categories),
'Icon': 'applications-internet',
'MimeType': ';'.join(mimetypes),
'Exec': f'{sys.executable} -m barkshark_web %U',
'Path': workdir,
'StartupNotify': True,
'StartupWMClass': 'BarksharkWeb',
'Type': 'Application',
'X-DBUS-ServiceName': 'xyz.barkshark.Web',
'X-DBUS-StartupType': 'Unique'
},
'Desktop Action NewTab': {
'Name': 'New Tab',
'Exec': f'{sys.executable} -m barkshark_web tab new',
'Path': workdir
}
})
if appimage_exec:
del config['Desktop Entry']['Path']
del config['Desktop Action NewTab']['Path']
config.write()
deskfile.chmod(755)
return deskfile
def set_default():
subprocess.run(['xdg-settings' 'set' 'default-web-browser' 'barkshark-web.desktop'])
def load_js_file(name, ext=False): def load_js_file(name, ext=False):
cache_name = name + str(1 if ext else 0) cache_name = name + str(1 if ext else 0)
cached = js_cache.fetch(cache_name) cached = js_cache.fetch(cache_name)

View file

@ -33,9 +33,6 @@ class Themes(ComponentBase, ObjectBase):
self.setup() self.setup()
if logging.get_config('level') in [LogLevel.VERBOSE, LogLevel.DEBUG]:
self.watcher_start()
def __del__(self): def __del__(self):
self.watcher_stop() self.watcher_stop()

View file

@ -11,6 +11,11 @@
"options": [], "options": [],
"url": null "url": null
}, },
"configobj": {
"version": "5.1.0.dev0",
"options": [],
"url": "git+https://github.com/DiffSK/configobj"
},
"dasbus": { "dasbus": {
"version": "1.6", "version": "1.6",
"options": [], "options": [],
@ -32,7 +37,7 @@
"url": "git+https://git.barkshark.xyz/izaliamae/izzylib-http-async" "url": "git+https://git.barkshark.xyz/izaliamae/izzylib-http-async"
}, },
"izzylib-sql": { "izzylib-sql": {
"version": "0.1.0", "version": "0.1.1",
"options": [], "options": [],
"url": "git+https://git.barkshark.xyz/izaliamae/izzylib-sql" "url": "git+https://git.barkshark.xyz/izaliamae/izzylib-sql"
}, },
@ -61,6 +66,11 @@
"options": [], "options": [],
"url": null "url": null
}, },
"pycairo": {
"version": "1.21.0",
"options": [],
"url": null
},
"pygobject": { "pygobject": {
"version": "3.38.0", "version": "3.38.0",
"options": [], "options": [],

View file

@ -1,8 +1,8 @@
beautifulsoup4==4.9.3 beautifulsoup4==4.9.3
click==8.1.0 click==8.1.0
configobj@git+https://github.com/DiffSK/configobj
dasbus==1.6 dasbus==1.6
dnspython==2.2.1 dnspython==2.2.1
izzylib@git+https://git.barkshark.xyz/izaliamae/izzylib@0.7.5
izzylib-http-async@git+https://git.barkshark.xyz/izaliamae/izzylib-http-async izzylib-http-async@git+https://git.barkshark.xyz/izaliamae/izzylib-http-async
izzylib-sql@git+https://git.barkshark.xyz/izaliamae/izzylib-sql izzylib-sql@git+https://git.barkshark.xyz/izaliamae/izzylib-sql
lxml==4.6.3 lxml==4.6.3

View file

@ -1,13 +1,12 @@
[metadata] [metadata]
name = Barkshark Web name = Barkshark Web
version = 0.3.8 version = 0.4.0
author = Zoey Mae author = Zoey Mae
author_email = zoey@barkshark.xyz author_email = zoey@barkshark.xyz
url = https://git.barkshark.xyz/izaliamae/barkshark-web url = https://git.barkshark.xyz/izaliamae/barkshark-web
description = Python venv manager description = Python venv manager
long_description = file: README.md long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8 long_description_content_type = text/markdown; charset=UTF-8
license = CNPL 4+
license_file = LICENSE license_file = LICENSE
platform = any platform = any
keywords = python development venv keywords = python development venv
@ -35,6 +34,7 @@ packages =
setup_requires = setup_requires =
beautifulsoup4==4.9.3 beautifulsoup4==4.9.3
click==8.1.0 click==8.1.0
configobj@git+https://github.com/DiffSK/configobj
dasbus==1.6 dasbus==1.6
dnspython==2.2.1 dnspython==2.2.1
izzylib@git+https://git.barkshark.xyz/izaliamae/izzylib@0.7.5 izzylib@git+https://git.barkshark.xyz/izaliamae/izzylib@0.7.5