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

Issue #178 Fix #179

Open
wants to merge 2 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
43 changes: 43 additions & 0 deletions delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# Define project directory and paths
PROJECT_DIR="$HOME/fluxgui"
ICON_DIR="$PROJECT_DIR/icons/hicolor"
DESKTOP_ENTRY_PATH="$HOME/.local/share/applications/fluxgui.desktop"
ICON_CACHE_DIR="$HOME/.local/share/icons/hicolor"

# Step 1: Remove the fluxgui project directory
if [ -d "$PROJECT_DIR" ]; then
echo "Removing project directory at $PROJECT_DIR..."
rm -rf "$PROJECT_DIR"
else
echo "Project directory $PROJECT_DIR does not exist. Skipping..."
fi

# Step 2: Remove icons specific to fluxgui from user's icon directory
echo "Removing fluxgui icons from $ICON_CACHE_DIR..."
for size in 16x16 22x22 24x24 32x32 48x48 64x64 96x96; do
ICON_PATH="$ICON_CACHE_DIR/$size/apps/fluxgui.svg"
if [ -f "$ICON_PATH" ]; then
rm "$ICON_PATH"
echo "Removed icon at $ICON_PATH"
else
echo "No icon found at $ICON_PATH. Skipping..."
fi
done

# Step 3: Refresh the icon cache to reflect icon removal
echo "Updating icon cache..."
gtk-update-icon-cache "$ICON_CACHE_DIR"

# Step 4: Remove the .desktop entry from user's applications menu
if [ -f "$DESKTOP_ENTRY_PATH" ]; then
echo "Removing desktop entry at $DESKTOP_ENTRY_PATH..."
rm "$DESKTOP_ENTRY_PATH"
else
echo "Desktop entry $DESKTOP_ENTRY_PATH does not exist. Skipping..."
fi

# Final confirmation
echo "All fluxgui-related files and configurations have been removed."

39 changes: 28 additions & 11 deletions download-xflux.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
#!/usr/bin/env python3

from sys import maxsize
import os
import subprocess
from sys import maxsize

# There is similar code in ./debian/postinst. If you are changing this
# you probably want to change that too.
def download_xflux():
# Determines which is the appropriate executable for 32-bit
# Determine appropriate executable based on system architecture
if maxsize == 2**31 - 1:
print("Downloading 32-bit xflux ...")
urls = ["https://justgetflux.com/linux/xflux-pre.tgz"]
elif maxsize == 2**63 - 1:
print("Downloading 64-bit xflux ...")
urls = ["https://justgetflux.com/linux/xflux64.tgz",
"https://justgetflux.com/linux/xflux11.tgz",
"https://justgetflux.com/linux/xflux12.tgz"]
urls = [
"https://justgetflux.com/linux/xflux64.tgz",
"https://justgetflux.com/linux/xflux11.tgz",
"https://justgetflux.com/linux/xflux12.tgz"
]
else:
raise Exception("Unexpected maxsize = %i!" % maxsize)
raise Exception(f"Unexpected maxsize = {maxsize}!")

tarchive = "./xflux.tgz"
for url in urls:
tarchive = "/tmp/xflux.tgz"
subprocess.call(['wget', url, '-O', tarchive])
subprocess.call(['tar', '-xvf', tarchive])
try:
print(f"Attempting to download from {url}...")
# Download the file
result = subprocess.run(['wget', url, '-O', tarchive], check=True)
if result.returncode == 0 and os.path.exists(tarchive):
# Extract the archive if the download succeeded
print(f"Extracting {tarchive}...")
subprocess.run(['tar', '-xvf', tarchive, '-C', '/usr/local/bin'], check=True)
print("Download and extraction completed.")
break
except subprocess.CalledProcessError:
print(f"Failed to download from {url}. Trying next URL if available.")
except Exception as e:
print(f"An error occurred: {e}")

else:
print("All download attempts failed.")

if __name__ == '__main__':
download_xflux()
71 changes: 71 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

# Define project directory
PROJECT_DIR="$HOME/fluxgui"
ICON_DIR="$PROJECT_DIR/icons/hicolor"
DESKTOP_ENTRY_PATH="$HOME/.local/share/applications/fluxgui.desktop"

