From 8286a58cd6f1ef383e94f12c5b679dcef8fd9799 Mon Sep 17 00:00:00 2001 From: Jisu Kim Date: Sun, 19 Jul 2020 08:11:39 +0900 Subject: [PATCH] Add macbook rules --- .gitconfig => gitconfig | 0 linux-macbook/Xresources | 1 + linux-macbook/dconf/user | Bin 0 -> 10688 bytes linux-macbook/pam_environment | 15 +++ linux-macbook/polybar/config | 202 +++++++++++++++++++++++++++++++++ linux-macbook/rofi/config.rasi | 9 ++ linux-macbook/rofi/numix.rasi | 144 +++++++++++++++++++++++ linux-macbook/sxhkd/sxhkdrc | 149 ++++++++++++++++++++++++ linux/Code/User/settings.json | 2 +- linux/bspwm/bspwmrc | 1 + mapping.ts | 61 ++++++---- scripts/dot.ts | 17 +-- 12 files changed, 573 insertions(+), 28 deletions(-) rename .gitconfig => gitconfig (100%) create mode 100644 linux-macbook/Xresources create mode 100644 linux-macbook/dconf/user create mode 100644 linux-macbook/pam_environment create mode 100644 linux-macbook/polybar/config create mode 100644 linux-macbook/rofi/config.rasi create mode 100644 linux-macbook/rofi/numix.rasi create mode 100644 linux-macbook/sxhkd/sxhkdrc diff --git a/.gitconfig b/gitconfig similarity index 100% rename from .gitconfig rename to gitconfig diff --git a/linux-macbook/Xresources b/linux-macbook/Xresources new file mode 100644 index 0000000..72a4471 --- /dev/null +++ b/linux-macbook/Xresources @@ -0,0 +1 @@ +Xft.dpi: 192 diff --git a/linux-macbook/dconf/user b/linux-macbook/dconf/user new file mode 100644 index 0000000000000000000000000000000000000000..6fafe1ca3ad6a883ade4d3f5de8326bae7403727 GIT binary patch literal 10688 zcma)?3wRXey~YOt3HN}gpomc^gvz+P+0AAXD8+(^5-TEAw5ZJP%qC;@=FTpJixn?b zykJqPpjAp05wFB*>#eQSs)ti-i`J)y7TQDA`e^NA>5)@u>Cy9hCllDD;b~WYyzl<^ zn{U4P?%%-K7g1IM1?S?MD>x7TWtbaq0Xh#Zg!vVG1urgwi{TQu6c)l|a5*dr zNTOZXcn8wZ(t|7c-UfL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(Zm(3VF}fDD@LWj-ox)NorkpQqd_m7Ckk`$X#stH9StK%Jvc` zlL`8cle3bU%Jw}%(UZ3r-_G;D52fP=(bY65HjL?9R^cC`zGzF?g5=S#zU%HWUBC+ z-Wbhy!>xF1=8rrTS!_wxh9~nMi>K#=?L;{0B+PW8!7^j9NXksshZANbMT9xS0KN!yl|!@Fq56sY*Z1fTE&TokP!_%ApmqrE-_Uvgu9=Z{&HSc1c<>0< zsxRvkT%Yi-@9idP_`~TM{d76bk5rZpoMkuU|2u=ApLT86DtcwaE*oO~I_q0Ok5$uBv)da&Q{>oZm6Y?keQ5+yMo_6uy5vTly%+{pLCi%76kTb{q9 zw3hA4V{hl0(>2d_>!3&6e;i?+^fx~2Cs~DyA^+cu6f)%&m&4#{$}-tQjN&E7qa8uUFm8W-224^rQHieDK6pvmdO?-BU)o zrL1exPO-pdFX-%A__|+E*L8v4V%*(Z>XnMt((b9E-BU%H+IcKfQ)$`jo-)=wWnELZ zZD#kh_1)7(n+ipLdFzp7ynC`(Q;`v|*x$|CMR&2&BY8vjKm!=(Go6Wx==n{rM` zd(!Ty8oQ@zX!582?r9>2ny0f46HR`v?2+hD%XB7cY)V-f-hEib9_i{>m700W@SyQC z<8MYypY!`H?sH$CANP5$&#oEc!!f79Y;Y3VttZ1~BAsH-$KEj&k2=X@BB}Cx3oe5?JDQ3#MA+g- zc-0k)MI$C#MBA*3CL7aMB1U#vw*7yLbua3)J1NBAl}oDVmh`&G>)grEI6SM#MvIex zlISy?_ip}Ku;=Wcxu1QbPLBT8Y!P2if$u;yr0b&%afbs()JfM-xKzSSgp+YI9ZAPI ze>A3|;Rcm!DDZBot8Oc1#zXHDL+kk6>rp(voyuJc8iy~^=rfK@!zcPt=iA_POfR9B zov$RcPgA-K^Yj%Jhx@KcJy@^iIi+$j$L` +format-connected-underline = #9f78e1 +label-connected = %essid% + +format-disconnected = +;format-disconnected = +;format-disconnected-underline = ${self.format-connected-underline} +;label-disconnected = %ifname% disconnected +;label-disconnected-foreground = ${colors.foreground-alt} + +ramp-signal-0 =  +ramp-signal-1 =  +ramp-signal-2 =  +ramp-signal-3 =  +ramp-signal-4 =  +ramp-signal-foreground = ${colors.foreground-alt} + +[module/eth] +type = internal/network +interface = enp3s0 +interval = 3.0 + +format-connected-underline = #55aa55 +format-connected-prefix = " " +format-connected-prefix-foreground = ${colors.foreground-alt} +label-connected = %local_ip% + +format-disconnected = +;format-disconnected = +;format-disconnected-underline = ${self.format-connected-underline} +;label-disconnected = %ifname% disconnected +;label-disconnected-foreground = ${colors.foreground-alt} + +[module/date] +type = internal/date +interval = 5 + +date = +date-alt = " %Y-%m-%d" + +time = %H:%M +time-alt = %H:%M:%S + +format-prefix =  +format-prefix-foreground = ${colors.foreground-alt} +format-underline = #0a6cf5 + +label = %date% %time% + +[module/pulseaudio] +type = internal/pulseaudio + +format-volume = +label-volume = VOL %percentage%% +label-volume-foreground = ${root.foreground} + +label-muted = 🔇 muted +label-muted-foreground = #666 + +bar-volume-width = 10 +bar-volume-foreground-0 = #55aa55 +bar-volume-foreground-1 = #55aa55 +bar-volume-foreground-2 = #55aa55 +bar-volume-foreground-3 = #55aa55 +bar-volume-foreground-4 = #55aa55 +bar-volume-foreground-5 = #f5a70a +bar-volume-foreground-6 = #ff5555 +bar-volume-gradient = false +bar-volume-indicator = | +bar-volume-indicator-font = 2 +bar-volume-fill = ─ +bar-volume-fill-font = 2 +bar-volume-empty = ─ +bar-volume-empty-font = 2 +bar-volume-empty-foreground = ${colors.foreground-alt} + +[settings] +screenchange-reload = true +;compositing-background = xor +;compositing-background = screen +;compositing-foreground = source +;compositing-border = over +;pseudo-transparency = false + +[global/wm] +margin-top = 5 +margin-bottom = 5 + +; vim:ft=dosini diff --git a/linux-macbook/rofi/config.rasi b/linux-macbook/rofi/config.rasi new file mode 100644 index 0000000..2be4195 --- /dev/null +++ b/linux-macbook/rofi/config.rasi @@ -0,0 +1,9 @@ +configuration { + font: "TerminessTTF Nerd Font 14"; + show-icons: true; + icon-theme: "Numix-Circle"; + combi-modi: "window,drun,ssh"; + theme: "numix"; + lines: 5; + dpi: 192; +} diff --git a/linux-macbook/rofi/numix.rasi b/linux-macbook/rofi/numix.rasi new file mode 100644 index 0000000..e349f7b --- /dev/null +++ b/linux-macbook/rofi/numix.rasi @@ -0,0 +1,144 @@ +/** + * ROFI Color theme + * User: JT (adpated from lb by Qball) + * Copyright: Dave Davenport + */ + +* { + selected-normal-foreground: @foreground; + foreground: #FFFFFF; + normal-foreground: @foreground; + alternate-normal-background: rgba ( 255, 255, 255, 7 % ); + red: rgba ( 220, 50, 47, 100 % ); + selected-urgent-foreground: rgba ( 51, 51, 51, 100 % ); + blue: rgba ( 38, 139, 210, 100 % ); + urgent-foreground: rgba ( 255, 153, 153, 100 % ); + alternate-urgent-background: rgba ( 255, 255, 255, 7 % ); + active-foreground: @bordercolor; + lightbg: rgba ( 238, 232, 213, 100 % ); + selected-active-foreground: @foreground; + alternate-active-background: rgba ( 255, 255, 255, 7 % ); + background: rgba ( 21, 21, 21, 40 % ); + bordercolor: rgba ( 235, 86, 77, 100 % ); + alternate-normal-foreground: @foreground; + normal-background: rgba ( 0, 0, 0, 0 % ); + lightfg: rgba ( 88, 104, 117, 100 % ); + selected-normal-background: @bordercolor; + border-color: @bordercolor; + spacing: 2; + separatorcolor: @bordercolor; + urgent-background: rgba ( 0, 0, 0, 0 % ); + selected-urgent-background: rgba ( 255, 153, 153, 100 % ); + alternate-urgent-foreground: @urgent-foreground; + background-color: rgba ( 0, 0, 0, 0 % ); + alternate-active-foreground: @active-foreground; + active-background: rgba ( 0, 0, 0, 0 % ); + selected-active-background: @bordercolor; +} +#window { + background-color: @background; + border: 1; + border-radius: 10; + padding: 5; +} +#mainbox { + border: 0; + padding: 0; +} +#message { + border: 1px dash 0px 0px ; + border-color: @separatorcolor; + padding: 1px ; +} +#textbox { + text-color: @foreground; +} +#listview { + fixed-height: 0; + border: 2px solid 0px 0px ; + border-color: @separatorcolor; + spacing: 2px ; + scrollbar: true; + padding: 2px 0px 0px ; +} +#element { + border: 0; + padding: 10px 1px; +} +#element.normal.normal { + background-color: @normal-background; + text-color: @normal-foreground; +} +#element.normal.urgent { + background-color: @urgent-background; + text-color: @urgent-foreground; +} +#element.normal.active { + background-color: @active-background; + text-color: @active-foreground; +} +#element.selected.normal { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} +#element.selected.urgent { + background-color: @selected-urgent-background; + text-color: @selected-urgent-foreground; +} +#element.selected.active { + background-color: @selected-active-background; + text-color: @selected-active-foreground; +} +#element.alternate.normal { + background-color: @alternate-normal-background; + text-color: @alternate-normal-foreground; +} +#element.alternate.urgent { + background-color: @alternate-urgent-background; + text-color: @alternate-urgent-foreground; +} +#element.alternate.active { + background-color: @alternate-active-background; + text-color: @alternate-active-foreground; +} +#scrollbar { + width: 4px ; + border: 0; + handle-width: 8px ; + padding: 0; + handle-color: @bordercolor; +} +#sidebar { + border: 2px dash 0px 0px ; + border-color: @separatorcolor; +} +#button.selected { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} +#inputbar { + spacing: 0; + text-color: @normal-foreground; + padding: 1px ; +} +#case-indicator { + spacing: 0; + text-color: @normal-foreground; +} +#entry { + spacing: 0; + text-color: @normal-foreground; +} +#prompt { + spacing: 0; + text-color: @normal-foreground; +} +#inputbar { + children: [ prompt,textbox-prompt-colon,entry,case-indicator ]; +} +#textbox-prompt-colon { + expand: false; + str: ":"; + margin: 0px 0.3em 0em 0em ; + text-color: @normal-foreground; +} diff --git a/linux-macbook/sxhkd/sxhkdrc b/linux-macbook/sxhkd/sxhkdrc new file mode 100644 index 0000000..53722a4 --- /dev/null +++ b/linux-macbook/sxhkd/sxhkdrc @@ -0,0 +1,149 @@ +# +# wm independent hotkeys +# + +# terminal emulator +super + Return + alacritty + +# program launcher +super + @space + rofi -show combi + +# make sxhkd reload its configuration files: +super + Escape + pkill -USR1 -x sxhkd + +# screen capture +super + ctrl + shift + {3,4} + maim -u { ~/Pictures/screenshot.png ,-s | xclip -selection clipboard -t image/png } + +# +# bspwm hotkeys +# + +# quit/restart bspwm +super + alt + {q,r} + bspc {quit,wm -r} + +# close and kill +super + {_,shift + }w + bspc node -{c,k} + +# alternate between the tiled and monocle layout +super + m + bspc desktop -l next + +# send the newest marked node to the newest preselected node +super + y + bspc node newest.marked.local -n newest.!automatic.local + +# swap the current node and the biggest node +super + g + bspc node -s biggest + +# +# state/flags +# + +# set the window state +super + {t,shift + t, f,shift + f} + bspc node -t {tiled,pseudo_tiled,floating,fullscreen} + +super + s + bspc node -g sticky + +super + shift + p + bspc node --state \~pseudo_tiled + +# +# focus/swap +# + +# focus the node in the given direction +super + {_,shift + }{h,j,k,l} + bspc node -{f,s} {west,south,north,east} + +# focus the node for the given path jump +# super + {p,b,comma,period} +# bspc node -f @{parent,brother,first,second} + +# focus the next/previous node in the current desktop +super + {_,shift + }c + bspc node -f {next,prev}.local + +# focus the next/previous desktop in the current monitor +super + bracket{left,right} + bspc desktop -f {prev,next}.local + +# focus the last node/desktop +super + {grave,Tab} + bspc {node,desktop} -f last + +# focus the older or newer node in the focus history +super + {o,i} + bspc wm -h off; \ + bspc node {older,newer} -f; \ + bspc wm -h on + +# focus or send to the given desktop +super + {_,shift + }{1-9,0} + bspc {desktop -f,node -d} '^{1-9,10}' + +# +# preselect +# + +# preselect the direction +super + ctrl + {h,j,k,l} + bspc node -p {west,south,north,east} + +# preselect the ratio +super + ctrl + {1-9} + bspc node -o 0.{1-9} + +# cancel the preselection for the focused node +super + ctrl + space + bspc node -p cancel + +# cancel the preselection for the focused desktop +super + ctrl + shift + space + bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel + +# +# move/resize +# + +# expand a window by moving one of its side outward +super + alt + {h,j,k,l} + bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0} + +# contract a window by moving one of its side inward +super + alt + shift + {h,j,k,l} + bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0} + +# move a floating window +super + {Left,Down,Up,Right} + bspc node -v {-20 0,0 20,0 -20,20 0} + +# toggle pip mode +super + p + bspc node -g sticky; \ + bspc node --state \~floating; \ + xdotool getactivewindow windowsize 640 360 windowmove $(expr 1920 - 640 - 45) $(expr 1080 - 360 - 30) + + +XF86AudioMute + pactl set-sink-mute @DEFAULT_SINK@ toggle + +XF86AudioLowerVolume + pactl set-sink-volume @DEFAULT_SINK@ -5% + +XF86AudioRaiseVolume + pactl set-sink-volume @DEFAULT_SINK@ +5% + +XF86MonBrightnessUp + xbacklight -ctrl gmux_backlight -inc 5 + +XF86MonBrightnessDown + xbacklight -ctrl gmux_backlight -dec 5 diff --git a/linux/Code/User/settings.json b/linux/Code/User/settings.json index 9f6b053..84c8b09 100644 --- a/linux/Code/User/settings.json +++ b/linux/Code/User/settings.json @@ -78,5 +78,5 @@ "editor.formatOnSave": true, "vim.enableNeovim": true, "vim.useCtrlKeys": false, - "editor.fontSize": 16 + "editor.fontSize": 14 } diff --git a/linux/bspwm/bspwmrc b/linux/bspwm/bspwmrc index 80c63ce..bb8705e 100755 --- a/linux/bspwm/bspwmrc +++ b/linux/bspwm/bspwmrc @@ -43,6 +43,7 @@ fcitx5 & dunst & sxhkd & dex -a +libinput-gestures-setup restart xinput set-prop 'Logitech G102 LIGHTSYNC Gaming Mouse' 'libinput Natural Scrolling Enabled' 1 xinput set-prop 'Logitech G102 LIGHTSYNC Gaming Mouse' 'libinput Accel Speed' -0.5 diff --git a/mapping.ts b/mapping.ts index 3b33070..697b2ae 100755 --- a/mapping.ts +++ b/mapping.ts @@ -1,7 +1,13 @@ import { dot, DotOption } from "./scripts/dot.ts"; +const common: DotOption = { + link: { + gitconfig: ".gitconfig", + }, +}; + const linux: DotOption = { - hostname: ["MBP", "office2"], + hostname: ["office2"], install: [ "sudo pacman -S git", `bash -c "cd && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si && cd .. && rm -rf yay"`, @@ -16,28 +22,43 @@ const linux: DotOption = { fcitx5 fcitx5-qt fcitx5-gtk fcitx5-hangul fcitx5-anthy kcm-fcitx5 numix-gtk-theme-git numix-circle-icon-theme-git`, ], - link: [ - ["linux/alacritty", ".config/alacritty"], - ["linux/bin/ufetch", ".local/bin/ufetch"], - ["linux/bspwm", ".config/bspwm"], - ["linux/Code/User/settings.json", ".config/Code/User/settings.json"], - ["linux/dunst", ".config/dunst"], - ["linux/omz", ".config/omz"], - ["linux/picom", ".config/picom"], - ["linux/polybar", ".config/polybar"], - ["linux/rofi", ".config/rofi"], - ["linux/sxhkd", ".config/sxhkd"], - ["linux/fcitx5", ".config/fcitx5"], - ["linux/dconf", ".config/dconf"], - ["linux/bakamplayer.ini", ".config/bakamplayer.ini"], - ["linux/xinitrc", ".xinitrc"], - ["linux/pam_environment", ".pam_environment"], - ["linux/zshrc", ".zshrc"], - ], + link: { + ...common.link, + "linux/alacritty": ".config/alacritty", + "linux/bin/ufetch": ".local/bin/ufetch", + "linux/bspwm": ".config/bspwm", + "linux/Code/User/settings.json": ".config/Code/User/settings.json", + "linux/dunst": ".config/dunst", + "linux/omz": ".config/omz", + "linux/picom": ".config/picom", + "linux/polybar": ".config/polybar", + "linux/rofi": ".config/rofi", + "linux/sxhkd": ".config/sxhkd", + "linux/fcitx5": ".config/fcitx5", + "linux/dconf": ".config/dconf", + "linux/bakamplayer.ini": ".config/bakamplayer.ini", + "linux/xinitrc": ".xinitrc", + "linux/pam_environment": ".pam_environment", + "linux/zshrc": ".zshrc", + }, +}; + +const linuxMacbook: DotOption = { + ...linux, + hostname: "MBP", + link: { + ...linux.link, + "linux-macbook/dconf": ".config/dconf", + "linux-macbook/polybar": ".config/polybar", + "linux-macbook/rofi": ".config/rofi", + "linux-macbook/sxhkd": ".config/sxhkd", + "linux-macbook/pam_environment": ".pam_environment", + "linux-macbook/Xresources": ".Xresources", + }, }; try { - await dot(Deno.args, [linux]); + await dot(Deno.args, [linux, linuxMacbook]); } catch (err) { console.log(err.message); } diff --git a/scripts/dot.ts b/scripts/dot.ts index f6d9d38..d526c90 100644 --- a/scripts/dot.ts +++ b/scripts/dot.ts @@ -9,7 +9,7 @@ import { export interface DotOption { hostname?: string | string[]; install?: string[]; - link?: [string, string][]; + link?: Record; } export async function dot(args: string[], options: DotOption[]) { @@ -30,17 +30,20 @@ export async function dot(args: string[], options: DotOption[]) { } } } else if (flags._[0] === "link" && target.link) { - for (const link of target.link) { + for (const from in target.link) { try { - const path = `${Deno.env.get("HOME")}/${link[1]}`; + const path = `${Deno.env.get("HOME")}/${target.link[from]}`; if (existsSync(path)) { - console.log(`${path} does exist. move to ${path}.bak`); - moveSync(path, `${path}.bak`); + let i = 0; + let mvPath = `${path}.bak`; + while (existsSync(mvPath)) mvPath = `${path}.${++i}.bak`; + console.log(`${path} does exist. move to ${mvPath}`); + moveSync(path, mvPath); } - await ensureSymlink(Deno.realPathSync(link[0]), path); + await ensureSymlink(Deno.realPathSync(from), path); console.log(`Link: ${path}`); } catch (err) { - throw Error(`${err.message}\nerror link: ${JSON.stringify(link)}`); + throw Error(`${err.message}\nerror link: ${JSON.stringify(from)}`); } } }