Compare commits
	
		
			4 Commits 
		
	
	
		
			a2821886f1
			...
			c647d6f347
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								
								 | 
						c647d6f347 | |
| 
							
							
								
								 | 
						fc374eab84 | |
| 
							
							
								
								 | 
						b9d06abcce | |
| 
							
							
								
								 | 
						04185d3f75 | 
							
								
								
									
										70
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										70
									
								
								Makefile
								
								
								
								
							| 
						 | 
					@ -1,25 +1,12 @@
 | 
				
			||||||
Appname:=$(shell cat appname.txt)
 | 
					Appname:=$(shell cat appname.txt)
 | 
				
			||||||
prefix:=/usr
 | 
					prefix:=/usr
 | 
				
			||||||
temp:=/tmp/fpm-jolla
 | 
					temp:=/tmp/fpm-jolla
 | 
				
			||||||
sdkpath:=$(HOME)/SailfishOS
 | 
					 | 
				
			||||||
sourcePath:=$(shell pwd)
 | 
					sourcePath:=$(shell pwd)
 | 
				
			||||||
dependencies=$(shell for file in `cat dependencies.txt`;do echo "-d "$${file};done;)
 | 
					dependencies=$(shell for file in `cat dependencies.txt`;do echo "-d "$${file};done;)
 | 
				
			||||||
arch:=armv7hl
 | 
					 | 
				
			||||||
version:=0.5.0
 | 
					version:=0.5.0
 | 
				
			||||||
iteration:=1
 | 
					iteration:=9
 | 
				
			||||||
rpmname:=$(Appname)-$(version)-$(iteration).$(arch).rpm
 | 
					 | 
				
			||||||
ssh_user:=defaultuser
 | 
					 | 
				
			||||||
jolla_usb_ip:=192.168.2.15
 | 
					 | 
				
			||||||
jolla_wifi_ip:=192.168.100.34
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					all: clean build-tmp rpm-i686 rpm-jolla rpm-aarch64
 | 
				
			||||||
all: clean build-tmp rpm-virt rpm-jolla
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
make-jolla-usb: build-tmp rpm-jolla send-jolla-usb
 | 
					 | 
				
			||||||
make-jolla-wifi: build-tmp rpm-jolla send-jolla-wifi
 | 
					 | 
				
			||||||
make-jolla-ap: build-tmp rpm-jolla send-jolla-ap
 | 
					 | 
				
			||||||
make-virt: arch:=i686
 | 
					 | 
				
			||||||
make-virt: build-tmp rpm-virt send-virt
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
build-tmp:
 | 
					build-tmp:
 | 
				
			||||||
	mkdir -p $(temp)/usr/share/applications
 | 
						mkdir -p $(temp)/usr/share/applications
 | 
				
			||||||
| 
						 | 
					@ -32,9 +19,9 @@ build-tmp:
 | 
				
			||||||
	cp -ar ./dat/appicon.png $(temp)/usr/share/icons/hicolor/86x86/apps/$(Appname).png
 | 
						cp -ar ./dat/appicon.png $(temp)/usr/share/icons/hicolor/86x86/apps/$(Appname).png
 | 
				
			||||||
	install -m 755 ./dat/$(Appname).sh $(temp)/usr/bin/$(Appname)
 | 
						install -m 755 ./dat/$(Appname).sh $(temp)/usr/bin/$(Appname)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
rpm-virt: arch:=i686
 | 
					rpm-i686: arch:=i686
 | 
				
			||||||
rpm-virt: rpmname:=$(Appname)-$(version)-$(iteration).$(arch).rpm
 | 
					rpm-i686: rpmname:=$(Appname)-$(version)-$(iteration).$(arch).rpm
 | 
				
			||||||