# Step 1: Set up a virtual environment
echo "Setting up a virtual environment..."
python3 -m venv "$PROJECT_DIR/venv"
source "$PROJECT_DIR/venv/bin/activate"

# Step 2: Install dependencies and fluxgui package
echo "Installing Python dependencies and the fluxgui package..."
python3 -m pip install -r "$PROJECT_DIR/requirements.txt"
python3 -m pip install .

# Step 3: Download and extract xflux
echo "Downloading and extracting xflux..."
cd "$PROJECT_DIR"
wget -O xflux.tgz https://justgetflux.com/linux/xflux64.tgz
tar -xzf xflux.tgz
chmod +x xflux
rm xflux.tgz

# Step 4: Move xflux to the virtual environment's bin directory
if [ -f "$PROJECT_DIR/xflux" ]; then
echo "Setting up xflux..."
mv "$PROJECT_DIR/xflux" "$PROJECT_DIR/venv/bin/xflux"
fi

# Step 5: Make main.py executable (if not already)
chmod +x "$PROJECT_DIR/src/fluxgui/main.py"

# Step 6: Copy preferences.glade to the site-packages directory
echo "Copying preferences.glade to site-packages directory..."
SITE_PACKAGES_DIR="$PROJECT_DIR/venv/lib/python3.12/site-packages/fluxgui"
mkdir -p "$SITE_PACKAGES_DIR"
cp "$PROJECT_DIR/src/fluxgui/preferences.glade" "$SITE_PACKAGES_DIR/"

# Step 7: Set up application icons
echo "Setting up icons..."
for size in 16x16 22x22 24x24 32x32 48x48 64x64 96x96; do
mkdir -p "$HOME/.local/share/icons/hicolor/$size/apps/"
cp "$ICON_DIR/$size/apps/fluxgui.svg" "$HOME/.local/share/icons/hicolor/$size/apps/fluxgui.svg"
done
gtk-update-icon-cache "$HOME/.local/share/icons/hicolor/"

# Step 8: Create .desktop entry for application launcher with explicit icon path
echo "Creating .desktop entry for fluxgui..."
mkdir -p "$HOME/.local/share/applications"
cat > "$DESKTOP_ENTRY_PATH" <<EOL
[Desktop Entry]
Version=1.0
Name=FluxGUI
Comment=f.lux indicator applet - better lighting for your computer
Exec=$PROJECT_DIR/venv/bin/python -m fluxgui.main
Icon=$HOME/.local/share/icons/hicolor/48x48/apps/fluxgui.svg
Terminal=false
Type=Application
Categories=Utility;
EOL

# Step 9: Rebuild the icon cache and refresh
echo "Rebuilding the icon cache and refreshing desktop entries..."
gtk-update-icon-cache "$HOME/.local/share/icons/hicolor/"
update-desktop-database "$HOME/.local/share/applications"

# Step 10: Final cleanup and deactivation
echo "Installation complete. You can launch FluxGUI from your applications menu."
deactivate
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
requests
pygobject
pycairo
pexpect
pyxdg
153 changes: 57 additions & 96 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,101 +1,62 @@
#!/usr/bin/env python3
# setup.py

from distutils.core import setup
from distutils.log import info
import distutils.command.install_data
import os, os.path, subprocess, sys
from setuptools import setup, find_packages
from setuptools.command.install import install
import os
import subprocess

if os.path.abspath(os.path.curdir) != os.path.abspath(os.path.dirname(__file__)):
print("The 'setup.py' must be run in its containing directory!")
sys.exit(1)

# Set an appropriate umask for global installs. The 'setup.py' install
# respects the umask, even if it results in files only root can read
# in a global install :P
os.umask(0o022)

# Set appropriate permissions on all local files in the repo. The
# 'setup.py' install preserves permissions on copied files, which
# creates problems for global installs :P
#
# There is a fancier solution at
# https://stackoverflow.com/a/25761434/470844 that uses
# 'self.get_outputs()' in a custom 'distutils.command.install'
# subclass to only modify permissions of files that 'setup.py'
# installed.
subprocess.call(['chmod', '-R', 'a+rX', '.'])

