diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/build | 17 | ||||
| -rw-r--r-- | examples/cirrus.yml | 39 | ||||
| -rw-r--r-- | examples/gh-ci.yml | 77 | ||||
| -rwxr-xr-x | examples/padding-icon.sh | 56 | ||||
| -rwxr-xr-x | examples/status.sh | 56 | ||||
| -rw-r--r-- | examples/xmobar.config | 39 | ||||
| -rw-r--r-- | examples/xmobar.el | 164 | ||||
| -rw-r--r-- | examples/xmobar.hs | 77 | ||||
| -rw-r--r-- | examples/xmonadpropwrite.hs | 41 | 
9 files changed, 0 insertions, 566 deletions
diff --git a/examples/build b/examples/build deleted file mode 100644 index 9e9eb72..0000000 --- a/examples/build +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/bash - -# An example build script that directs ghc to use a temporary directory for its -# intermediate files instead of writing them into XMOBAR_CONFIG_DIR.  This -# allows using a read-only XMOBAR_CONFIG_DIR.  To use this script, place it in -# XMOBAR_CONFIG_DIR and call it "build". - -bin=$1 -object_dir=$(mktemp -d) - -default_build_args=(--make xmobar.hs -i -ilib -fforce-recomp -main-is main -v0 -o "$bin" -threaded -rtsopts -with-rtsopts -V0) # From src/Xmobar/App/Compile.hs -extra_build_args=(-odir "$object_dir" -hidir "$object_dir") - -ghc "${default_build_args[@]}" "${extra_build_args[@]}" -status=$? -rm -r "$object_dir" -exit $status diff --git a/examples/cirrus.yml b/examples/cirrus.yml deleted file mode 100644 index 6105386..0000000 --- a/examples/cirrus.yml +++ /dev/null @@ -1,39 +0,0 @@ -freebsd_instance: -  image_family: freebsd-13-0 - -build_task: -  env: -    CONFIG: "--enable-tests --enable-benchmarks -fwith_mpd -fwith_xft" - -  # caches the freebsd package downloads -  # saves probably just a couple of seconds, but hey... -  pkg_cache: -    folder: /var/cache/pkg - -  install_script: -    - pkg install -y ghc hs-hlint xorg-libraries hs-cabal-install git autoconf libmpdclient pkgconf libXft hs-hspec-discover - -  # cache the hackage index file and downloads which are -  # cabal v2-update downloads an incremental update, so we don't need to keep this up2date -  packages_cache: -    # warning: don't use ~/.cabal here, this will break the cache -    folder: /.cabal/packages -    reupload_on_changes: false - -  # cache the dependencies built by cabal -  # they have to be uploaded on every change to make the next build fast -  store_cache: -    # warning: don't use ~/.cabal here, this will break the cache -    folder: /.cabal/store -    fingerprint_script: cat xmobar.cabal -    reupload_on_changes: true - -  build_script: -    - cabal v2-update -    - timeout 1800 cabal v2-build -j4 $CONFIG || (($?==124)) - -  lint_script: -    - hlint src - -  test_script: -    - cabal v2-test -j4 $CONFIG diff --git a/examples/gh-ci.yml b/examples/gh-ci.yml deleted file mode 100644 index e720e9e..0000000 --- a/examples/gh-ci.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: Haskell CI (PRs) - -on: -  pull_request: -    branches: [ master ] -  workflow_dispatch: - -jobs: -  build: -    runs-on: ubuntu-latest -    strategy: -      matrix: -        cabal: ["3.2"] -        ghc: ["8.4", "8.6", "8.8.3", "8.10"] -    env: -      CONFIG: "--enable-tests --enable-benchmarks -fall_extensions" - -    steps: -    - uses: actions/checkout@v2 -    - uses: actions/setup-haskell@v1 -      with: -        ghc-version: ${{ matrix.ghc }} -        cabal-version: ${{ matrix.cabal }} - -    - name: Cache -      uses: actions/cache@v1 -      env: -        cache-name: cache-cabal -      with: -        path: ~/.cabal -        key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} -        restore-keys: | -          ${{ runner.os }}-build-${{ env.cache-name }}- -          ${{ runner.os }}-build- -          ${{ runner.os }}- - -    - name: Install packages -      run: | -        sudo apt-get update -        sudo apt-get install -y xorg-dev -        sudo apt-get install -y libasound2-dev libxpm-dev libmpd-dev libxrandr-dev -        sudo apt-get install -y happy c2hs hspec-discover - -    - name: Install dependencies -      run: | -        cabal update -        cabal build --dependencies-only $CONFIG - -    - name: Build -      run: cabal build $CONFIG - -    - name: Run hlint -      run: | -        wget https://raw.github.com/ndmitchell/hlint/master/misc/travis.sh -        sh ./travis.sh src -    - name: Run tests -      run: cabal test - -  # build-freebsd: -  #   runs-on: macos-latest -  #   env: -  #     CONFIG: "--enable-tests --enable-benchmarks -fwith_xft -fwith_mpd" - -  #   steps: -  #   - uses: actions/checkout@v2 - -  #   - name: Install dependencies -  #     uses: vmactions/freebsd-vm@v0.1.5 -  #     with: -  #       usesh: true -  #       prepare: pkg install -y ghc hs-hlint xorg-libraries hs-cabal-install git autoconf -  #       run: | -  #         cabal update -  #         cabal build --dependencies-only $CONFIG -  #         cabal build $CONFIG -  #         hlint -  #         cabal test diff --git a/examples/padding-icon.sh b/examples/padding-icon.sh deleted file mode 100755 index ec3ada2..0000000 --- a/examples/padding-icon.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -# Detects the width of running window with name given as first -# argument (xprop name '$1') and creates an XPM icon of that width, -# 1px height, and transparent.  Outputs an <icon>-tag for use in -# xmobar to display the generated XPM icon. -# -# Run script from xmobar and trayer: -# `Run Com "/where/ever/padding-icon.sh" ["panel"] "trayerpad" 10` -# and use `%trayerpad%` in your template. -# or, if you're using for instance stalonetray: -# `Run Com "/where/ever/padding-icon.sh" ["stalonetray"] "tray" 10` - -# Very heavily based on Jonas Camillus Jeppensen code -# https://codeberg.org/xmobar/xmobar/issues/239#issuecomment-233206552 - -# Function to create a transparent Wx1 px XPM icon -create_xpm_icon () { -timestamp=$(date) -pixels=$(for i in `seq $1`; do echo -n "."; done) - -cat << EOF > "$2" -/* XPM * -static char * trayer_pad_xpm[] = { -/* This XPM icon is used for padding in xmobar to */ -/* leave room for trayer-srg. It is dynamically   */ -/* updated by by trayer-pad-icon.sh which is run  */ -/* by xmobar.                                     */ -/* Created: ${timestamp} */ -/* <w/cols>  <h/rows>  <colors>  <chars per pixel> */ -"$1 1 1 1", -/* Colors (none: transparent) */ -". c none", -/* Pixels */ -"$pixels" -}; -EOF -} - -# panel window name -pname=${1:-panel} - -# Width of the trayer window -width=$(xprop -name $pname | grep 'program specified minimum size' | cut -d ' ' -f 5) - -# Icon file name -iconfile="/tmp/$pname-padding-${width:-0}px.xpm" - -# If the desired icon does not exist create it -if [ ! -f $iconfile ] -then -    create_xpm_icon $width $iconfile -fi - -# Output the icon tag for xmobar -echo "<icon=${iconfile}/>" diff --git a/examples/status.sh b/examples/status.sh deleted file mode 100755 index 151728b..0000000 --- a/examples/status.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -STATUSPIPE="/tmp/xmobar_status_jrk" - -function isMuted () { -    # retrieve mute status -    # return an arbitrary string for true or nothing at all -    echo -} - -function getPercent () { -    # somehow retrieve the percent value as plain int (e.g. "66") -    echo "66" -} - -function percentBar () { -    local i=1                   res= -          normal=47             high=80 -          fgColor='#657b83'     mutedColor='#cb4b16' -          lowColor='#859900'    midColor='#b58900' -          highColor='#cb4b16' - -          bar="$(echo -ne "\u2588")" -          percent="$( getPercent )" -          muted="$( isMuted )" - -    if [ -n "$muted" ]; then -        res="<fc=$mutedColor>" -    else -        res="<fc=$lowColor>" -    fi - -    while [ $i -lt $percent ]; do -        if   [ $i -eq $normal -a -z "$muted" ]; then -            res+="</fc><fc=$midColor>" -        elif [ $i -eq $high   -a -z "$muted" ]; then -            res+="</fc><fc=$highColor>" -        fi - -        res+=$bar -        i=$((i+1)) -    done - -    res+="</fc><fc=$fgColor>" - -    while [ $i -lt 100 ]; do -        res+='-' -        i=$((i+1)) -    done - -    echo "$res</fc>" -} - -[[ -p $STATUSPIPE ]] || mkfifo $STATUSPIPE - -echo "$( percentBar )" > "$STATUSPIPE" diff --git a/examples/xmobar.config b/examples/xmobar.config deleted file mode 100644 index e951b67..0000000 --- a/examples/xmobar.config +++ /dev/null @@ -1,39 +0,0 @@ -Config { font = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*" -       , additionalFonts = [] -       , borderColor = "black" -       , border = TopB -       , bgColor = "black" -       , fgColor = "grey" -       , alpha = 255 -       , position = Top -       , textOffset = -1 -       , iconOffset = -1 -       , lowerOnStart = True -       , pickBroadest = False -       , persistent = False -       , hideOnStart = False -       , iconRoot = "." -       , allDesktops = True -       , overrideRedirect = True -       , textOutputFormat = Ansi -       , commands = [ Run Weather "EGPF" ["-t","<station>: <tempC>C", -                                          "-L","18","-H","25", -                                          "--normal","green", -                                          "--high","red", -                                          "--low","lightblue"] 36000 -                    , Run Network "eth0" ["-L","0","-H","32", -                                          "--normal","green","--high","red"] 10 -                    , Run Network "eth1" ["-L","0","-H","32", -                                          "--normal","green","--high","red"] 10 -                    , Run Cpu ["-L","3","-H","50", -                               "--normal","green","--high","red"] 10 -                    , Run Memory ["-t","Mem: <usedratio>%"] 10 -                    , Run Swap [] 10 -                    , Run Com "uname" ["-s","-r"] "" 36000 -                    , Run Date "%a %b %_d %Y %H:%M:%S" "date" 10 -                    ] -       , sepChar = "%" -       , alignSep = "}{" -       , template = "%cpu% | %memory% * %swap% | %eth0% - %eth1% }\ -                    \{ <fc=#ee9a00>%date%</fc>| %EGPF% | %uname%" -       } diff --git a/examples/xmobar.el b/examples/xmobar.el deleted file mode 100644 index 905af3d..0000000 --- a/examples/xmobar.el +++ /dev/null @@ -1,164 +0,0 @@ -;; xmobar.el --- Display xmobar text output -*- lexical-binding: t -*- - -;; Copyright 2022 jao <jao@gnu.org> -;; Version: 0.0.1 -;; Package-Requires: ((emacs "28.1")) -;; Keywords: unix - -;; Heavily inspired by Steven Allen's https://github.com/Stebalien/i3bar.el - -;; This file is not part of GNU Emacs. - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING.  If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; Displays the output of an xmobar command in the Emacs mode-line (or tab-line). - -;;; Code: - -(eval-when-compile (require 'cl-lib)) - -(require 'tab-bar) -(require 'xterm-color nil t) - -(defgroup xmobar nil -  "xmobar status display for Emacs." -  :version "0.0.1" -  :group 'mode-line) - -(defcustom xmobar-command '("xmobar" "-TAnsi") -  "The xmobar command and flags." -  :type '(choice (string :tag "Shell Command") -                 (repeat (string)))) - -(defcustom xmobar-tab-bar t -  "Whether to dispaly xmobar output in the tab bar." -  :type 'boolean) - -(defcustom xmobar-tab-split nil -  "Split on this string for `xmobar-left-string' and `xmobar-right-string'." -  :type 'string) - -(defcustom xmobar-tab-bar-format -  '(xmobar-left-string tab-bar-format-align-right xmobar-right-string) -  "Format for the tab bar when `xmobar-tab-bar' is t." -  :type 'list) - -(defvar xmobar--process nil -  "The running xmobar process, if any.") - -(defvar xmobar--left-string "") - -(defvar xmobar-string "" -  "The xmobar string to be displayed in the mode-line or tab-bar.") - -(put 'xmobar-string 'risky-local-variable t) - -(defvar xmobar--colorize-fn -  (if (featurep 'xterm-color) #'xterm-color-filter #'ansi-color-apply)) - -(defvar xmobar--old-tab-format tab-bar-format) - -(defun xmobar-string () xmobar-string) -(defun xmobar-right-string () xmobar-string) -(defun xmobar-left-string () xmobar--left-string) - -;;;###autoload -(define-minor-mode xmobar-mode -  "Display an xmobar in the mode-line." -  :global t :group 'xmobar -  (xmobar--stop) -  (if xmobar-mode -      (progn (if xmobar-tab-bar -                 (progn -                   (setq xmobar--old-tab-format tab-bar-format) -                   (setq tab-bar-format xmobar-tab-bar-format) -                   (tab-bar-mode 1)) -               (or global-mode-string (setq global-mode-string '(""))) -               (unless (memq 'xmobar-string global-mode-string) -                 (setq global-mode-string -                       (append global-mode-string '(xmobar-string))))) -             (xmobar--start)) -    (when xmobar-tab-bar (setq tab-bar-format xmobar--old-tab-format)))) - -(defun xmobar--update (update) -  "Apply an UPDATE to the xmobar bar." -  (when xmobar-mode -    (let* ((str (funcall xmobar--colorize-fn update)) -           (strs (and xmobar-tab-split (split-string str xmobar-tab-split)))) -      (setq xmobar-string (if strs (cadr strs) str) -            xmobar--left-string (or (car strs) ""))) -    (force-mode-line-update t))) - -(defun xmobar--process-filter (proc string) -  "Process output from the xmobar process." -  (let ((buf (process-buffer proc))) -    (when (buffer-live-p buf) -      (with-current-buffer buf -        ;; Write the input to the buffer (might be partial). -        (save-excursion -          (goto-char (process-mark proc)) -          (insert string) -          (set-marker (process-mark proc) (point))) -        (when (string-match-p "\n$" string) -          (xmobar--update (buffer-string)) -          (delete-region (point-min) (point-max))))))) - -(defun xmobar--process-sentinel (proc status) -  "Handle events from the xmobar process (PROC). -If the process has exited, this function stores the exit STATUS in -`xmobar-string'." -  (unless (process-live-p proc) -    (setq xmobar--process nil) -    (let ((buf (process-buffer proc))) -      (when (and buf (buffer-live-p buf)) (kill-buffer buf))) -    (setq xmobar-string (format "xmobar: %s" status) xmobar--left-string ""))) - -(defun xmobar--start () -  "Start xmobar." -  (xmobar--stop) -  (condition-case err -      (setq xmobar--process -            (make-process -             :name "xmobar" -             :buffer " *xmobar process*" -             :stderr " *xmobar stderr*" -             :command (ensure-list xmobar-command) -             :connection-type 'pipe -             :noquery t -             :sentinel #'xmobar--process-sentinel -             :filter #'xmobar--process-filter)) -    (error -     (setq xmobar-string -           (format "starting xmobar: %s" (error-message-string err)) -           xmobar--left-string "")))) - -(defun xmobar--stop () -  "Stop xmobar." -  (when (and xmobar--process (process-live-p xmobar--process)) -    (delete-process xmobar--process)) -  (setq xmobar-string "" xmobar--left-string "")) - -;;;###autoload -(defun xmobar-restart () -  "Restart the xmobar program." -  (interactive) -  (unless xmobar-mode (user-error "The xmobar-mode is not enabled")) -  (xmobar--start)) - -(provide 'xmobar) -;;; xmobar.el ends here diff --git a/examples/xmobar.hs b/examples/xmobar.hs deleted file mode 100644 index f8434fe..0000000 --- a/examples/xmobar.hs +++ /dev/null @@ -1,77 +0,0 @@ ------------------------------------------------------------------------------- --- | --- Copyright: (c) 2018, 2019, 2022 Jose Antonio Ortega Ruiz --- License: BSD3-style (see LICENSE) --- --- Maintainer: jao@gnu.org --- Stability: unstable --- Portability: portable --- Created: Sat Nov 24, 2018 21:03 --- --- --- An example of a Haskell-based xmobar. Compile it with ---   ghc --make -- xmobar.hs --- with the xmobar library installed or simply call: ---   xmobar /path/to/xmobar.hs --- and xmobar will compile and launch it for you and ------------------------------------------------------------------------------- - -import Xmobar - --- Example user-defined plugin - -data HelloWorld = HelloWorld -    deriving (Read, Show) - -instance Exec HelloWorld where -    alias HelloWorld = "hw" -    run   HelloWorld = return "<fc=red>Hello World!!</fc>" - --- Configuration, using predefined monitors as well as our HelloWorld --- plugin: - -config :: Config -config = defaultConfig { -  font = "xft:Sans Mono-9" -  , additionalFonts = [] -  , borderColor = "black" -  , border = TopB -  , bgColor = "black" -  , fgColor = "grey" -  , alpha = 255 -  , position = Top -  , textOffset = -1 -  , iconOffset = -1 -  , lowerOnStart = True -  , pickBroadest = False -  , persistent = False -  , hideOnStart = False -  , iconRoot = "." -  , allDesktops = True -  , overrideRedirect = True -  , textOutputFormat = Ansi -  , commands = [ Run $ Weather "EGPH" ["-t","<station>: <tempC>C", -                                        "-L","18","-H","25", -                                        "--normal","green", -                                        "--high","red", -                                        "--low","lightblue"] 36000 -               , Run $ Network "eth0" ["-L","0","-H","32", -                                        "--normal","green","--high","red"] 10 -               , Run $ Network "eth1" ["-L","0","-H","32", -                                        "--normal","green","--high","red"] 10 -               , Run $ Cpu ["-L","3","-H","50", -                             "--normal","green","--high","red"] 10 -               , Run $ Memory ["-t","Mem: <usedratio>%"] 10 -               , Run $ Swap [] 10 -               , Run $ Com "uname" ["-s","-r"] "" 36000 -               , Run $ Date "%a %b %_d %Y %H:%M:%S" "date" 10 -              , Run HelloWorld -              ] -  , sepChar = "%" -  , alignSep = "}{" -  , template = "%cpu% | %memory% * %swap% | %eth0% - %eth1% }\ -               \ %hw% { <fc=#ee9a00>%date%</fc>| %EGPH% | %uname%" -} - -main :: IO () -main = configFromArgs config >>= xmobar diff --git a/examples/xmonadpropwrite.hs b/examples/xmonadpropwrite.hs deleted file mode 100644 index f3f4a5d..0000000 --- a/examples/xmonadpropwrite.hs +++ /dev/null @@ -1,41 +0,0 @@ --- Copyright Spencer Janssen <spencerjanssen@gmail.com> ---           Tomas Janousek <tomi@nomi.cz> --- BSD3 (see LICENSE) --- --- Reads from standard input and writes to an X propery on root window. --- To be used with XPropertyLog: ---  Add it to commands: ---      Run XPropertyLog "_XMONAD_LOG_CUSTOM" ---  Add it to the template: ---      template = "... %_XMONAD_LOG_CUSTOM% ..." ---  Run: ---      $ blah blah | xmonadpropwrite _XMONAD_LOG_CUSTOM - -import Control.Monad -import Graphics.X11 -import Graphics.X11.Xlib.Extras -import qualified Data.ByteString as B -import Foreign.C (CChar) -import System.IO -import System.Environment - -main = do -    atom <- flip fmap getArgs $ \args -> case args of -        [a] -> a -        _   -> "_XMONAD_LOG" - -    d <- openDisplay "" -    xlog <- internAtom d atom False -    ustring <- internAtom d "UTF8_STRING" False - -    root  <- rootWindow d (defaultScreen d) - -    forever $ do -        msg <- B.getLine -        changeProperty8 d root xlog ustring propModeReplace (encodeCChar msg) -        sync d True - -    return () - -encodeCChar :: B.ByteString -> [CChar] -encodeCChar = map fromIntegral . B.unpack  | 
