diff options
Diffstat (limited to 'archive/XMonad')
-rwxr-xr-x | archive/XMonad/baraction | 58 | ||||
-rw-r--r-- | archive/XMonad/xmonad.hs | 243 |
2 files changed, 301 insertions, 0 deletions
diff --git a/archive/XMonad/baraction b/archive/XMonad/baraction new file mode 100755 index 00000000..70316740 --- /dev/null +++ b/archive/XMonad/baraction @@ -0,0 +1,58 @@ +#!/bin/zsh + +get_date_time() { + datetime=$(date +"%d %b(%A) %H:%M") + echo $datetime +} + +get_dnd_status() { + dnd_status=$(</tmp/dnd_status) + if [ $dnd_status = "on" ]; then + echo "%{F#232627}%{B#f70258}" "サイレント" "%{F-}%{B-}" + fi +} + +get_cpu_load() { + read cpu a b c previdle rest < /proc/stat + prevtotal=$((a+b+c+previdle)) + sleep 0.5 + read cpu a b c idle rest < /proc/stat + total=$((a+b+c+idle)) + cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) )) + echo -e "CPU: $cpu%" +} + +get_cpu_temp() { + CEL=$'\xc2\xb0C' + temp=$( cat /sys/devices/virtual/thermal/thermal_zone0/temp ) + temp=`expr $temp / 1000` + echo "TEMP: " $temp$CEL +} + +get_disk_usage() { + root=$(df -h / | awk 'NR==2 {print $4 "/" $2}') + home=$(df -h /home | awk 'NR==2 {print $4 "/" $2}') + echo "ROOT:" $root " %{B-} " "%{B#E6739F} HOME:" $home " " +} + +get_mem_usage() { + mem=$(free -m | grep Mem: | awk '{print$3 / $2 * 100}') + printf "MEM: %.0f %%" $mem +} + +get_mute_status() { + vol=$(pamixer --get-volume-human) + if [ $vol = "muted" ] + then + echo "%{B#F15BB5}%{F#232627} ミュート" + fi +} + +get_weather() { + echo $(</tmp/weather_stat) +} + +while :; do + echo "%{B#FD3A69}%{F#232627} " $(get_disk_usage) "%{B-} %{B#FECD1A} " $(get_cpu_load) "%{B-} %{B#03C4A1}" $(get_cpu_temp) "%{B-} %{B#00BBF9}" $(get_mem_usage) "%{c}%{F-}%{B-}%{r}" $(get_dnd_status) $(get_mute_status) "%{B-}%{F-} %{B#9B5DE5}%{F#FCFCFC}" $(get_weather) "%{B-} %{B#892CDC}%{F#FCFCFC} " $(get_date_time) " %{F-}%{B-}" + sleep 3 +done diff --git a/archive/XMonad/xmonad.hs b/archive/XMonad/xmonad.hs new file mode 100644 index 00000000..f6661106 --- /dev/null +++ b/archive/XMonad/xmonad.hs @@ -0,0 +1,243 @@ +import XMonad +import qualified XMonad.StackSet as W +import XMonad.ManageHook + +-- actions +import XMonad.Actions.CycleWS (moveTo, shiftTo, WSType(..), nextScreen, prevScreen) +import XMonad.Actions.CopyWindow +import XMonad.Actions.CycleWS +import XMonad.Actions.GridSelect +import XMonad.Actions.SwapWorkspaces +import XMonad.Actions.WindowBringer +import XMonad.Actions.MouseResize + +-- layouts modifiers +import XMonad.Layout.Spacing +import XMonad.Layout.LayoutModifier +import XMonad.Layout.WindowNavigation as WN + +-- Layouts +import XMonad.Layout.AvoidFloats +import XMonad.Layout.BinarySpacePartition as BSP +import XMonad.Layout.CenteredMaster +import XMonad.Layout.Grid +import XMonad.Layout.ThreeColumns +import XMonad.Layout.TwoPane +import XMonad.Layout.Spiral +import XMonad.Layout.ResizableTile +import XMonad.Layout.Tabbed + +-- hooks +import XMonad.Hooks.SetWMName +import XMonad.Hooks.ManageDocks +import XMonad.Hooks.DynamicLog +-- import XMonad.Hooks.FadeInactive + +-- utilities +import XMonad.Util.SpawnOnce +import XMonad.Util.EZConfig (additionalKeys) +import XMonad.Util.Cursor +import XMonad.Util.Paste +import XMonad.Util.Run +import XMonad.Util.NamedScratchpad + +myStartupHook :: X () +myStartupHook = do + spawnOnce "/home/zt/.xmonad/baraction | lemonbar -g 1366x21+0+0 -B '#171520' -F '#ffffff' -f 'Source Han Sans JP:size=10' -n 'XMobar'" + spawnOnce "/home/zt/.config/scripts/weather" + spawnOnce "nitrogen --restore &" + spawnOnce "picom &" + spawnOnce "deadd-notification-center &" + spawnOnce "firefox &" + spawnOnce "vivaldi &" + spawnOnce "sxhkd &" + spawnOnce "weather" + -- spawnOnce "betterlockscreen -l -t 'Welcome, Vidhu Kant!'" + spawnOnce "sleep 3; trayer --align center --edge top --width 20 --height 21 --expand true --distance 90 --distancefrom right --tint 0x171520 --transparent true --alpha 0 --iconspacing 8" + setWMName "Oppai" + setDefaultCursor xC_left_ptr + + +windowCount :: X (Maybe String) +windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset + + +-- defaults + +-- myFont :: String +-- myFont = "Roboto" + +myModMask :: KeyMask +myModMask = mod4Mask + +myTerminal :: String +myTerminal = "st" + +myDmenu :: String +myDmenu = "run_dmenu" + +myBrowser :: String +myBrowser = "firefox" + +-- myEditor :: String +-- myEditor = "vim" + +-- wm variables + +nBorder = "#000000" -- "#3804f4" -- "#bf00ff" +fBorder = "#6e02fc" + +myBorderWidth = 1 + +sGap = 0 -- screen gap +wGap = 1 -- window gap + +myExtraWorkspaces = [(xK_0, " 十 ")] +myWorkspaces = [" 一 "," 二 "," 三 "," 四 "," 五 "," 六 "," 七 "," 八 ", " 九 "] ++ (map snd myExtraWorkspaces) + + + +-- scratchpad config +myScratchpads = [ +-- NS "Vysor" "Vysor.AppImage" (title =? "Vysor") defaultFloating + NS "Phone" "scrcpy" (title =? "Motorola One Power") defaultFloating, + NS "T1" "st -t 'T1'" (title =? "T1") defaultFloating, + NS "T2" "st -t 'T2'" (title =? "T2") defaultFloating, + NS "Nitrogen" "nitrogen" (title =? "Nitrogen") defaultFloating + ] where role = stringProperty "WM_WINDOW_ROLE" + + +-- keybindings +myKeys = [ + ((mod4Mask, xK_Return), spawn (myTerminal)) + , ((mod1Mask, xK_p), spawn "/home/zt/.config/scripts/run_dmenu") + , ((mod1Mask, xK_w), kill1) + , ((mod1Mask .|. shiftMask, xK_k), kill1) + , ((mod1Mask, xK_o), withFocused $ windows . W.sink) -- unfloat windows + + -- scratchpad keybindings + , ((mod4Mask, xK_p), namedScratchpadAction myScratchpads "Phone") + , ((mod4Mask, xK_o), namedScratchpadAction myScratchpads "T1") + , ((mod4Mask, xK_i), namedScratchpadAction myScratchpads "T2") + , ((mod4Mask, xK_w), namedScratchpadAction myScratchpads "Nitrogen") + + -- view prev/next workspaces + , ((mod1Mask, xK_h), prevWS) + , ((mod1Mask, xK_l), nextWS) + + -- move to prev/next workspaces + , ((mod1Mask .|. shiftMask, xK_h), shiftToPrev >> prevWS) + , ((mod1Mask .|. shiftMask, xK_l), shiftToNext >> nextWS) + + -- modify gaps on runtime + , ((mod1Mask, xK_equal), incWindowSpacing 1) + , ((mod1Mask, xK_minus), decWindowSpacing 1) + , ((mod1Mask .|. shiftMask, xK_equal), incScreenSpacing 1) + , ((mod1Mask .|. shiftMask, xK_minus), decScreenSpacing 1) + + , ((mod4Mask .|. shiftMask, xK_Return), windows W.swapMaster) -- Swap the focused window and the master window + + -- these keybindings are for WindowNavigation + -- and they conflict with BSP layout + + -- directional navigation of windows + , ((mod4Mask, xK_l), sendMessage $ Go R) + , ((mod4Mask, xK_h), sendMessage $ Go L) + , ((mod4Mask, xK_k), sendMessage $ Go U) + , ((mod4Mask, xK_j), sendMessage $ Go D) + + -- swap windows + , ((mod4Mask .|. shiftMask, xK_l), sendMessage $ WN.Swap R) + , ((mod4Mask .|. shiftMask, xK_h), sendMessage $ WN.Swap L) + , ((mod4Mask .|. shiftMask, xK_k), sendMessage $ WN.Swap U) + , ((mod4Mask .|. shiftMask, xK_j), sendMessage $ WN.Swap D) + + -- cycle through windows + , ((mod1Mask, xK_j), windows W.focusDown) + , ((mod1Mask, xK_k), windows W.focusUp) + + -- grid select + , ((mod1Mask, xK_n), goToSelected defaultGSConfig) + + -- windowbringer + , ((mod1Mask, xK_b), bringMenu) + , ((mod1Mask, xK_g), gotoMenu) + + -- paste x selection + , ((0, xK_Insert), pasteSelection) + + -- toggle bars + , ((mod1Mask, xK_backslash), sendMessage ToggleStruts) -- toggle both bars + , ((mod1Mask, xK_bracketleft), sendMessage $ ToggleStrut D) -- toggle bottom bar + , ((mod1Mask, xK_bracketright), sendMessage $ ToggleStrut U) -- toggle top bar + + -- BSP layout keybindings + -- resize + , ((mod4Mask .|. mod1Mask, xK_l ), sendMessage $ ExpandTowards R) + , ((mod4Mask .|. mod1Mask, xK_h ), sendMessage $ ExpandTowards L) + , ((mod4Mask .|. mod1Mask, xK_j ), sendMessage $ ExpandTowards D) + , ((mod4Mask .|. mod1Mask, xK_k ), sendMessage $ ExpandTowards U) + , ((mod4Mask .|. mod1Mask .|. shiftMask , xK_l ), sendMessage $ ShrinkFrom R) + , ((mod4Mask .|. mod1Mask .|. shiftMask , xK_h ), sendMessage $ ShrinkFrom L) + , ((mod4Mask .|. mod1Mask .|. shiftMask , xK_j ), sendMessage $ ShrinkFrom D) + , ((mod4Mask .|. mod1Mask .|. shiftMask , xK_k ), sendMessage $ ShrinkFrom U) + -- other + , ((mod1Mask, xK_r ), sendMessage Rotate) + , ((mod1Mask, xK_s ), sendMessage BSP.Swap) +-- , ((mod4Mask .|. shiftMask .|. controlMask , xK_j ), sendMessage $ SplitShift Prev) +-- , ((mod4Mask .|. shiftMask .|. controlMask , xK_k ), sendMessage $ SplitShift Next) + + + + ] ++ [ -- for extra workspace(s) + ((myModMask, key), (windows $ W.greedyView ws)) + | (key,ws) <- myExtraWorkspaces + ] ++ [ -- also for extra workspaces + ((myModMask .|. shiftMask, key), (windows $ W.shift ws)) + | (key,ws) <- myExtraWorkspaces + ] ++ [ -- to swap workspaces + ((mod4Mask .|. controlMask, k), windows $ swapWithCurrent i) + | (i, k) <- zip myWorkspaces [xK_1 ..] + ] + + + +-- layouts +myGap = spacingRaw False (Border sGap sGap sGap sGap) True (Border wGap wGap wGap wGap) True + +myLayouts = avoidStruts $ mouseResize $ windowNavigation $ myGap $ emptyBSP ||| ThreeColMid 1 (3/100) (1/2) ||| Grid ||| TwoPane (3/100) (1/2) ||| ThreeCol 1 (3/100) (1/2) ||| ThreeCol 2 (3/100) (1/2) ||| topRightMaster emptyBSP + +myLayoutHook = myLayouts + + +myLemonbarPP = def {ppCurrent = wrap "%{F#6c71c4}%{B#d33682}%{F-}" "%{F#d33682}%{B-}%{F-}" + , ppWsSep = " " + , ppHidden = wrap "%{B#268bd2}" "%{B-}" + , ppHiddenNoWindows = wrap "%{F#02fc45}" "%{F-}" + , ppTitle = wrap " %{B#6c71c4}%{F#f0f0f0} " " %{B-}" . shorten 75 + , ppUrgent = wrap "%{B#9cfc02} " " %{B-}%{F-}" + , ppLayout = wrap "%{r}%{B#99B1D5}%{F#232627} " " %{B-} " + , ppSep = " " + , ppExtras = [windowCount] + , ppOrder = \(ws:l:t:ex) -> [ws]++[t]++[l]++["%{B#50FA7B}%{F#232627} WIN:"]++ex++["%{B-}%{F-} "] + } + +main = do + notXMobar <- spawnPipe "lemonbar -b -g 1366x21+0+0 -B '#171520' -F '#ffffff' -f 'Source Han Sans JP:size=10' -o -3 -f 'RobotoMono Nerd Font:style=Regular:size=15' -f -n 'notXMobar' -o 0" + xmonad $ docks def + { + terminal = myTerminal, + focusFollowsMouse = True, + borderWidth = myBorderWidth, + modMask = myModMask, + workspaces = myWorkspaces, + normalBorderColor = nBorder, + focusedBorderColor = fBorder, + -- mouseBindings = myMouseBindings, + layoutHook = myLayoutHook, + manageHook = namedScratchpadManageHook myScratchpads, + -- handleEventHook = myEventHook, + logHook = dynamicLogWithPP myLemonbarPP { ppOutput = \x -> hPutStrLn notXMobar x}, + startupHook = myStartupHook +} `additionalKeys` myKeys + |