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

Super heavy pull request: fixes multiple issues, refactors code and adds features #14

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
220 changes: 214 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
.idea/
tmp/

### PyCharm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml

# Sensitive or high-churn files:
.idea/dataSources/
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

# Gradle:
.idea/gradle.xml
.idea/libraries

# Mongo Explorer plugin:
.idea/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### PyCharm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr


### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand All @@ -20,7 +77,6 @@ lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
Expand Down Expand Up @@ -76,19 +132,171 @@ target/
# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
.venv/
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject
.ropeproject


### Django ###
*.pyc
db.sqlite3
media


### Eclipse ###

.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# Eclipse Core
.project

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/


### NetBeans ###
nbproject/private/
build/
nbbuild/
dist/
nbdist/
.nb-gradle/


### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml

# Sensitive or high-churn files:
.idea/dataSources/
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

# Gradle:
.idea/gradle.xml
.idea/libraries

# Mongo Explorer plugin:
.idea/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr


### Intellij+iml ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:

# Sensitive or high-churn files:

# Gradle:

# Mongo Explorer plugin:

## File-based project format:

## Plugin-specific files:

# IntelliJ

# mpeltonen/sbt-idea plugin

# JIRA plugin

# Crashlytics plugin (for Android Studio and IntelliJ)

### Intellij+iml Patch ###
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

*.iml
modules.xml
.idea/misc.xml
*.ipr
4 changes: 0 additions & 4 deletions InstantLyrics.py

This file was deleted.

File renamed without changes.
Empty file added InstantLyrics/app/__init__.py
Empty file.
99 changes: 99 additions & 0 deletions InstantLyrics/app/appIndicator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# !/usr/bin/python3
# coding: utf-8

import signal
import threading

import dbus
import gi
from dbus.mainloop.glib import DBusGMainLoop

gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')

from gi.repository import AppIndicator3 as appindicator
from gi.repository import Gtk
import os

from InstantLyrics.app.settings import APPINDICATOR_ID
from InstantLyrics.app.windows import LyricsWindow, PreferenceWindow
from InstantLyrics import utils


DBusGMainLoop(set_as_default=True)
ICON_PATH = utils.get_default_icon_path() # full path
LOCAL_LYRICS_PATH = os.path.join(
os.getenv("HOME"),
".local", "Instant-Lyrics", "lyrics"
)


def list_music_apps():
apps = []
session_bus = dbus.SessionBus()
for service in session_bus.list_names():
if service[:22] == "org.mpris.MediaPlayer2":
apps.append(service[23:])

return apps


class AppIndicator:
def __init__(self):
signal.signal(signal.SIGINT, signal.SIG_DFL)

bus = dbus.SessionBus()

bus.add_signal_receiver(self.build_menu, path="/org/mpris/MediaPlayer2")

self.indicator = appindicator.Indicator.new(
APPINDICATOR_ID, ICON_PATH,
appindicator.IndicatorCategory.SYSTEM_SERVICES)
self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
self.build_menu()

self.Config = utils.get_config()

Gtk.main()

def build_menu(self, *args):
menu = Gtk.Menu()

item_lyrics = Gtk.MenuItem('Custom Lyrics')
item_lyrics.connect('activate', self.fetch_lyrics)
menu.append(item_lyrics)

for app in list_music_apps():
current = Gtk.MenuItem(app.capitalize() + " lyrics")
current.connect('activate', self.app_lyrics, app)
menu.insert(current, 1)

preferences = Gtk.MenuItem('Preferences')
preferences.connect('activate', self.preferences)
menu.append(preferences)

item_quit = Gtk.MenuItem('Quit')
item_quit.connect('activate', self.quit)
menu.append(item_quit)

menu.show_all()
self.indicator.set_menu(menu)

def fetch_lyrics(self, source):
win = LyricsWindow("get", self)
win.show_all()

def app_lyrics(self, source, app):
win = LyricsWindow("app", self)
win.show_all()

thread = threading.Thread(target=win.get_lyrics, args=(app,))
thread.daemon = True
thread.start()

def preferences(self, source):
win = PreferenceWindow(self)
win.show_all()

def quit(self, source):
Gtk.main_quit()
3 changes: 3 additions & 0 deletions src/settings.py → InstantLyrics/app/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# !/usr/bin/python3
# coding: utf-8

import os

APPINDICATOR_ID = 'lyricsappindicator'
Expand Down
Loading