rpm-virt: build-tmp
 | 
					rpm-i686: build-tmp
 | 
				
			||||||
	cd $(temp);fpm -f -s dir -t rpm \
 | 
						cd $(temp);fpm -f -s dir -t rpm \
 | 
				
			||||||
		--after-install $(sourcePath)/dat/upgradeScript.sh \
 | 
							--after-install $(sourcePath)/dat/upgradeScript.sh \
 | 
				
			||||||
		--after-remove $(sourcePath)/dat/removeScript.sh \
 | 
							--after-remove $(sourcePath)/dat/removeScript.sh \
 | 
				
			||||||
| 
						 | 
					@ -48,6 +35,8 @@ rpm-virt: build-tmp
 | 
				
			||||||
		-a $(arch) \
 | 
							-a $(arch) \
 | 
				
			||||||
		--prefix / *
 | 
							--prefix / *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					rpm-jolla: arch:=armv7hl
 | 
				
			||||||
 | 
					rpm-jolla: rpmname:=$(Appname)-$(version)-$(iteration).$(arch).rpm
 | 
				
			||||||
rpm-jolla: build-tmp
 | 
					rpm-jolla: build-tmp
 | 
				
			||||||
	cd $(temp);fpm -f -s dir -t rpm \
 | 
						cd $(temp);fpm -f -s dir -t rpm \
 | 
				
			||||||
		--after-install $(sourcePath)/dat/upgradeScript.sh \
 | 
							--after-install $(sourcePath)/dat/upgradeScript.sh \
 | 
				
			||||||
| 
						 | 
					@ -62,36 +51,23 @@ rpm-jolla: build-tmp
 | 
				
			||||||
		-a $(arch) \
 | 
							-a $(arch) \
 | 
				
			||||||
		--prefix / *
 | 
							--prefix / *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
send-virt:
 | 
					rpm-aarch64: arch:=aarch64
 | 
				
			||||||
	cat $(temp)/$(rpmname) | ssh -i '$(sdkpath)/vmshare/ssh/private_keys/SailfishOS_Emulator/nemo' -p2223 $(ssh_user)@localhost \
 | 
					rpm-aarch64: rpmname:=$(Appname)-$(version)-$(iteration).$(arch).rpm
 | 
				
			||||||
		cat ">" /tmp/$(rpmname) "&&" \
 | 
					rpm-aarch64: build-tmp
 | 
				
			||||||
		pkcon install-local -y /tmp/$(rpmname) "&&" \
 | 
						cd $(temp);fpm -f -s dir -t rpm \
 | 
				
			||||||
		rm /tmp/$(rpmname)
 | 
							--after-install $(sourcePath)/dat/upgradeScript.sh \
 | 
				
			||||||
 | 
							--after-remove $(sourcePath)/dat/removeScript.sh \
 | 
				
			||||||
send-jolla-wifi:
 | 
							--rpm-changelog $(sourcePath)/changelog.txt \
 | 
				
			||||||
	cat $(temp)/$(rpmname) | ssh $(ssh_user)@$(jolla_wifi_ip) \
 | 
							--directories "/usr/share/$(Appname)" \
 | 
				
			||||||
		cat ">" /tmp/$(rpmname) "&&" \
 | 
							-v $(version) \
 | 
				
			||||||
		pkcon install-local -y /tmp/$(rpmname) "&&" \
 | 
							--iteration $(iteration) \
 | 
				
			||||||
		rm /tmp/$(rpmname)
 | 
							$(dependencies) \
 | 
				
			||||||
 | 
							-p $(temp)/$(rpmname) \
 | 
				
			||||||
send-jolla-ap: jolla_wifi_ip:=192.168.1.1
 | 
							-n $(Appname) \
 | 
				
			||||||
send-jolla-ap:
 | 
							-a $(arch) \
 | 
				
			||||||
	cat $(temp)/$(rpmname) | ssh $(ssh_user)@$(jolla_wifi_ip) \
 | 
							--prefix / *
 | 
				
			||||||
		cat ">" /tmp/$(rpmname) "&&" \
 | 
					 | 
				
			||||||
		pkcon install-local -y /tmp/$(rpmname) "&&" \
 | 
					 | 
				
			||||||
		rm /tmp/$(rpmname)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