# On Ubuntu 18.04 both '/usr/local/share/glib-2.0/schemas' (global
# install) and '~/.local/share/glib-2.0/schemas' (local '--user'
# install) are on the default search path for glib schemas. The global
# search paths are in '$XDG_DATA_DIRS'.
gschema_dir_suffix = 'share/glib-2.0/schemas'

data_files = [
('share/icons/hicolor/16x16/apps', ['icons/hicolor/16x16/apps/fluxgui.svg']),
('share/icons/hicolor/22x22/apps', ['icons/hicolor/22x22/apps/fluxgui.svg']),
('share/icons/hicolor/24x24/apps', ['icons/hicolor/24x24/apps/fluxgui.svg']),
('share/icons/hicolor/32x32/apps', ['icons/hicolor/32x32/apps/fluxgui.svg']),
('share/icons/hicolor/48x48/apps', ['icons/hicolor/48x48/apps/fluxgui.svg']),
('share/icons/hicolor/64x64/apps', ['icons/hicolor/64x64/apps/fluxgui.svg']),
('share/icons/hicolor/96x96/apps', ['icons/hicolor/96x96/apps/fluxgui.svg']),
('share/icons/ubuntu-mono-dark/status/16', ['icons/ubuntu-mono-dark/status/16/fluxgui-panel.svg']),
('share/icons/ubuntu-mono-dark/status/22', ['icons/ubuntu-mono-dark/status/22/fluxgui-panel.svg']),
('share/icons/ubuntu-mono-dark/status/24', ['icons/ubuntu-mono-dark/status/24/fluxgui-panel.svg']),
('share/icons/ubuntu-mono-light/status/16', ['icons/ubuntu-mono-light/status/16/fluxgui-panel.svg']),
('share/icons/ubuntu-mono-light/status/22', ['icons/ubuntu-mono-light/status/22/fluxgui-panel.svg']),
('share/icons/ubuntu-mono-light/status/24', ['icons/ubuntu-mono-light/status/24/fluxgui-panel.svg']),
('share/icons/Adwaita/16x16/status', ['icons/Adwaita/16x16/status/fluxgui-panel.svg']),
('share/icons/breeze/status/22', ['icons/breeze/status/22/fluxgui-panel.svg']),
('share/icons/breeze-dark/status/22', ['icons/breeze-dark/status/22/fluxgui-panel.svg']),
('share/icons/elementary/status/24', ['icons/elementary/status/24/fluxgui-panel.svg']),
('share/icons/elementary-xfce/panel/22', ['icons/elementary-xfce/panel/22/fluxgui-panel.svg']),
('share/icons/elementary-xfce-dark/panel/22', ['icons/elementary-xfce-dark/panel/22/fluxgui-panel.svg']),
('share/applications', ['desktop/fluxgui.desktop']),
(gschema_dir_suffix, ['apps.fluxgui.gschema.xml'])]

scripts = ['fluxgui']

if (os.path.exists("xflux")):
# Unlike for 'scripts', the 'setup.py' doesn't modify the
# permissions on files installed using 'data_files', so we need to
# set the permissions ourselves.
subprocess.call(['chmod', 'a+rx', 'xflux'])
data_files.append(('bin', ['xflux']))
else:
print("""WARNING: if you are running 'python setup.py' manually, and not as
part of Debian package creation, and you intend to use the DEPRECATED xflux backend,
then you need to download the 'xflux' binary separately. You can do this by running

./download-xflux.py

before running 'setup.py'.""")

class install_data(distutils.command.install_data.install_data):
class CustomInstall(install):
def run(self):
super().run()

# Compile '*.gschema.xml' to update or create 'gschemas.compiled'.
if os.environ.get('DISABLE_GSCHEMAS_COMPILED') is None:
info("compiling gsettings schemas; set DISABLE_GSCHEMAS_COMPILED env var to disable")
gschema_dir = os.path.join(self.install_dir, gschema_dir_suffix)
self.spawn(["glib-compile-schemas", gschema_dir])

