From 8e20389ce238d979e6cb9253643bc181d698f5a9 Mon Sep 17 00:00:00 2001 From: azahi Date: Sat, 13 Oct 2018 14:12:30 +0300 Subject: Huge update, yet again Move to ~/.xmonad Completely redo directory structure Remove Test.hs with xmonad-ng-test because it breaks cabal Add headers for new files Add proper "copyright" entries and mention upstream xmonad developers Other minor fixes --- .gitignore | 1 + misc/bin/mpc-play-pause.sh | 8 --- misc/bin/nsp-console.sh | 8 --- misc/bin/screenlock.sh | 7 --- misc/bin/toggle-compton.sh | 8 --- misc/bin/toggle-redshift.sh | 9 --- misc/bin/toggle-touchpad.sh | 11 ---- misc/bin/toggle-trackpoint.sh | 11 ---- misc/bin/xmobar/fcitx.sh | 16 ------ misc/bin/xshot-select-upload.sh | 7 --- misc/bin/xshot-select.sh | 5 -- misc/bin/xshot-upload.sh | 7 --- misc/bin/xshot.sh | 5 -- misc/xmobarrcBot.hs | 64 --------------------- misc/xmobarrcTop.hs | 40 ------------- scripts/mpc-play-pause.sh | 8 +++ scripts/nsp-console.sh | 8 +++ scripts/screenlock.sh | 7 +++ scripts/toggle-compton.sh | 8 +++ scripts/toggle-redshift.sh | 9 +++ scripts/toggle-touchpad.sh | 11 ++++ scripts/toggle-trackpoint.sh | 11 ++++ scripts/xmobar/fcitx.sh | 16 ++++++ scripts/xshot-select-upload.sh | 7 +++ scripts/xshot-select.sh | 5 ++ scripts/xshot-upload.sh | 7 +++ scripts/xshot.sh | 5 ++ src/Test.hs | 50 ----------------- src/XMonad/Actions/FloatSnapSpaced.hs | 2 +- src/XMonad/Custom/Bindings.hs | 24 ++++---- src/XMonad/Custom/Log.hs | 4 +- src/XMonad/Custom/Prompt.hs | 18 ++++++ src/XMonad/Custom/Scratchpads.hs | 4 +- src/XMonad/Custom/Startup.hs | 4 +- src/XMonad/Util/ALSA.hs | 12 ++++ stack.yaml | 2 +- test/xmonad-ng-xephyr.sh | 102 ++++++++++++++++++++++++++++++++++ xmobarrc/bot.hs | 65 ++++++++++++++++++++++ xmobarrc/top.hs | 41 ++++++++++++++ xmonad-ng.cabal | 71 ++++++----------------- 40 files changed, 376 insertions(+), 332 deletions(-) delete mode 100755 misc/bin/mpc-play-pause.sh delete mode 100755 misc/bin/nsp-console.sh delete mode 100755 misc/bin/screenlock.sh delete mode 100755 misc/bin/toggle-compton.sh delete mode 100755 misc/bin/toggle-redshift.sh delete mode 100755 misc/bin/toggle-touchpad.sh delete mode 100755 misc/bin/toggle-trackpoint.sh delete mode 100755 misc/bin/xmobar/fcitx.sh delete mode 100755 misc/bin/xshot-select-upload.sh delete mode 100755 misc/bin/xshot-select.sh delete mode 100755 misc/bin/xshot-upload.sh delete mode 100755 misc/bin/xshot.sh delete mode 100644 misc/xmobarrcBot.hs delete mode 100644 misc/xmobarrcTop.hs create mode 100755 scripts/mpc-play-pause.sh create mode 100755 scripts/nsp-console.sh create mode 100755 scripts/screenlock.sh create mode 100755 scripts/toggle-compton.sh create mode 100755 scripts/toggle-redshift.sh create mode 100755 scripts/toggle-touchpad.sh create mode 100755 scripts/toggle-trackpoint.sh create mode 100755 scripts/xmobar/fcitx.sh create mode 100755 scripts/xshot-select-upload.sh create mode 100755 scripts/xshot-select.sh create mode 100755 scripts/xshot-upload.sh create mode 100755 scripts/xshot.sh delete mode 100644 src/Test.hs create mode 100644 src/XMonad/Custom/Prompt.hs create mode 100755 test/xmonad-ng-xephyr.sh create mode 100644 xmobarrc/bot.hs create mode 100644 xmobarrc/top.hs diff --git a/.gitignore b/.gitignore index b9df080..f11ea6a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .stack-work/ cabal.sandbox.config dist/ +prompt-history diff --git a/misc/bin/mpc-play-pause.sh b/misc/bin/mpc-play-pause.sh deleted file mode 100755 index 3fb4f3b..0000000 --- a/misc/bin/mpc-play-pause.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -if mpc | grep -q "playing" -then - mpc --no-status pause -else - mpc --no-status play -fi diff --git a/misc/bin/nsp-console.sh b/misc/bin/nsp-console.sh deleted file mode 100755 index 5d19f46..0000000 --- a/misc/bin/nsp-console.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -if tmux list-sessions | grep -q "scratchpad" -then - tmux attach-session -t "scratchpad" -else - tmux new-session -s "scratchpad" -n "scratchpad" -c "${HOME}" -fi diff --git a/misc/bin/screenlock.sh b/misc/bin/screenlock.sh deleted file mode 100755 index 28dbe0c..0000000 --- a/misc/bin/screenlock.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -i3lock \ - --no-unlock-indicator \ - --image "${HOME}/pictures/wallpapers/mill-lock.png" \ - --pointer default \ - --ignore-empty-password diff --git a/misc/bin/toggle-compton.sh b/misc/bin/toggle-compton.sh deleted file mode 100755 index 91ebc4d..0000000 --- a/misc/bin/toggle-compton.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -if [[ $(pgrep 'compton') ]] -then - pkill "compton" -else - compton -b --config "${XDG_CONFIG_HOME}/compton.conf" -fi diff --git a/misc/bin/toggle-redshift.sh b/misc/bin/toggle-redshift.sh deleted file mode 100755 index 8ba6b60..0000000 --- a/misc/bin/toggle-redshift.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -if [[ $(pgrep 'redshift') ]] -then - pkill "redshift" -else - redshift -c "${XDG_CONFIG_HOME}/redshift.conf" & - disown redshift -fi diff --git a/misc/bin/toggle-touchpad.sh b/misc/bin/toggle-touchpad.sh deleted file mode 100755 index 5a30528..0000000 --- a/misc/bin/toggle-touchpad.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -ID=$(xinput list | grep -Eo 'TouchPad\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}') -STATE=$(xinput list-props "$ID" | awk '/Device Enabled/ {print $4}') - -if [ "$STATE" -eq 1 ] -then - xinput disable "$ID" -else - xinput enable "$ID" -fi diff --git a/misc/bin/toggle-trackpoint.sh b/misc/bin/toggle-trackpoint.sh deleted file mode 100755 index b0b3501..0000000 --- a/misc/bin/toggle-trackpoint.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -ID=$(xinput list | grep -Eo 'TrackPoint\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}') -STATE=$(xinput list-props "$ID" | awk '/Device Enabled/ {print $4}') - -if [ "$STATE" -eq 1 ] -then - xinput disable "$ID" -else - xinput enable "$ID" -fi diff --git a/misc/bin/xmobar/fcitx.sh b/misc/bin/xmobar/fcitx.sh deleted file mode 100755 index ddf1826..0000000 --- a/misc/bin/xmobar/fcitx.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -status="$(fcitx-remote)" -set out - -if [[ "$status" = 0 ]] -then - out="Off" -elif [[ "$status" = 1 ]] -then - out="Disabled" -else - out="Enabled" -fi - -echo -e "$out" diff --git a/misc/bin/xshot-select-upload.sh b/misc/bin/xshot-select-upload.sh deleted file mode 100755 index e846800..0000000 --- a/misc/bin/xshot-select-upload.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png" - -maim --format=png --hidecursor --quality 8 --select "${PIC}" && \ - curl --form "file=@${PIC}" "https://0x0.st" | \ - xclip -quiet diff --git a/misc/bin/xshot-select.sh b/misc/bin/xshot-select.sh deleted file mode 100755 index 53ad782..0000000 --- a/misc/bin/xshot-select.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png" - -maim --format=png --hidecursor --quality 8 --select "${PIC}" diff --git a/misc/bin/xshot-upload.sh b/misc/bin/xshot-upload.sh deleted file mode 100755 index 91c23f4..0000000 --- a/misc/bin/xshot-upload.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png" - -maim --format=png --hidecursor --quality 8 "${PIC}" && \ - curl --form "file=@${PIC}" "https://0x0.st" | \ - xclip -quiet diff --git a/misc/bin/xshot.sh b/misc/bin/xshot.sh deleted file mode 100755 index d7984e3..0000000 --- a/misc/bin/xshot.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png" - -maim --format=png --hidecursor --quality 8 "${PIC}" diff --git a/misc/xmobarrcBot.hs b/misc/xmobarrcBot.hs deleted file mode 100644 index c70689b..0000000 --- a/misc/xmobarrcBot.hs +++ /dev/null @@ -1,64 +0,0 @@ -Config { font = "xft:lucy tewi:style=Regular:pixelsize=11,Efont Biwidth:pixelsize=12,Misc Fixed Wide:size=8" - , additionalFonts = [ "xft:Wuncon Siji:style=Regular" - , "xft:lucy tewi:style=Bold:pixelsize=11" - ] - , bgColor = "#0b0806" - , fgColor = "#a19782" - , alpha = 255 - , position = Static { xpos = 0 - , ypos = 876 - , width = 1600 - , height = 24 - } - , textOffset = 16 - , iconOffset = -1 - , lowerOnStart = True - , hideOnStart = False - , allDesktops = True - , overrideRedirect = False - , pickBroadest = False - , persistent = False - , border = FullBM 0 - , borderColor = "#2f2b2a" - , borderWidth = 1 - , iconRoot = "." - , commands = [ Run StdinReader - , Run Battery [ "-t", "%" - , "--" - , "-i", "\57914", "-O", "\57913" , "-o", "\57911" - ] 10 - , Run Cpu [ "-t", "\57381%" ] 10 - , Run CoreTemp [ "-t", "°C / °C" ] 10 - , Run Memory [ "-t", "\57384%" ] 10 - , Run ThermalZone 0 ["-t","\57371°C"] 10 - , Run ThermalZone 1 ["-t","°C"] 10 - , Run Wireless "wlp3s0" [ "-t", "\57882 @ %" ] 10 - , Run DynNetwork [ "-t", "\57660 / \57659 kbps" ] 10 - , Run Kbd [ ("us", "\57967English / \57898") - , ("ru", "\57967Russian / \57898")] - , Run Com "/home/free/.xmonad/bin/xmobar/fcitx.sh" [] "fcitx" 3 - , Run Locks - , Run MPD [ "-t", " - " - , "--" - , "-P", "\57498", "-Z", "\57499", "-S", "\57497" - ] 10 - , Run Volume "default" "Master" [ "-t", "<fn=1><status></fn><volume>%" - , "--" - , "--on" , "\57427" - , "--off" , "\57426" - , "--onc" , "#a19782" - , "--offc" , "#a19782" - ] 10 - ] - , sepChar = "%" - , alignSep = "}{" - , template = " \ - \%battery% %wlp3s0wi% %dynnetwork% %StdinReader%\ - \}\ - \%kbd%%fcitx%\ - \{\ - \%mpd% %default:Master%\ - \ " - } - --- vim:filetype=haskell:expandtab:tabstop=4:shiftwidth=4 diff --git a/misc/xmobarrcTop.hs b/misc/xmobarrcTop.hs deleted file mode 100644 index 6764359..0000000 --- a/misc/xmobarrcTop.hs +++ /dev/null @@ -1,40 +0,0 @@ -Config { font = "xft:lucy tewi:style=Regular:pixelsize=11,Efont Biwidth:pixelsize=12,Misc Fixed Wide:size=8" - , additionalFonts = [ "xft:Wuncon Siji:style=Regular" - , "xft:lucy tewi:style=Bold:pixelsize=11" - ] - , bgColor = "#0b0806" - , fgColor = "#a19782" - , alpha = 255 - , position = Static { xpos = 0 - , ypos = 0 - , width = 1600 - , height = 24 - } - , textOffset = 16 - , iconOffset = -1 - , lowerOnStart = True - , hideOnStart = False - , allDesktops = True - , overrideRedirect = False - , pickBroadest = False - , persistent = False - , border = FullBM 0 - , borderColor = "#2f2b2a" - , borderWidth = 1 - , iconRoot = "." - , commands = [ Run StdinReader - , Run Date "<fn=1>\57893</fn>%d.%m.%y / %A / %H:%M" "date" 10 - , Run Weather "UUWW" [ "-t", "<fn=1>\57550</fn><tempC>°C / <rh>% / <pressure> Pa" ] 10000 - ] - , sepChar = "%" - , alignSep = "}{" - , template = " \ - \%StdinReader%\ - \}\ - \\ - \{\ - \%UUWW% %date%\ - \ " - } - --- vim:filetype=haskell:expandtab:tabstop=4:shiftwidth=4 diff --git a/scripts/mpc-play-pause.sh b/scripts/mpc-play-pause.sh new file mode 100755 index 0000000..3fb4f3b --- /dev/null +++ b/scripts/mpc-play-pause.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if mpc | grep -q "playing" +then + mpc --no-status pause +else + mpc --no-status play +fi diff --git a/scripts/nsp-console.sh b/scripts/nsp-console.sh new file mode 100755 index 0000000..5d19f46 --- /dev/null +++ b/scripts/nsp-console.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if tmux list-sessions | grep -q "scratchpad" +then + tmux attach-session -t "scratchpad" +else + tmux new-session -s "scratchpad" -n "scratchpad" -c "${HOME}" +fi diff --git a/scripts/screenlock.sh b/scripts/screenlock.sh new file mode 100755 index 0000000..28dbe0c --- /dev/null +++ b/scripts/screenlock.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +i3lock \ + --no-unlock-indicator \ + --image "${HOME}/pictures/wallpapers/mill-lock.png" \ + --pointer default \ + --ignore-empty-password diff --git a/scripts/toggle-compton.sh b/scripts/toggle-compton.sh new file mode 100755 index 0000000..91ebc4d --- /dev/null +++ b/scripts/toggle-compton.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if [[ $(pgrep 'compton') ]] +then + pkill "compton" +else + compton -b --config "${XDG_CONFIG_HOME}/compton.conf" +fi diff --git a/scripts/toggle-redshift.sh b/scripts/toggle-redshift.sh new file mode 100755 index 0000000..8ba6b60 --- /dev/null +++ b/scripts/toggle-redshift.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +if [[ $(pgrep 'redshift') ]] +then + pkill "redshift" +else + redshift -c "${XDG_CONFIG_HOME}/redshift.conf" & + disown redshift +fi diff --git a/scripts/toggle-touchpad.sh b/scripts/toggle-touchpad.sh new file mode 100755 index 0000000..5a30528 --- /dev/null +++ b/scripts/toggle-touchpad.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +ID=$(xinput list | grep -Eo 'TouchPad\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}') +STATE=$(xinput list-props "$ID" | awk '/Device Enabled/ {print $4}') + +if [ "$STATE" -eq 1 ] +then + xinput disable "$ID" +else + xinput enable "$ID" +fi diff --git a/scripts/toggle-trackpoint.sh b/scripts/toggle-trackpoint.sh new file mode 100755 index 0000000..b0b3501 --- /dev/null +++ b/scripts/toggle-trackpoint.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +ID=$(xinput list | grep -Eo 'TrackPoint\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}') +STATE=$(xinput list-props "$ID" | awk '/Device Enabled/ {print $4}') + +if [ "$STATE" -eq 1 ] +then + xinput disable "$ID" +else + xinput enable "$ID" +fi diff --git a/scripts/xmobar/fcitx.sh b/scripts/xmobar/fcitx.sh new file mode 100755 index 0000000..ddf1826 --- /dev/null +++ b/scripts/xmobar/fcitx.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +status="$(fcitx-remote)" +set out + +if [[ "$status" = 0 ]] +then + out="Off" +elif [[ "$status" = 1 ]] +then + out="Disabled" +else + out="Enabled" +fi + +echo -e "$out" diff --git a/scripts/xshot-select-upload.sh b/scripts/xshot-select-upload.sh new file mode 100755 index 0000000..e846800 --- /dev/null +++ b/scripts/xshot-select-upload.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png" + +maim --format=png --hidecursor --quality 8 --select "${PIC}" && \ + curl --form "file=@${PIC}" "https://0x0.st" | \ + xclip -quiet diff --git a/scripts/xshot-select.sh b/scripts/xshot-select.sh new file mode 100755 index 0000000..53ad782 --- /dev/null +++ b/scripts/xshot-select.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png" + +maim --format=png --hidecursor --quality 8 --select "${PIC}" diff --git a/scripts/xshot-upload.sh b/scripts/xshot-upload.sh new file mode 100755 index 0000000..91c23f4 --- /dev/null +++ b/scripts/xshot-upload.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png" + +maim --format=png --hidecursor --quality 8 "${PIC}" && \ + curl --form "file=@${PIC}" "https://0x0.st" | \ + xclip -quiet diff --git a/scripts/xshot.sh b/scripts/xshot.sh new file mode 100755 index 0000000..d7984e3 --- /dev/null +++ b/scripts/xshot.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +PIC="${HOME}/pictures/screenshots/$(date +%Y-%m-%d_%H-%M-%S).png" + +maim --format=png --hidecursor --quality 8 "${PIC}" diff --git a/src/Test.hs b/src/Test.hs deleted file mode 100644 index eea5d61..0000000 --- a/src/Test.hs +++ /dev/null @@ -1,50 +0,0 @@ -module Main where - -import Control.Monad (void) -import qualified Data.Map as M -import qualified Data.Set as S -import XMonad -import XMonad.Prompt -import XMonad.StackSet (new) -import XMonad.Util.EZConfig (checkKeymap) -import XMonad.Util.Font -import XMonad.Custom.Bindings (rawKeys) -import XMonad.Custom.Theme (promptTheme) - -main :: IO () -main = do - dpy <- openDisplay "" - rootw <- rootWindow dpy $ defaultScreen dpy - - let xmc = def {layoutHook = Layout $ layoutHook def} - initialWinset = new (layoutHook xmc) (workspaces xmc) [] - - let cf = XConf { display = dpy - , config = xmc - , theRoot = rootw - , normalBorder = 0 - , focusedBorder = 0 - , keyActions = M.empty - , buttonActions = M.empty - , mouseFocused = False - , mousePosition = Nothing - , currentEvent = Nothing - } - - let st = XState { windowset = initialWinset - , numberlockMask = 0 - , mapped = S.empty - , waitingUnmap = M.empty - , dragging = Nothing - , extensibleState = M.empty - } - - void $ runX cf st $ do - checkKeymap xmc (rawKeys xmc) - - xmf <- initXMF (font promptTheme) - - case xmf of - Core _ -> io (putStrLn "Font: core") - Utf8 _ -> io (putStrLn "Font: utf8") - Xft _ -> io (putStrLn "Font: xft") diff --git a/src/XMonad/Actions/FloatSnapSpaced.hs b/src/XMonad/Actions/FloatSnapSpaced.hs index 5b5d572..a579376 100644 --- a/src/XMonad/Actions/FloatSnapSpaced.hs +++ b/src/XMonad/Actions/FloatSnapSpaced.hs @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : XMonad.Actions.FloatSnapSpaced --- Copyright : (c) azahi 2018 +-- Copyright : (c) 2009 Anders Engstrom <ankaan@gmail.com> -- License : BSD3-style (see LICENSE) -- -- Maintainer : azahi@teknik.io diff --git a/src/XMonad/Custom/Bindings.hs b/src/XMonad/Custom/Bindings.hs index 7504526..b31599a 100644 --- a/src/XMonad/Custom/Bindings.hs +++ b/src/XMonad/Custom/Bindings.hs @@ -50,7 +50,6 @@ import XMonad.Layout.Reflect import XMonad.Layout.ResizableTile import XMonad.Layout.SubLayouts import XMonad.Prompt.ConfirmPrompt -import XMonad.Prompt.Pass import XMonad.Prompt.Shell import XMonad.Prompt.Window import XMonad.Prompt.Workspace @@ -133,17 +132,17 @@ keysBase _ = keysSystem :: XConfig Layout -> [(String, X ())] keysSystem _ = [ ("M-C-g" , return ()) - , ("<XF86ScreenSaver>" , spawn "~/.xmonad/bin/screenlock.sh") + , ("<XF86ScreenSaver>" , spawn "~/.xmonad/scripts/screenlock.sh") -- , ("M-S-c" , xSelectionNotify) - , ("M-<Print>" , spawn "~/.xmonad/bin/xshot-upload.sh") - , ("M-S-<Print>" , spawn "~/.xmonad/bin/xshot-select-upload.sh") - , ("M-<Insert>" , spawn "~/.xmonad/bin/xcast.sh --webm") - , ("M-S-<Insert>" , spawn "~/.xmonad/bin/xcast.sh --gif") + , ("M-<Print>" , spawn "~/.xmonad/scripts/xshot-upload.sh") + , ("M-S-<Print>" , spawn "~/.xmonad/scripts/xshot-select-upload.sh") + , ("M-<Insert>" , spawn "~/.xmonad/scripts/xcast.sh --webm") + , ("M-S-<Insert>" , spawn "~/.xmonad/scripts/xcast.sh --gif") , ("M-C-<Insert>" , spawn "pkill ffmpeg") - , ("M-C-c" , spawn "~/.xmonad/bin/toggle-compton.sh") - , ("M-C-r" , spawn "~/.xmonad/bin/toggle-redshift.sh") - , ("M-C-p" , spawn "~/.xmonad/bin/toggle-touchpad.sh") - , ("M-C-t" , spawn "~/.xmonad/bin/toggle-trackpoint.sh") + , ("M-C-c" , spawn "~/.xmonad/scripts/toggle-compton.sh") + , ("M-C-r" , spawn "~/.xmonad/scripts/toggle-redshift.sh") + , ("M-C-p" , spawn "~/.xmonad/scripts/toggle-touchpad.sh") + , ("M-C-t" , spawn "~/.xmonad/scripts/toggle-trackpoint.sh") ] keysMedia :: XConfig Layout -> [(String, X ())] @@ -151,7 +150,7 @@ keysMedia _ = [ ("<XF86AudioMute>" , void toggleMute) , ("<XF86AudioLowerVolume>" , void $ lowerVolume 5) , ("<XF86AudioRaiseVolume>" , void $ raiseVolume 5) - , ("<XF86AudioPlay>" , spawn "~/.xmonad/bin/mpc-play-pause.sh") + , ("<XF86AudioPlay>" , spawn "~/.xmonad/scripts/mpc-play-pause.sh") , ("<XF86AudioStop>" , spawn "mpc --no-status stop") , ("<XF86AudioPrev>" , spawn "mpc --no-status prev") , ("<XF86AudioNext>" , spawn "mpc --no-status next") @@ -159,7 +158,7 @@ keysMedia _ = keysWorkspaces :: XConfig Layout -> [(String, X ())] keysWorkspaces _ = - [ ("M-p" , switchProjectPrompt promptTheme) + [ ("M-S-o" , switchProjectPrompt promptTheme) , ("M-S-p" , shiftToProjectPrompt promptTheme) , ("M-," , nextNonEmptyWS) , ("M-." , prevNonEmptyWS) @@ -174,7 +173,6 @@ keysSpawnables :: XConfig Layout -> [(String, X ())] keysSpawnables _ = [ ("M-<Return>" , spawn (C.term C.applications)) , ("M-b" , spawn (C.browser C.applications)) - , ("M-C-p" , passPrompt promptTheme) , ("M-c" , namedScratchpadAction scratchpads "console") , ("M-m" , namedScratchpadAction scratchpads "music") , ("M-t" , namedScratchpadAction scratchpads "top") diff --git a/src/XMonad/Custom/Log.hs b/src/XMonad/Custom/Log.hs index 461634e..e441a02 100644 --- a/src/XMonad/Custom/Log.hs +++ b/src/XMonad/Custom/Log.hs @@ -44,9 +44,7 @@ topBarPP = def , ppWsSep = " " , ppTitle = xmobarColor white1 "" . shorten 50 , ppTitleSanitize = xmobarStrip - , ppLayout = xmobarColor white1 "" . \case "Spacing 12 Tabbed Hidden BSP" -> "Omni.Gaps" - "Tabbed Hidden BSP" -> "Omni" - _ -> "Misc" + , ppLayout = xmobarColor white1 "" , ppOrder = id , ppSort = (namedScratchpadFilterOutWorkspace .) <$> getSortByIndex , ppExtras = [] diff --git a/src/XMonad/Custom/Prompt.hs b/src/XMonad/Custom/Prompt.hs new file mode 100644 index 0000000..15aab2c --- /dev/null +++ b/src/XMonad/Custom/Prompt.hs @@ -0,0 +1,18 @@ +module XMonad.Custom.Prompt + ( listCompFunc + , aListCompFunc + , predicateFunction + ) where + +import Data.Char +import Data.List +import XMonad.Prompt + +listCompFunc :: XPConfig -> [String] -> String -> IO [String] +listCompFunc c xs s = return (filter (searchPredicate c s) xs) + +aListCompFunc :: XPConfig -> [(String, a)] -> String -> IO [String] +aListCompFunc c xs = listCompFunc c (map fst xs) + +predicateFunction :: String -> String -> Bool +predicateFunction x y = lc x `isInfixOf` lc y where lc = map toLower diff --git a/src/XMonad/Custom/Scratchpads.hs b/src/XMonad/Custom/Scratchpads.hs index 98ddaf5..d463b87 100644 --- a/src/XMonad/Custom/Scratchpads.hs +++ b/src/XMonad/Custom/Scratchpads.hs @@ -34,7 +34,7 @@ floatingNSP = customFloating $ S.RationalRect x y w h scratchpads :: [NamedScratchpad] scratchpads = [ NS "console" - (spawnTerminalWith "NSPConsole" "~/.xmonad/bin/nsp-console.sh") + (spawnTerminalWith "NSPConsole" "~/.xmonad/scripts/nsp-console.sh") (title =? "NSPConsole") floatingNSP , NS "volume" @@ -42,7 +42,7 @@ scratchpads = (title =? "NSPVolume") floatingNSP , NS "music" - (spawnTerminalWith "NSPMusic" "~/.bin/mp") + (spawnTerminalWith "NSPMusic" "mp") (title =? "NSPMusic") floatingNSP , NS "top" diff --git a/src/XMonad/Custom/Startup.hs b/src/XMonad/Custom/Startup.hs index 3738f6a..6050dff 100644 --- a/src/XMonad/Custom/Startup.hs +++ b/src/XMonad/Custom/Startup.hs @@ -51,8 +51,8 @@ addEWMHFullscreen = do startupHook :: X () startupHook = do - spawnNamedPipe "xmobar ~/.xmonad/xmobarrcTop.hs" "xmobarTop" - spawnNamedPipe "xmobar ~/.xmonad/xmobarrcBot.hs" "xmobarBot" + spawnNamedPipe "xmobar ~/.xmonad/xmobarrc/top.hs" "xmobarTop" + spawnNamedPipe "xmobar ~/.xmonad/xmobarrc/bot.hs" "xmobarBot" docksStartupHook addEWMHFullscreen setDefaultCursor xC_left_ptr diff --git a/src/XMonad/Util/ALSA.hs b/src/XMonad/Util/ALSA.hs index 3e543df..0bccfd8 100644 --- a/src/XMonad/Util/ALSA.hs +++ b/src/XMonad/Util/ALSA.hs @@ -1,5 +1,17 @@ {-# LANGUAGE CPP #-} +---------------------------------------------------------------------------- +-- | +-- Module : XMonad.Util.ALSA +-- Copyright : (c) daniel@wagner-home.com +-- License : BSD3-style (see LICENSE) +-- +-- Maintainer : azahi@teknik.io +-- Stability : unstable +-- Portability : unportable +-- +---------------------------------------------------------------------------- + module XMonad.Util.ALSA ( toggleMute , raiseVolume diff --git a/stack.yaml b/stack.yaml index ab9f566..0183c3c 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,4 +1,4 @@ -resolver: lts-12.11 +resolver: lts-12.12 packages: - . - ./vendor/xmonad diff --git a/test/xmonad-ng-xephyr.sh b/test/xmonad-ng-xephyr.sh new file mode 100755 index 0000000..37e0bab --- /dev/null +++ b/test/xmonad-ng-xephyr.sh @@ -0,0 +1,102 @@ +#!/bin/sh -eu + +usage () { + cat << EOF +Usage: xmonad-ng-xephyr.sh [options] + + -d NxN Set the screen size to NxN + -h This message + -n NUM Set the internal DISPLAY to NUM + -s NUM Set the number of screens to NUM +EOF +} + +ARCH=$(uname -m) +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +SCREENS=1 +SCREEN_SIZE="800x600" +DISPLAY_NUMBER=5 + +while getopts "d:hs:n:" o +do + case "${o}" in + d) + SCREEN_SIZE=$OPTARG + ;; + + h) usage + exit + ;; + + n) + DISPLAY_NUMBER=$OPTARG + ;; + + s) + SCREENS=$OPTARG + ;; + + *) + echo + usage + exit 1 + ;; + esac +done + +shift $((OPTIND-1)) + +################################################################################ +if [ -d .stack-work ]; then + echo "stack build detected" + options="" + [ "${NIX_PATH:-NO}" = "NO" ] || options="--nix" + BIN_PATH=$(stack path $options --dist-dir)/build/xmonad-ng +elif [ -d dist ]; then + echo "cabal build detected" + BIN_PATH=$(find dist/ -type f -executable -name xmonad-ng -printf '%h') +else + echo "you need to build xmonad-ng first, see README for instructions" + exit 1 +fi + +RAW_BIN=$BIN_PATH/xmonad-ng +ARCH_BIN=$BIN_PATH/xmonad-ng-$ARCH-$OS + +################################################################################ +cp -p "$RAW_BIN" "$ARCH_BIN" + +################################################################################ +XMONAD_CONFIG_DIR=$(pwd)/state/config +XMONAD_CACHE_DIR=$(pwd)/state/cache +XMONAD_DATA_DIR=$(pwd)/state/data +export XMONAD_CONFIG_DIR XMONAD_CACHE_DIR XMONAD_DATA_DIR + +mkdir -p "$XMONAD_CONFIG_DIR" "$XMONAD_CACHE_DIR" "$XMONAD_DATA_DIR" +echo "xmonad will store state files in $(pwd)/state" + +################################################################################ +SCREEN_COUNTER=0 +SCREEN_OPTS="" +X_OFFSET_CURRENT="0" +X_OFFSET_ADD=$(echo "$SCREEN_SIZE" | cut -dx -f1) + +while expr "$SCREEN_COUNTER" "<" "$SCREENS"; do + SCREEN_OPTS="$SCREEN_OPTS -origin ${X_OFFSET_CURRENT},0 -screen ${SCREEN_SIZE}+${X_OFFSET_CURRENT}" + SCREEN_COUNTER=$(("$SCREEN_COUNTER" + 1)) + X_OFFSET_CURRENT=$(("$X_OFFSET_CURRENT" + "$X_OFFSET_ADD")) +done + +( + # shellcheck disable=SC2086 + Xephyr $SCREEN_OPTS +xinerama +extension RANDR \ + -ac -br -reset -terminate -verbosity 10 \ + -softCursor ":$DISPLAY_NUMBER" & + + export DISPLAY=":$DISPLAY_NUMBER" + echo "Waiting for windows to appear..." && sleep 2 + + xterm -hold xrandr & + xterm & + $ARCH_BIN +) diff --git a/xmobarrc/bot.hs b/xmobarrc/bot.hs new file mode 100644 index 0000000..292fec8 --- /dev/null +++ b/xmobarrc/bot.hs @@ -0,0 +1,65 @@ +Config { font = "xft:lucy tewi:style=Regular:pixelsize=11,Efont Biwidth:pixelsize=12,Misc Fixed Wide:size=8" + , additionalFonts = [ "xft:Wuncon Siji:style=Regular" + , "xft:lucy tewi:style=Bold:pixelsize=11" + ] + , bgColor = "#0b0806" + , fgColor = "#a19782" + , alpha = 255 + , position = Static { xpos = 0 + , ypos = 876 + , width = 1600 + , height = 24 + } + , textOffset = 16 + , textOffsets = [16, -1] + , iconOffset = -1 + , lowerOnStart = True + , hideOnStart = False + , allDesktops = True + , overrideRedirect = False + , pickBroadest = False + , persistent = False + , border = FullBM 0 + , borderColor = "#2f2b2a" + , borderWidth = 1 + , iconRoot = "." + , commands = [ Run StdinReader + , Run Battery [ "-t", "<fn=1><acstatus></fn><left>%" + , "--" + , "-i", "\57914", "-O", "\57913" , "-o", "\57911" + ] 10 + , Run Cpu [ "-t", "<fn=1>\57381</fn><total>%" ] 10 + , Run CoreTemp [ "-t", "<core0>°C / <core1>°C" ] 10 + , Run Memory [ "-t", "<fn=1>\57384</fn><usedratio>%" ] 10 + , Run ThermalZone 0 ["-t","<fn=1>\57371</fn><temp>°C"] 10 + , Run ThermalZone 1 ["-t","<temp>°C"] 10 + , Run Wireless "wlp3s0" [ "-t", "<fn=1>\57775</fn><essid> @ <quality>%" ] 10 + , Run DynNetwork [ "-t", "<fn=1>\57660</fn><rx> / <fn=1>\57659</fn><tx> kbps" ] 10 + , Run Kbd [ ("us", "English / ") + , ("ru", "Russian / ")] + , Run Com "/home/free/.xmonad/scripts/xmobar/fcitx.sh" [] "fcitx" 3 + , Run Locks + , Run MPD [ "-t", "<fn=1><statei></fn><artist> - <title>" + , "--" + , "-P", "\57498", "-Z", "\57499", "-S", "\57497" + ] 10 + , Run Volume "default" "Master" [ "-t", "<fn=1><status></fn><volume>%" + , "--" + , "--on" , "\57427" + , "--off" , "\57426" + , "--onc" , "#a19782" + , "--offc" , "#a19782" + ] 10 + ] + , sepChar = "%" + , alignSep = "}{" + , template = " \ + \%battery% %wlp3s0wi% %dynnetwork% %StdinReader%\ + \}\ + \%kbd%%fcitx%\ + \{\ + \%mpd% %default:Master%\ + \ " + } + +-- vim:filetype=haskell:expandtab:tabstop=4:shiftwidth=4 diff --git a/xmobarrc/top.hs b/xmobarrc/top.hs new file mode 100644 index 0000000..0f26e5c --- /dev/null +++ b/xmobarrc/top.hs @@ -0,0 +1,41 @@ +Config { font = "xft:lucy tewi:style=Regular:pixelsize=11,Efont Biwidth:pixelsize=12,Misc Fixed Wide:size=8" + , additionalFonts = [ "xft:Wuncon Siji:style=Regular" + , "xft:lucy tewi:style=Bold:pixelsize=11" + ] + , bgColor = "#0b0806" + , fgColor = "#a19782" + , alpha = 255 + , position = Static { xpos = 0 + , ypos = 0 + , width = 1600 + , height = 24 + } + , textOffset = -1 + , textOffsets = [-1, -1] + , iconOffset = -1 + , lowerOnStart = True + , hideOnStart = False + , allDesktops = True + , overrideRedirect = False + , pickBroadest = False + , persistent = False + , border = FullBM 0 + , borderColor = "#2f2b2a" + , borderWidth = 1 + , iconRoot = "." + , commands = [ Run StdinReader + , Run Date "<fn=1>\57893</fn>%d.%m.%y / %A / %H:%M" "date" 10 + , Run Weather "UUWW" [ "-t", "<fn=1>\57550</fn><tempC>°C / <rh>% / <pressure> Pa" ] 10000 + ] + , sepChar = "%" + , alignSep = "}{" + , template = " \ + \%StdinReader%\ + \}\ + \\ + \{\ + \%UUWW% %date%\ + \ " + } + +-- vim:filetype=haskell:expandtab:tabstop=4:shiftwidth=4 diff --git a/xmonad-ng.cabal b/xmonad-ng.cabal index 112c369..1713214 100644 --- a/xmonad-ng.cabal +++ b/xmonad-ng.cabal @@ -17,7 +17,8 @@ source-repository head type: git location: https://github.com/azahi/xmonad-ng -library +executable xmonad-ng + main-is: Main.hs ghc-options: -Wall hs-source-dirs: src default-language: Haskell2010 @@ -27,58 +28,21 @@ library , MultiParamTypeClasses , TypeSynonymInstances - exposed-modules: XMonad.Actions.FloatSnapSpaced - , XMonad.Actions.PerConditionKeys - , XMonad.Custom.Bindings - , XMonad.Custom.Event - , XMonad.Custom.Layout - , XMonad.Custom.Log - , XMonad.Custom.Manage - , XMonad.Custom.Misc - , XMonad.Custom.Navigation - , XMonad.Custom.Projects - , XMonad.Custom.Scratchpads - , XMonad.Custom.Startup - , XMonad.Custom.Theme - , XMonad.Custom.Workspaces - , XMonad.Util.ALSA - - build-depends: X11 >= 1.9 && < 1.10 - , alsa-mixer >= 0.2 && < 0.3 - , base >= 4.11 && < 4.12 - , containers >= 0.5 && < 0.6 - , directory >= 1.3 && < 1.4 - , filepath >= 1.4 && < 1.5 - , mtl >= 2.2 && < 2.3 - , text >= 1.2 && < 1.3 - , time >= 1.8 && < 1.9 - , xmonad >= 0.15 && < 0.16 - , xmonad-contrib >= 0.15 && < 0.16 - -executable xmonad-ng - main-is: Main.hs - ghc-options: -Wall - hs-source-dirs: src - default-language: Haskell2010 - - build-depends: X11 >= 1.9 && < 1.10 - , alsa-mixer >= 0.2 && < 0.3 - , base >= 4.11 && < 4.12 - , containers >= 0.5 && < 0.6 - , directory >= 1.3 && < 1.4 - , filepath >= 1.4 && < 1.5 - , mtl >= 2.2 && < 2.3 - , text >= 1.2 && < 1.3 - , time >= 1.8 && < 1.9 - , xmonad >= 0.15 && < 0.16 - , xmonad-contrib >= 0.15 && < 0.16 - , xmonad-ng - -executable xmonad-ng-test - main-is: Test.hs - ghc-options: -Wall - hs-source-dirs: src - default-language: Haskell2010 + other-modules: XMonad.Actions.FloatSnapSpaced + , XMonad.Actions.PerConditionKeys + , XMonad.Custom.Bindings + , XMonad.Custom.Event + , XMonad.Custom.Layout + , XMonad.Custom.Log + , XMonad.Custom.Manage + , XMonad.Custom.Misc + , XMonad.Custom.Navigation + , XMonad.Custom.Projects + , XMonad.Custom.Scratchpads + , XMonad.Custom.Startup + , XMonad.Custom.Theme + , XMonad.Custom.Workspaces + , XMonad.Util.ALSA build-depends: X11 >= 1.9 && < 1.10 , alsa-mixer >= 0.2 && < 0.3 @@ -91,4 +55,3 @@ executable xmonad-ng-test , time >= 1.8 && < 1.9 , xmonad >= 0.15 && < 0.16 , xmonad-contrib >= 0.15 && < 0.16 - , xmonad-ng -- cgit 1.4.1