send-jolla-usb:
 | 
					 | 
				
			||||||
	cat $(temp)/$(rpmname) | ssh $(ssh_user)@$(jolla_usb_ip) \
 | 
					 | 
				
			||||||
		cat ">" /tmp/$(rpmname) "&&" \
 | 
					 | 
				
			||||||
		pkcon install-local -y /tmp/$(rpmname) "&&" \
 | 
					 | 
				
			||||||
		rm /tmp/$(rpmname)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
send-only-virt:
 | 
					 | 
				
			||||||
	cat $(temp)/$(rpmname) | ssh -i '$(sdkpath)/vmshare/ssh/private_keys/SailfishOS_Emulator/nemo' -p2223 $(ssh_user)@localhost \
 | 
					 | 
				
			||||||
		cat ">" /tmp/$(rpmname)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
clean:
 | 
					clean:
 | 
				
			||||||
	rm -rf $(temp)
 | 
						rm -rf $(temp)
 | 
				
			||||||
	rm -rf $(builddir)
 | 
						rm -rf $(builddir)
 | 
				
			||||||
	rm -rf ./$(rpmname)
 | 
						rm -rf ./$(Appname)-$(version)-$(iteration)*
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ Make your webapps icons in the app box look better with the rest of your native
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Build dependencies
 | 
					## Build dependencies
 | 
				
			||||||
