FractalArt 0.2.0.1 → 0.2.0.2
raw patch · 4 files changed
+145/−4 lines, 4 files
Files
- FractalArt.cabal +13/−4
- README.md +80/−0
- src/FractalArt/ForeignFunctions.hs +17/−0
- src/FractalArt/SimpleCommandParser.hs +35/−0
FractalArt.cabal view
@@ -1,15 +1,17 @@ name: FractalArt-version: 0.2.0.1+version: 0.2.0.2 synopsis: Generates colorful wallpapers-description:- This application generates colorful images as a wallpaper+description: This application generates colorful images as a wallpaper+homepage: https://github.com/TomSmeets/FractalArt license: MIT license-file: LICENSE-author: Tom+author: Tom Smeets maintainer: Tom.TSmeets@Gmail.com+copyright: 2016 Tom Smeets category: Graphics build-type: Simple cabal-version: >=1.10+extra-source-files: README.md executable FractalArt main-is: Main.hs@@ -32,5 +34,12 @@ , vector , JuicyPixels hs-source-dirs: src+ other-modules:+ FractalArt.SimpleCommandParser+ FractalArt.ForeignFunctions default-language: Haskell2010 ghc-options: -O2++source-repository head+ type: git+ location: git://github.com/TomSmeets/FractalArt.git
+ README.md view
@@ -0,0 +1,80 @@+Fractal Art+=============+This program generates colorful Wallpapers.++# Usage+These are optional++It automatically detects your screen resolution.++| Command | Argument | Description | Default |+|--------------|----------|---------------------------------------------|-------------------------------|+| -w, --width | Integer | sets width of the generated image | Screen Width |+| -h, --height | Integer | sets height of the generated image | Screen Height |+| -f, --file | Path | specify filename and path | ~/.fractalart/wallpaper.bmp |+| -n, --no-bg | | don't set the wallpaper | |++# Installation++####Arch Linux+++This package is available in the AUR as fractalart-git. ++####Building manually++Make sure you have [stack](http://docs.haskellstack.org/en/stable/install_and_upgrade/) and zlib installed.++Then do:+```shell+$ git clone https://github.com/TomSmeets/FractalArt.git+$ cd FractalArt+$ stack install+```++Your executable will copied to your [local-bin path](http://docs.haskellstack.org/en/stable/install_and_upgrade/#path).+For Unix systems this path is `$HOME/.local/bin` and on Windows `%APPDATA%\local\bin`.++# Windows+If you want a new wallpaper each time you start your PC,+put the executable into a startup folder.++For Windows 7 this folder is located at:+`%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup`++but can also be found in: `Start Menu -> All Programs`++# Linux+On Linux you have to set your wallpaper path to: `~/.fractalart/wallpaper.bmp`++And somehow run the program on startup.++## Gnome+You can add `~/.cabal/bin` to your path++or move `dist/build/FractalArt/FractalArt` inside `/usr/local/bin/`+++Create `~/.config/autostart/fractalart.desktop` ++```+[Desktop Entry]+Name=FractalArt+GenericName=Fractal Art+Comment=Generate Wallpapers+Exec=FractalArt+Terminal=false+Type=Application+Categories=Graphics+```++This will execute the command `FractalArt` after login.++To set your wallpaper path run:++`gsettings set org.gnome.desktop.background picture-uri file://$HOME/.fractalart/wallpaper.bmp`++# Example images+++
+ src/FractalArt/ForeignFunctions.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE ForeignFunctionInterface #-}+module FractalArt.ForeignFunctions (setWallpaper, getScreenSize) where++import Foreign.C++foreign import ccall unsafe "set_wallpaper" set_wallpaper' :: CString -> IO ()+foreign import ccall unsafe "get_screen_size_x" get_screen_size_x' :: IO Int+foreign import ccall unsafe "get_screen_size_y" get_screen_size_y' :: IO Int++setWallpaper :: String -> IO ()+setWallpaper path = withCString path set_wallpaper'++getScreenSize :: IO (Int, Int)+getScreenSize = do+ x <- get_screen_size_x'+ y <- get_screen_size_y'+ return (x, y)
+ src/FractalArt/SimpleCommandParser.hs view
@@ -0,0 +1,35 @@+module FractalArt.SimpleCommandParser where++import Data.Char++type Args = [String]++type Name = String+type ShortName = Char+type Parse a = String -> Maybe a++data Arg a = Arg Name ShortName (Parse a) +data Flag = Flag Name ShortName ++def :: Maybe a -> a -> a+def (Just x) _ = x+def Nothing d = d++search :: String -> Char -> Args -> [String]+search name sname = dropWhile (not . comp)+ where+ comp a = map toLower a == ("--" ++ map toLower name)+ || a == ("-" ++ [sname]) ++parseFlag :: Flag -> Args -> Bool+parseFlag (Flag name sname) args = res+ where+ res = not $ null $ search name sname args++parseArg :: Arg a -> Args -> Maybe a+parseArg (Arg name sname f) args = res >>= f+ where+ res = case search name sname args of+ (_:arg:_) -> Just arg+ _ -> Nothing+