Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay on startup #8

Open
fossfreedom opened this issue Jun 23, 2020 · 8 comments
Open

Delay on startup #8

fossfreedom opened this issue Jun 23, 2020 · 8 comments
Assignees
Labels
desktop enhancement New feature or request Vala Issued related to vala or custom widget

Comments

@fossfreedom
Copy link
Contributor

fossfreedom commented Jun 23, 2020

There is a slight but notable delay on each startup of the app.

EDIT: On a much slower laptop the app takes 1-2 seconds to start.

This is because the whole menu has to be reread and displayed.

Suggested enhancement is to have lightpad run via an autostart file - initially hidden.

Then when lightpad is run via the keybinding - lightpad is made visible rather than starting from scratch.

@libredeb libredeb self-assigned this Jun 26, 2020
@libredeb libredeb added desktop enhancement New feature or request Vala Issued related to vala or custom widget labels Jun 26, 2020
@libredeb
Copy link
Owner

@fossfreedom thank you dude! I'm working on it... I have been doing some proofs of concept and they have concluded successfully. I have to think a way to include the initial startup of LightPad along with the system boot. Can you think of something? I estimate that with a systemd unit it can be solved, but I'm not sure.

@fossfreedom
Copy link
Contributor Author

Hmm.

I was thinking more along the lines of a regular auto start file (/etc/xdg/autostart)

E.g. in the autostart .desktop file

Exec=com.github.libredeb.lightpad --autostart

Thus lightpad will start but when it sees the autostart 1st parameter it would not create the desktop overlay (or will but immediately hide it).

It would then setup a dbus session listening.

Then when a regular com.github.libredeb.lightpad is run via the shortcut key it will look to see if another process of the same name is running. If it detects another process it sends a dbus message before exiting.

The hidden process that is listening will make the desktop overlay window visible.

When an app is run or esc is pressed, instead of the app closing, the overlay window is hidden.

@kareemkasem
Copy link

same here. is there any way to make it run on start up yet ?

@libredeb
Copy link
Owner

libredeb commented Jan 4, 2021

@fossfreedom yes... I need to practice and do some proof of concept with dbus. The solution is in that way!
@kareemkasem not yet. I need to learn dbus session to send messages between the app and dbus.

Also I thinking in migrate LightPad to LibHandy to add a more natural touch screen support.

@fossfreedom
Copy link
Contributor Author

Quick example of dbus here

https://github.com/UbuntuBudgie/budgie-extras/blob/master/budgie-extras-daemon/src/dbus.vala

So you set up dbus with a given session name and own it.

From the client side you can call a dbus method (e.g. ResetLayout) as per https://github.com/UbuntuBudgie/budgie-extras/blob/master/budgie-extras-daemon/src/invoke.py

Just note - methods are case sensitive - so whether you are using python or vala - make sure you define & call methods with their case-sensitive name.

@libredeb
Copy link
Owner

libredeb commented Jan 6, 2021

@fossfreedom thanks for the links and documentation. Yes, i know how to develop in both languages... I'll be careful of what you say. Let me try to code something functional first. Regards!

@pi-dev500
Copy link

I personally use a Raspberry Pi 4 and the app can take up to 10 seconds to start. I was thinking of doing a background preload with Python before seeing this issue. So I currently have a script which generate a json file like this:

[{'name': 'Workspaces', 'icon': 'org.xfce.workspaces', 'description': 'Configure layout, names and margins', 'terminal': False, 'command': 'xfwm4-workspace-settings', 'desktop_file': '/usr/share/applications/xfce-workspaces-settings.desktop'},{'name': 'Force Quit...', 'icon': 'Quit', 'description': '', 'terminal': False, 'command': 'xkill', 'desktop_file': '/home/pi-dev500/.local/share/applications/xkill.desktop'},{'name': 'Screensaver', 'icon': 'xscreensaver', 'description': 'Change screensaver properties', 'terminal': False, 'command': 'xscreensaver-demo', 'desktop_file': '/usr/share/applications/xscreensaver-properties.desktop'},{'name': 'Help', 'icon': 'org.gnome.Yelp', 'description': 'Get help with GNOME', 'terminal': False, 'command': 'yelp %u', 'desktop_file': '/usr/share/applications/yelp.desktop'}]
but I need to know how to integrate that in DesktopEntries.vala or another file. The problem is that I don't understand properly the code (I never used vala) Have you any ideas ?

@pi-dev500
Copy link

My python script(only 1 sec to run it):

#!/usr/bin/pypy
import subprocess
import os
import sys
import json
def parse_desktop_file(desktop_file_path,xdg):
    with open(desktop_file_path, "r") as f:
        desktop_file = f.read()

    name = get_value(desktop_file, "Name")
    description = get_value(desktop_file, "Comment")
    terminal = get_value(desktop_file, "Terminal")
    command = get_value(desktop_file, "Exec")
    icon = get_value(desktop_file, "Icon")
    desktop_file = os.path.abspath(desktop_file_path)
    onlyshowin = get_value(desktop_file, "OnlyShowIn")
    if name == "" or (not xdg in onlyshowin and not onlyshowin==""):
        quit(0)
    return {
        "name": name,
        "icon": icon,
        "description": description,
        "terminal": terminal.lower() == "true",
        "command": command,
        "desktop_file": desktop_file
    } 

def get_value(desktop_file, key):
    for line in desktop_file.split("\n"):
        line = line.strip()
        if line.startswith(key + "="):
            return line[len(key) + 1:]
    return ""

if __name__ == "__main__":
    print("[")
    command = 'bash -c "ls /usr/share/applications && ls /usr/local/share/applications && ls $HOME/.local/share/applications" | grep "\.desktop" | uniq | sort'
    app_list=subprocess.check_output(command, shell=True, universal_newlines=True)
    for filename in app_list.split('\n'):
        if not filename:
            continue  # Ignorer les lignes vides
        if os.path.exists(os.path.join(os.environ['HOME'], '.local/share/applications', filename)):
            filepath = os.path.join(os.environ['HOME'], '.local/share/applications', filename)
        elif os.path.exists(os.path.join('/usr/share/applications', filename)):
            filepath = os.path.join('/usr/share/applications', filename)
        elif os.path.exists(os.path.join('/usr/local/share/applications', filename)):
            filepath = os.path.join('/usr/local/share/applications', filename)
        else:
            continue
        result = parse_desktop_file(filepath,sys.argv[1])
        print(str(result) + ",")
    print("]")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop enhancement New feature or request Vala Issued related to vala or custom widget
Projects
None yet
Development

No branches or pull requests

4 participants