setup(name = "f.lux indicator applet",
version = "2.0.1pre",
description = "f.lux indicator applet - better lighting for your computer",
author = "Kilian Valkhof, Michael and Lorna Herf, Josh Winters",
author_email = "[email protected]",
url = "http://www.stereopsis.com/flux/",
license = "MIT license",
package_dir = {'fluxgui' : 'src/fluxgui'},
packages = ["fluxgui", "fluxgui.settings", "fluxgui.controller", "fluxgui.tabs"],
package_data = {"fluxgui" : ["*.glade"] },
data_files=data_files,
scripts = scripts,
long_description = """f.lux indicator applet is an indicator applet to
control xflux, an application that makes the color of your computer's
display adapt to the time of day, warm at nights and like sunlight during
the day""",
cmdclass = {'install_data': install_data}
)
print("Compiling GSettings schemas")
gschema_dir = os.path.join(self.install_lib, 'share/glib-2.0/schemas')
subprocess.call(["glib-compile-schemas", gschema_dir])

setup(
name="fluxgui",
version="2.0.1",
description="f.lux indicator applet - better lighting for your computer",
author="Kilian Valkhof, Michael and Lorna Herf, Josh Winters",
author_email="[email protected]",
url="https://github.com/xflux-gui/fluxgui",
license="MIT",
packages=find_packages(where="src"),
package_dir={'': 'src'},
include_package_data=True,

data_files=[
('share/icons/hicolor/16x16/apps', ['icons/hicolor/16x16/apps/fluxgui.svg']),
('share/icons/hicolor/22x22/apps', ['icons/hicolor/22x22/apps/fluxgui.svg']),
('share/icons/hicolor/24x24/apps', ['icons/hicolor/24x24/apps/fluxgui.svg']),
('share/icons/hicolor/32x32/apps', ['icons/hicolor/32x32/apps/fluxgui.svg']),
('share/icons/hicolor/48x48/apps', ['icons/hicolor/48x48/apps/fluxgui.svg']),
('share/icons/hicolor/64x64/apps', ['icons/hicolor/64x64/apps/fluxgui.svg']),
('share/icons/hicolor/96x96/apps', ['icons/hicolor/96x96/apps/fluxgui.svg']),
('share/icons/ubuntu-mono-dark/status/16', ['icons/ubuntu-mono-dark/status/16/fluxgui-panel.svg']),
('share/icons/ubuntu-mono-dark/status/22', ['icons/ubuntu-mono-dark/status/22/fluxgui-panel.svg']),
('share/icons/ubuntu-mono-dark/status/24', ['icons/ubuntu-mono-dark/status/24/fluxgui-panel.svg']),
('share/icons/ubuntu-mono-light/status/16', ['icons/ubuntu-mono-light/status/16/fluxgui-panel.svg']),
('share/icons/ubuntu-mono-light/status/22', ['icons/ubuntu-mono-light/status/22/fluxgui-panel.svg']),
('share/icons/ubuntu-mono-light/status/24', ['icons/ubuntu-mono-light/status/24/fluxgui-panel.svg']),
('share/icons/Adwaita/16x16/status', ['icons/Adwaita/16x16/status/fluxgui-panel.svg']),
('share/icons/breeze/status/22', ['icons/breeze/status/22/fluxgui-panel.svg']),
('share/icons/breeze-dark/status/22', ['icons/breeze-dark/status/22/fluxgui-panel.svg']),
('share/icons/elementary/status/24', ['icons/elementary/status/24/fluxgui-panel.svg']),
('share/icons/elementary-xfce/panel/22', ['icons/elementary-xfce/panel/22/fluxgui-panel.svg']),
('share/icons/elementary-xfce-dark/panel/22', ['icons/elementary-xfce-dark/panel/22/fluxgui-panel.svg']),
('share/applications', ['desktop/fluxgui.desktop']),
('share/glib-2.0/schemas', ['apps.fluxgui.gschema.xml'])
],
install_requires=[
"requests>=2.0",
"pygobject>=3.0",
],
entry_points={
'console_scripts': [
'fluxgui = fluxgui.main:main', # Entry point to main function in fluxgui.main module
],
},
cmdclass={'install': CustomInstall},
python_requires=">=3.10",
)
Loading