- [fpm](https://github.com/jordansissel/fpm)
 | 
					- [fpm](https://github.com/jordansissel/fpm)
 | 
				
			||||||
 | 
					- [rpm-tools](http://rpm.org/)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Build your own RPM package
 | 
					## Build your own RPM package
 | 
				
			||||||
1. Clone the repository: `git clone https://gitlab.com/kirbylife/harbour-muchkin`
 | 
					1. Clone the repository: `git clone https://gitlab.com/kirbylife/harbour-muchkin`
 | 
				
			||||||
| 
						 | 
					@ -16,13 +17,14 @@ Make your webapps icons in the app box look better with the rest of your native
 | 
				
			||||||
1. Build the package.
 | 
					1. Build the package.
 | 
				
			||||||
  1. armv7hl: `make rpm-jolla`
 | 
					  1. armv7hl: `make rpm-jolla`
 | 
				
			||||||
  1. i686: `make rpm-virt`
 | 
					  1. i686: `make rpm-virt`
 | 
				
			||||||
  1. aarch64: `soon`
 | 
					  1. aarch64: `make rpm-aarch64`
 | 
				
			||||||
1. the .rpm file will be on `/tmp/fpm-jolla/`
 | 
					1. the .rpm file will be on `/tmp/fpm-jolla/`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## TO-DO
 | 
					## TO-DO
 | 
				
			||||||
- [ ] Make betters Make commands
 | 
					 | 
				
			||||||
- [x] Support to aarch64 arquitecture
 | 
					- [x] Support to aarch64 arquitecture
 | 
				
			||||||
- [x] Choice non-transparent color to fill the empty spaces
 | 
					- [x] Choice non-transparent color to fill the empty spaces
 | 
				
			||||||
 | 
					- [x] Fix the issue with sailjail
 | 
				
			||||||
 | 
					- [ ] Make betters Make commands
 | 
				
			||||||
- [ ] Add option to request favicon
 | 
					- [ ] Add option to request favicon
 | 
				
			||||||
- [ ] Add option to restore the original icon
 | 
					- [ ] Add option to restore the original icon
 | 
				
			||||||
- [ ] Make all icons in the main grid the same size
 | 
					- [ ] Make all icons in the main grid the same size
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,3 +4,5 @@ X-Nemo-Application-Type=silica-qt5
 | 
				
			||||||
Name=Muchkin
 | 
					Name=Muchkin
 | 
				
			||||||
Icon=harbour-muchkin
 | 
					Icon=harbour-muchkin
 | 
				
			||||||
Exec=sailfish-qml harbour-muchkin
 | 
					Exec=sailfish-qml harbour-muchkin
 | 
				
			||||||
 | 
					[X-Sailjail]
 | 
				
			||||||
 | 
					Sandboxing=Disabled
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,4 @@
 | 
				
			||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#rm -rf /usr/share/harbour-muchkin
 | 
					#rm -rf /usr/share/harbour-muchkin
 | 
				
			||||||
echo "Upgrading...."
 | 
					echo "Upgrading..."
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,3 +2,4 @@ libsailfishapp-launcher
 | 
				
			||||||
pyotherside-qml-plugin-python3-qt5
 | 
					pyotherside-qml-plugin-python3-qt5
 | 
				
			||||||
python3-base
 | 
					python3-base
 | 
				
			||||||
python3-imaging
 | 
					python3-imaging
 | 
				
			||||||
 | 
					python3-requests
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,7 +68,9 @@ Page {
 | 
				
			||||||
        anchors.topMargin: 10
 | 
					        anchors.topMargin: 10
 | 
				
			||||||
        text: "Save"
 | 
					        text: "Save"
 | 
				
			||||||
        onClicked: {
 | 
					        onClicked: {
 | 
				
			||||||
 | 
					            if(iconEditor.attrs.old_icon === undefined) {
 | 
				
			||||||
                iconEditor.attrs.old_icon = iconEditor.attrs.Icon.toString()
 | 
					                iconEditor.attrs.old_icon = iconEditor.attrs.Icon.toString()
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            iconEditor.attrs.Icon = icon.source.toString()
 | 
					            iconEditor.attrs.Icon = icon.source.toString()
 | 
				
			||||||
            py.importModule("main", function(){
 | 
					            py.importModule("main", function(){
 | 
				
			||||||
                py.call("main.save_icon", [iconEditor.attrs], function(result){
 | 
					                py.call("main.save_icon", [iconEditor.attrs], function(result){
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										39
									
								
								src/main.py
								
								
								
								
							
							
						
						
									
										39
									
								
								src/main.py
								
								
								
								
							| 
						 | 
					@ -1,13 +1,29 @@
 | 
				
			||||||
import pyotherside
 | 
					import pyotherside
 | 
				
			||||||
from PIL import Image, ImageOps, ImageDraw, ImageChops
 | 
					from PIL import Image, ImageDraw, ImageChops
 | 
				
			||||||
 | 
					from PIL.Image import Image as ImageType
 | 
				
			||||||
from io import BytesIO
 | 
					from io import BytesIO
 | 
				
			||||||
from glob import glob
 | 
					from glob import glob
 | 
				
			||||||
from collections import Counter
 | 
					from collections import Counter
 | 
				
			||||||
 | 
					import requests
 | 
				
			||||||
import base64
 | 
					import base64
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import shutil
 | 
					import shutil
 | 
				
			||||||
 | 
					import logging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def base64_to_img(base64_bytes: bytes) -> Image:
 | 
					logging_filename = os.path.join(os.getenv("HOME"),
 | 
				
			||||||
 | 
					                                ".local",
 | 
				
			||||||
 | 
					                                "share",
 | 
				
			||||||
 | 
					                                "org.git.kirbylife.harbour-muchkin",
 | 
				
			||||||
 | 
					                                "muchkin.log")
 | 
				
			||||||
 | 
					logging.basicConfig(filename=logging_filename, filemode="w", level=logging.DEBUG)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def download_icon(url) -> ImageType:
 | 
				
			||||||
 | 
					    response = requests.get(url)
 | 
				
			||||||
 | 
					    img = Image.open(BytesIO(response.content))
 | 
				
			||||||
 | 
					    img = img.convert("RGBA")
 | 
				
			||||||
 | 
					    return img
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def base64_to_img(base64_bytes: bytes) -> ImageType:
 | 
				
			||||||
    img_bytes = base64.b64decode(base64_bytes)
 | 
					    img_bytes = base64.b64decode(base64_bytes)
 | 
				
			||||||
    img_buffer = BytesIO(img_bytes)
 | 
					    img_buffer = BytesIO(img_bytes)
 | 
				
			||||||
    img = Image.open(img_buffer)
 | 
					    img = Image.open(img_buffer)
 | 
				
			||||||
| 
						 | 
					@ -24,7 +40,7 @@ def avg_colors(img):
 | 
				
			||||||
                counter[pixel] += 1
 | 
					                counter[pixel] += 1
 | 
				
			||||||
    return counter.most_common(1)[0][0]
 | 
					    return counter.most_common(1)[0][0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def add_background(img: Image, bg_tuple: tuple) -> Image:
 | 
					def add_background(img: ImageType, bg_tuple: tuple) -> ImageType:
 | 
				
			||||||
    bg = Image.new("RGBA", img.size, bg_tuple)
 | 
					    bg = Image.new("RGBA", img.size, bg_tuple)
 | 
				
			||||||
    bg.paste(img, (0, 0), img)
 | 
					    bg.paste(img, (0, 0), img)
 | 
				
			||||||
    return bg
 | 
					    return bg
 | 
				
			||||||
| 
						 | 
					@ -80,8 +96,18 @@ def get_web_icons():
 | 
				
			||||||
    return list(map(parse_file, apps))
 | 
					    return list(map(parse_file, apps))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def sailify(raw_str, pattern):
 | 
					def sailify(raw_str, pattern):
 | 
				
			||||||
 | 
					    try:
 | 
				
			||||||
 | 
					        # New versions of Sailfish has the url on the icons
 | 
				
			||||||
 | 
					        img = download_icon(raw_str)
 | 
				
			||||||
 | 
					        logging.info("Downloaded from url: " + raw_str)
 | 
				
			||||||
 | 
					    except requests.exceptions.InvalidSchema:
 | 
				
			||||||
 | 
					        # The old ones converted the icon to base64
 | 
				
			||||||
        base64_bytes = raw_str.replace("data:image/png;base64,", "", 1).encode()
 | 
					        base64_bytes = raw_str.replace("data:image/png;base64,", "", 1).encode()
 | 
				
			||||||
        img = base64_to_img(base64_bytes)
 | 
					        img = base64_to_img(base64_bytes)
 | 
				
			||||||
 | 
					        logging.info("Converted from base64")
 | 
				
			||||||
 | 
					    except Exception as e:
 | 
				
			||||||
 | 
					        logging.error(e)
 | 
				
			||||||
 | 
					        raise e
 | 
				
			||||||
    bg_tuple = avg_colors(img)
 | 
					    bg_tuple = avg_colors(img)
 | 
				
			||||||
    img = add_background(img, bg_tuple)
 | 
					    img = add_background(img, bg_tuple)
 | 
				
			||||||
    img = crop_to_circle(img, pattern)
 | 
					    img = crop_to_circle(img, pattern)
 | 
				
			||||||
| 
						 | 
					@ -93,12 +119,17 @@ def sailify(raw_str, pattern):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def backup_icon(app):
 | 
					def backup_icon(app):
 | 
				
			||||||
    if not os.path.exists(app["path"] + "backup"):
 | 
					    if not os.path.exists(app["path"] + "backup"):
 | 
				
			||||||
        shutil.copyfile(app["path"], app["path"] + "_backup")
 | 
					        backup_path = app["path"] + "_backup"
 | 
				
			||||||
 | 
					        shutil.copyfile(app["path"], backup_path)
 | 
				
			||||||
 | 
					        logging.info("Icon backed up on: " + backup_path)
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        logging.info("Backup already exists")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def save_icon(app):
 | 
					def save_icon(app):
 | 
				
			||||||
    new_content = deparse_file(app)
 | 
					    new_content = deparse_file(app)
 | 
				
			||||||
    with open(app["path"], "w") as f:
 | 
					    with open(app["path"], "w") as f:
 | 
				
			||||||
        f.write(new_content)
 | 
					        f.write(new_content)
 | 
				
			||||||
 | 
					    logging.info("Icon saved on: " + app["path"])
 | 
				
			||||||
    return True
 | 
					    return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue