diff --git a/.gitignore b/.gitignore index 0347c7d..3f7ea19 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ shell/.config/zsh/plugins/zsh-syntax-highlighting shell/.config/zsh/plugins/zsh-vi-mode qtile/.config/qtile/theme.txt lupan-clock/lupan-clock +lupan-clock/stdout-clock lupan-wm/target *~ __pycache__ diff --git a/kitty/.config/kitty/kitty.conf b/kitty/.config/kitty/kitty.conf index f1773aa..6b9b1b0 100644 --- a/kitty/.config/kitty/kitty.conf +++ b/kitty/.config/kitty/kitty.conf @@ -1,5 +1,5 @@ font_family HurmitNerdFont -font_size 11 +font_size 10 cursor_blink_interval 0 enable_audio_bell no diff --git a/kwm/.config/kwm/config.zon b/kwm/.config/kwm/config.zon new file mode 100644 index 0000000..793ea26 --- /dev/null +++ b/kwm/.config/kwm/config.zon @@ -0,0 +1,1196 @@ +.{ + // environment variables + // used by processes spawned by kwm + .env = .{ + // .{ "key", "value" }, + }, + + // working direction of processes spawned by kwm + .working_directory = .home, + + .startup_cmds = .{ + .{ "sh", "-c", "sleep 1; wlr-randr --output DP-1 --mode 3840x2160 --scale 2; wlr-randr --output HDMI-A-1 --mode 3840x2160 --scale 2 --left-of DP-1" }, + }, + + // null + // or + // .{ .name = []const u8, .size = u32 } + .xcursor_theme = null, + + // ?u32 + // solid color background + // note: set this to null if you use other wallpaper program like `swaybg`, orelse it will be covered by this and unable to see + .background = 0x33000000, + + .bar = .{ + .show_default = true, + // .top + // .bottom + .position = .top, + + .font = "monospace:size=24", + + .scheme = .{ + .normal = .{ + .fg = 0x828bb8ff, + .bg = 0x1b1d2bd0, + }, + .select = .{ + .fg = 0x444a73ff, + .bg = 0xc8d3f5d0, + }, + }, + + // set null to disable tags part + .tags = .{ + // tags show on bar + .tags = .{ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, + + // click callback + // each part supports left/right/middle/side/extra/forward/back/task + // set null to disable + .click = .{ + // could use 0 there because it will be replace with the tag clicked + .left = .{ .set_output_tag = .{ .tag = .{ .tag = 0 } } }, + .right = .{ .toggle_output_tag = .{ .mask = 0 } }, + .middle = .{ .toggle_window_tag = .{ .mask = 0 } }, + }, + }, + // set null to disable mode part + .mode = .{ + // mode tags show on bar + // display full mode string by default + .tags = .{ + .{ "default", "" }, // hide mode tag in default mode + .{ "passthrough", "P" }, // only show "P" on bar in passthrough mode + .{ "floating", "F" }, // only show "F" on bar in floating mode + }, + + .click = .{ + .left = .{ .switch_mode = .{ .mode = "default" } }, + }, + }, + // set null to disable layout part + .layout = .{ + // layout tags show on bar + // {{?}} will be replaced with managed window count, when the count is 0, `?` will be used as replacement. + // e.g. [{{{=}}], when managed window count > 0, [N] will be showed, else [=] will be showed + .tags = .{ + .tile = .{ + .left = "[]=", + .right = "=[]", + .top = "[^]", + .bottom = "[_]", + }, + .grid = .{ + .horizontal = "|+|", + .vertical = "|||", + }, + .monocle = "[{{=}}]", + .deck = .{ + .left = "[{{D}}]=", + .right = "=[{{D}}]", + .top = "[{{D}}^]", + .bottom = "[{{D}}_]", + }, + .scroller = "[==]", + .float = "><>", + }, + + .click = .{ + .left = .switch_to_previous_layout, + }, + }, + // set null to disable title part + .title = .{ + .click = .{ + .left = .{ .zoom = .{ .swap = false } }, + }, + }, + // set null to disable status part + .status = .{ + .data = .stdin, + + .click = .{ + .middle = .{ .spawn = .{ .argv = .{ "kitty", "--single-instance", "--instance-group", "default" } } }, + }, + }, + + // override colors + .override_colors = .{ + // areas: + // .tags + // .{ .mode = "floating" or other modes }, null will match all mode + // .{ layout = .tile or other layout }, null will match all layouts + // .title + // .status + // + // scheme is a struct, no need to specify all fields: + // .{ + // .normal = .{ + // .fg = u32, + // .bg = u32, + // }, + // .select = .{ + // .fg = u32, + // .bg = u32, + // } + // } + // + // mode, layout and status will only use the `normal` color + // tags and title will use both `normal` and `select` color + // + + // set scheme for mode tag + .{ + .area = .{ .mode = null }, + .scheme = .{ + .normal = .{ + .fg = 0x444a73ff, + .bg = 0xc8d3f5d0, + } + } + }, + } + }, + + .sloppy_focus = false, + + // .none + // .on_focus_changed: warp cursor to the center of window focused + // .on_output_changed: warp cursor to the center of output focused + .cursor_warp = .none, + + // disable wrap around when iter focus or swap window in scroller layout + .disable_wrap_around_for_scroller = false, + + // if to remember last floating geometry + .remember_floating_geometry = false, + + .auto_swallow = true, + + // .top: stack top + // .bottom: stack bottom + // .stack_top: for tile and deck layout + // .above_focused + // .below_focused + .default_attach_mode = .{ + .tile = .top, + .grid = .top, + .monocle = .top, + .deck = .stack_top, + .scroller = .below_focused, + .float = .top, + }, + + // .csd + // .ssd + .default_window_decoration = .ssd, + + // window border + .border = .{ + .width = 2, + .color = .{ + .focus = 0xffc777ff, + .unfocus = 0x828bb8ff, + .swallowing = 0x0830e6ff, + }, + }, + + // .tile + // .grid + // .monocle + // .deck + // .scroller + // .float + .default_layout = .tile, + .layout = .{ + .tile = .{ + .nmaster = 1, + .mfact = 0.55, + .inner_gap = 12, + .outer_gap = 9, + + // .left + // .right + // .top + // .bottom + .master_location = .left, + }, + .grid = .{ + .outer_gap = 9, + .inner_gap = 12, + + // .horizontal + // .vertical + .direction = .horizontal, + }, + .monocle = .{ + .gap = 0, + }, + .deck = .{ + .nmaster = 1, + .mfact = 0.55, + .inner_gap = 12, + .outer_gap = 9, + + // .left + // .right + // .top + // .bottom + .master_location = .left, + }, + .scroller = .{ + .mfact = 0.5, + .inner_gap = 16, + .outer_gap = 9, + }, + }, + + // key/pointer bindings + .bindings = .{ + // repeat info for key repeat event, different with the repeat_info of input device + .repeat_info = .{ + .rate = 50, + .delay = 300, + }, + + // list of key bindings + // full scheme: + // mode: string(< 16 bytes) + // "default" and "lock" are defined by default + // "default" is the default mode, if you not set `mode`, the binding will be seemed as "default" mode + // when the session locked, kwm will switch to "lock" mode + // you could define any other mode + // keysym: keysym string + // modifiers: + // a struct with fields: shift, ctrl, mod1, mod3, mod4, mod5, and all of these fields are `false` by default + // set modifiers to .{} means key binding without any modifier + // event: key binding trigger event + // there are two options: + // .event = .{ + // .repeat = action + // } + // after the key pressed, the action will repeatly trigger until key released or any another key pressed + // + // .event = .{ + // .click = .{ + // .pressed = null or action, default is null + // .released = null or action, default is null + // } + // } + // the corrosponding action will only trigger once when key pressed or released + // the pressed action and released action could define at the same time + .key = .{ + .{ + .keysym = "r", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .reload_config, + }, + }, + }, + + // passthrough + .{ + .keysym = "Escape", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .switch_mode = .{ .mode = "passthrough" }, + }, + }, + }, + }, + .{ + .mode = "passthrough", + .keysym = "Escape", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .switch_mode = .{ .mode = "default" }, + }, + }, + }, + }, + + // floating + .{ + .keysym = "f", + .modifiers = .{ .mod4 = true, .ctrl = true }, + .event = .{ + .click = .{ + .pressed = .{ + .switch_mode = .{ .mode = "floating", .auto_quit = .once_unbound_pressed }, + }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "l", + .modifiers = .{ .mod4 = true }, + .event = .{ + .repeat = .{ + .move = .{ .step = .{ .horizontal = 10 } }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "h", + .modifiers = .{ .mod4 = true }, + .event = .{ + .repeat = .{ + .move = .{ .step = .{ .horizontal = -10 } }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "j", + .modifiers = .{ .mod4 = true }, + .event = .{ + .repeat = .{ + .move = .{ .step = .{ .vertical = 10 } }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "k", + .modifiers = .{ .mod4 = true }, + .event = .{ + .repeat = .{ + .move = .{ .step = .{ .vertical = -10 } }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "l", + .modifiers = .{ .mod4 = true, .ctrl = true }, + .event = .{ + .repeat = .{ + .resize = .{ .step = .{ .horizontal = 10 } }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "h", + .modifiers = .{ .mod4 = true, .ctrl = true }, + .event = .{ + .repeat = .{ + .resize = .{ .step = .{ .horizontal = -10 } }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "j", + .modifiers = .{ .mod4 = true, .ctrl = true }, + .event = .{ + .repeat = .{ + .resize = .{ .step = .{ .vertical = 10 } }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "k", + .modifiers = .{ .mod4 = true, .ctrl = true }, + .event = .{ + .repeat = .{ + .resize = .{ .step = .{ .vertical = -10 } }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "l", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .snap = .{ .edge = .right }, + }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "h", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .snap = .{ .edge = .left }, + }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "j", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .snap = .{ .edge = .bottom }, + }, + }, + }, + }, + .{ + .mode = "floating", + .keysym = "k", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .snap = .{ .edge = .top }, + }, + }, + }, + }, + + // default + .{ + .keysym = "q", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .quit = .{ + .exit_session = true, + // command to run before quit + // will quit only when the process exit with zero status + // e.g. .{ "sh", "-c", "~/cleanup.sh" } + .hook = null, + }, + }, + }, + }, + }, + .{ + .keysym = "c", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .close, + }, + }, + }, + .{ + .keysym = "Return", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .zoom = .{ .swap = true }, + }, + }, + }, + }, + .{ + .keysym = "h", + .modifiers = .{ .mod4 = true, .ctrl = true }, + .event = .{ + .click = .{ + .pressed = .focus_master_return, + }, + }, + }, + .{ + .keysym = "l", + .modifiers = .{ .mod4 = true, .ctrl = true }, + .event = .{ + .click = .{ + .pressed = .focus_master_return, + }, + }, + }, + .{ + .keysym = "b", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .toggle_bar, + }, + }, + }, + .{ + .keysym = "j", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .focus_iter = .{ .direction = .forward }, + }, + }, + }, + }, + .{ + .keysym = "k", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .focus_iter = .{ .direction = .reverse }, + }, + }, + }, + }, + .{ + .keysym = "j", + .modifiers = .{ .mod4 = true, .ctrl = true }, + .event = .{ + .click = .{ + .pressed = .{ + .focus_iter = .{ .direction = .forward, .skip = .floating }, + }, + }, + }, + }, + .{ + .keysym = "k", + .modifiers = .{ .mod4 = true, .ctrl = true }, + .event = .{ + .click = .{ + .pressed = .{ + .focus_iter = .{ .direction = .reverse, .skip = .floating }, + }, + }, + }, + }, + .{ + .keysym = "j", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .swap = .{ .direction = .forward }, + }, + }, + }, + }, + .{ + .keysym = "k", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .swap = .{ .direction = .reverse }, + }, + }, + }, + }, + .{ + .keysym = "period", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .focus_output_iter = .{ .direction = .forward }, + }, + }, + }, + }, + .{ + .keysym = "comma", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .focus_output_iter = .{ .direction = .reverse }, + }, + }, + }, + }, + .{ + .keysym = "period", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .send_to_output = .{ .direction = .forward }, + }, + }, + }, + }, + .{ + .keysym = "comma", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .send_to_output = .{ .direction = .reverse }, + }, + }, + }, + }, + .{ + .keysym = "m", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .toggle_fullscreen = .{ .in_window = true }, + }, + }, + }, + }, + .{ + .keysym = "f", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .toggle_fullscreen = .{ .in_window = false }, + }, + }, + }, + }, + .{ + .keysym = "e", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .toggle_maximize, + }, + }, + }, + .{ + .keysym = "space", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .switch_to_previous_layout, + }, + }, + }, + .{ + .keysym = "f", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .toggle_floating, + }, + }, + }, + .{ + .keysym = "s", + .modifiers = .{ .mod4 = true, .ctrl = true }, + .event = .{ + .click = .{ + .pressed = .toggle_sticky, + }, + }, + }, + .{ + .keysym = "a", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .toggle_swallow, + }, + }, + }, + .{ + .keysym = "f", + .modifiers = .{ .mod4 = true, .mod1 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .switch_layout = .{ .layout = .float }, + }, + }, + }, + }, + .{ + .keysym = "t", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .switch_layout = .{ .layout = .tile }, + }, + }, + }, + }, + .{ + .keysym = "g", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .switch_layout = .{ .layout = .grid }, + }, + }, + }, + }, + .{ + .keysym = "d", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .switch_layout = .{ .layout = .deck }, + }, + }, + }, + }, + .{ + .keysym = "m", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .switch_layout = .{ .layout = .monocle }, + }, + }, + }, + }, + .{ + .keysym = "s", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .switch_layout = .{ .layout = .scroller }, + }, + }, + }, + }, + .{ + .keysym = "Tab", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .switch_to_previous_tag, + }, + }, + }, + .{ + .keysym = "apostrophe", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .set_output_tag = .{ .tag = .{ .occupied = .forward } }, + }, + }, + }, + }, + .{ + .keysym = "semicolon", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .set_output_tag = .{ .tag = .{ .occupied = .reverse } }, + }, + }, + }, + }, + .{ + .keysym = "apostrophe", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .set_window_tag = .{ .tag = .{ .unoccupied = .forward } }, + }, + }, + }, + }, + .{ + .keysym = "semicolon", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .set_window_tag = .{ .tag = .{ .unoccupied = .reverse } }, + }, + }, + }, + }, + + .{ .keysym = "1", .modifiers = .{ .mod4 = true }, .event = .{ .click = .{ .pressed = .{ .set_output_tag = .{ .tag = .{ .tag = 0b1 } } } } } }, + .{ .keysym = "2", .modifiers = .{ .mod4 = true }, .event = .{ .click = .{ .pressed = .{ .set_output_tag = .{ .tag = .{ .tag = 0b10 } } } } } }, + .{ .keysym = "3", .modifiers = .{ .mod4 = true }, .event = .{ .click = .{ .pressed = .{ .set_output_tag = .{ .tag = .{ .tag = 0b100 } } } } } }, + .{ .keysym = "4", .modifiers = .{ .mod4 = true }, .event = .{ .click = .{ .pressed = .{ .set_output_tag = .{ .tag = .{ .tag = 0b1000 } } } } } }, + .{ .keysym = "5", .modifiers = .{ .mod4 = true }, .event = .{ .click = .{ .pressed = .{ .set_output_tag = .{ .tag = .{ .tag = 0b10000 } } } } } }, + .{ .keysym = "6", .modifiers = .{ .mod4 = true }, .event = .{ .click = .{ .pressed = .{ .set_output_tag = .{ .tag = .{ .tag = 0b100000 } } } } } }, + .{ .keysym = "7", .modifiers = .{ .mod4 = true }, .event = .{ .click = .{ .pressed = .{ .set_output_tag = .{ .tag = .{ .tag = 0b1000000 } } } } } }, + .{ .keysym = "8", .modifiers = .{ .mod4 = true }, .event = .{ .click = .{ .pressed = .{ .set_output_tag = .{ .tag = .{ .tag = 0b10000000 } } } } } }, + .{ .keysym = "9", .modifiers = .{ .mod4 = true }, .event = .{ .click = .{ .pressed = .{ .set_output_tag = .{ .tag = .{ .tag = 0b100000000 } } } } } }, + .{ .keysym = "0", .modifiers = .{ .mod4 = true }, .event = .{ .click = .{ .pressed = .{ .set_output_tag = .{ .tag = .{ .tag = 0b111111111 } } } } } }, + + .{ .keysym = "1", .modifiers = .{ .mod4 = true, .ctrl = true }, .event = .{ .click = .{ .pressed = .{ .toggle_output_tag = .{ .mask = 0b1 } } } } }, + .{ .keysym = "2", .modifiers = .{ .mod4 = true, .ctrl = true }, .event = .{ .click = .{ .pressed = .{ .toggle_output_tag = .{ .mask = 0b10 } } } } }, + .{ .keysym = "3", .modifiers = .{ .mod4 = true, .ctrl = true }, .event = .{ .click = .{ .pressed = .{ .toggle_output_tag = .{ .mask = 0b100 } } } } }, + .{ .keysym = "4", .modifiers = .{ .mod4 = true, .ctrl = true }, .event = .{ .click = .{ .pressed = .{ .toggle_output_tag = .{ .mask = 0b1000 } } } } }, + .{ .keysym = "5", .modifiers = .{ .mod4 = true, .ctrl = true }, .event = .{ .click = .{ .pressed = .{ .toggle_output_tag = .{ .mask = 0b10000 } } } } }, + .{ .keysym = "6", .modifiers = .{ .mod4 = true, .ctrl = true }, .event = .{ .click = .{ .pressed = .{ .toggle_output_tag = .{ .mask = 0b100000 } } } } }, + .{ .keysym = "7", .modifiers = .{ .mod4 = true, .ctrl = true }, .event = .{ .click = .{ .pressed = .{ .toggle_output_tag = .{ .mask = 0b1000000 } } } } }, + .{ .keysym = "8", .modifiers = .{ .mod4 = true, .ctrl = true }, .event = .{ .click = .{ .pressed = .{ .toggle_output_tag = .{ .mask = 0b10000000 } } } } }, + .{ .keysym = "9", .modifiers = .{ .mod4 = true, .ctrl = true }, .event = .{ .click = .{ .pressed = .{ .toggle_output_tag = .{ .mask = 0b100000000 } } } } }, + + .{ .keysym = "1", .modifiers = .{ .mod4 = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .set_window_tag = .{ .tag = .{ .tag = 0b1 } } } } } }, + .{ .keysym = "2", .modifiers = .{ .mod4 = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .set_window_tag = .{ .tag = .{ .tag = 0b10 } } } } } }, + .{ .keysym = "3", .modifiers = .{ .mod4 = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .set_window_tag = .{ .tag = .{ .tag = 0b100 } } } } } }, + .{ .keysym = "4", .modifiers = .{ .mod4 = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .set_window_tag = .{ .tag = .{ .tag = 0b1000 } } } } } }, + .{ .keysym = "5", .modifiers = .{ .mod4 = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .set_window_tag = .{ .tag = .{ .tag = 0b10000 } } } } } }, + .{ .keysym = "6", .modifiers = .{ .mod4 = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .set_window_tag = .{ .tag = .{ .tag = 0b100000 } } } } } }, + .{ .keysym = "7", .modifiers = .{ .mod4 = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .set_window_tag = .{ .tag = .{ .tag = 0b1000000 } } } } } }, + .{ .keysym = "8", .modifiers = .{ .mod4 = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .set_window_tag = .{ .tag = .{ .tag = 0b10000000 } } } } } }, + .{ .keysym = "9", .modifiers = .{ .mod4 = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .set_window_tag = .{ .tag = .{ .tag = 0b100000000 } } } } } }, + .{ .keysym = "0", .modifiers = .{ .mod4 = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .set_window_tag = .{ .tag = .{ .tag = 0b111111111 } } } } } }, + + .{ .keysym = "1", .modifiers = .{ .mod4 = true, .ctrl = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .toggle_window_tag = .{ .mask = 0b1 } } } } }, + .{ .keysym = "2", .modifiers = .{ .mod4 = true, .ctrl = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .toggle_window_tag = .{ .mask = 0b10 } } } } }, + .{ .keysym = "3", .modifiers = .{ .mod4 = true, .ctrl = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .toggle_window_tag = .{ .mask = 0b100 } } } } }, + .{ .keysym = "4", .modifiers = .{ .mod4 = true, .ctrl = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .toggle_window_tag = .{ .mask = 0b1000 } } } } }, + .{ .keysym = "5", .modifiers = .{ .mod4 = true, .ctrl = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .toggle_window_tag = .{ .mask = 0b10000 } } } } }, + .{ .keysym = "6", .modifiers = .{ .mod4 = true, .ctrl = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .toggle_window_tag = .{ .mask = 0b100000 } } } } }, + .{ .keysym = "7", .modifiers = .{ .mod4 = true, .ctrl = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .toggle_window_tag = .{ .mask = 0b1000000 } } } } }, + .{ .keysym = "8", .modifiers = .{ .mod4 = true, .ctrl = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .toggle_window_tag = .{ .mask = 0b10000000 } } } } }, + .{ .keysym = "9", .modifiers = .{ .mod4 = true, .ctrl = true, .shift = true }, .event = .{ .click = .{ .pressed = .{ .toggle_window_tag = .{ .mask = 0b100000000 } } } } }, + + .{ + .keysym = "l", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .modify_mfact = .{ .change = .{ .step = 0.01 } }, + }, + }, + }, + }, + .{ + .keysym = "h", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .modify_mfact = .{ .change = .{ .step = -0.01 } }, + }, + }, + }, + }, + .{ + .keysym = "j", + .modifiers = .{ .mod4 = true, .mod1 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .modify_master_location = .{ .location = .bottom }, + }, + }, + }, + }, + .{ + .keysym = "k", + .modifiers = .{ .mod4 = true, .mod1 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .modify_master_location = .{ .location = .top }, + }, + }, + }, + }, + .{ + .keysym = "l", + .modifiers = .{ .mod4 = true, .mod1 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .modify_master_location = .{ .location = .right }, + }, + }, + }, + }, + .{ + .keysym = "h", + .modifiers = .{ .mod4 = true, .mod1 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .modify_master_location = .{ .location = .left }, + }, + }, + }, + }, + .{ + .keysym = "equal", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .modify_nmaster = .{ .change = .increase }, + }, + }, + }, + }, + .{ + .keysym = "minus", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .modify_nmaster = .{ .change = .decrease }, + }, + }, + }, + }, + .{ + .keysym = "equal", + .modifiers = .{ .mod4 = true, .mod1 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .modify_gap = .{ .step = 1 }, + }, + }, + }, + }, + .{ + .keysym = "minus", + .modifiers = .{ .mod4 = true, .mod1 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .modify_gap = .{ .step = -1 }, + }, + }, + }, + }, + .{ + .keysym = "a", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .toggle_auto_swallow, + }, + }, + }, + .{ + .keysym = "g", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .toggle_grid_direction, + }, + }, + }, + + .{ + .keysym = "p", + .modifiers = .{ .mod4 = true }, + .event = .{ + .click = .{ + .pressed = .{ + .spawn = .{ .argv = .{ "rofi", "-show", "run", "-theme", "Arc-Dark" } }, + }, + }, + }, + }, + .{ + .keysym = "Return", + .modifiers = .{ .mod4 = true, .shift = true }, + .event = .{ + .click = .{ + .pressed = .{ + .spawn = .{ .argv = .{ "kitty", "--single-instance", "--instance-group", "default" } }, + }, + }, + }, + }, + }, + + // list of pointer bindings + // full scheme: + // mode: same as key binding + // button: pointer button + // .left + // .right + // .middle + // modifiers: same as key binding + // event: pointer binding trigger event + // .event = .{ + // .pressed = null or action, default is null + // .released = null or action, default is null + // } + // the corrosponding action will only trigger once when pointer button pressed or released + // the pressed action and released action could define at the same time + .pointer = .{ + .{ + .mode = "default", + .button = .left, + .modifiers = .{ .mod4 = true }, + .event = .{ .pressed = .pointer_move }, + }, + .{ + .mode = "default", + .button = .right, + .modifiers = .{ .mod4 = true }, + .event = .{ .pressed = .pointer_resize }, + }, + }, + // other unmentioned actions: + // group: run multiple actions in sequence + // .event = .{ + // .click = .{ + // .pressed = .{ + // .group = .{ + // .actions = .{ + // action1, + // action2, + // ... + // }, + // }, + // }, + // }, + // } + }, + + // rule part + // + // a rule pattern has fields below: + // str: pattern string, required + // regex: bool, if enable regex + // match_null: bool, if match null + // + // only the first rule matched will be applied + + // window rules + // full scheme: + // app_id: rule pattern + // title: rule pattern + // + // tag: window tag + // output: output name pattern, same as rule pattern + // floating: bool, if floating + // dimension: .{ .width = i32, .height = i32 }, initial dimension + // decoration: .csd or .ssd, window decoration + // is_terminal: bool, if set true, means the window could be swallowed + // disable_swallow: bool, if set true, the window could not swallow any other windows + // scroller_mfact: f32, initial mfact of the window for scroller layout + // attach_mode: like `default_attach_mode`, change attach_mode for window matched + .window_rules = .{ + .{ .app_id = .{ .str = "", .match_null = true }, .floating = true }, + .{ .app_id = .{ .str = "zenity" }, .floating = true }, + .{ .app_id = .{ .str = "DesktopEditors" }, .floating = true }, + .{ .app_id = .{ .str = "xdg-desktop-portal-gtk" }, .floating = true }, + .{ .app_id = .{ .str = "chromium" }, .tag = 0b10, .scroller_mfact = 0.9 }, + .{ .app_id = .{ .str = "foot" }, .is_terminal = true, .scroller_mfact = 0.8 }, + .{ .app_id = .{ .str = "kitty" }, .is_terminal = true, .scroller_mfact = 0.8 }, + }, + + // output rules + // full scheme: + // name: rule pattern + // + // presentation_mode: presentation mode, .vsync or .async + // layout: same as `layout` before but you only need to specify the values you want to change + // default_layout: same as `default_layout` before + .output_rules = .{ + // + }, + + // NOTE: configuration below is used for kwim + // without `@if(kwim)` would cause compile error during compile kwm + // @if(kwim) + // input device rules + // full scheme: + // name: rule pattern + // + // repeat_info: .{ .rate = i32, .delay = i32 } + // scroll_factor: f64 + .input_device_rules = .{ + .{ .repeat_info = .{ .rate = 50, .delay = 300 } }, + }, + + // libinput device rules + // full scheme: + // name: rule pattern + // + // send_events_modes: + // .enabled + // .disabled + // .disabled_on_external_mouse + // tap: .enabled or .disabled + // drag: .enabled or .disabled + // drag_lock: .enabled or .disabled + // tap_button_map: .lrm or .lmr + // three_finger_drag: + // .disabled + // .enabled_3fg + // .enabled_4fg + // calibration_matrix: [6]f32 + // accel_profile: + // .none + // .flat + // .adaptive + // .custom + // accel_speed: f32 + // natural_scroll: .enabled or .disabled + // left_handed: .enabled or .disabled + // click_method: + // .none + // .button_areas + // .clickfinger + // clickfinger_button_map: .lrm or .lmr + // middle_button_emulation: .enabled or .disabled + // scroll_method: + // .no_scroll + // .two_finger + // .edge + // .on_button_down + // scroll_button: + // .left + // .right + // .middle + // scroll_button_lock: .enabled or .disabled + // disable_while_typing: .enabled or .disabled + // disable_while_trackpointing: .enabled or .disabled + // rotation_angle: u32 + .libinput_device_rules = .{ + .{ .name = .{ .str = ".*[tT]ouchpad", .regex = true }, .tap = .enabled, .drag = .enabled, .natural_scroll = .enabled }, + .{ .tap = .enabled, .drag = .enabled } + }, + + // xkb_keyboard rules + // full scheme: + // name: rule pattern + // + // numlock: .enabled or .disabled + // capslock: .enabled or .disabled + // layout: + // layout index: .{ .index = u32 } + // or + // layout name: .{ .name = "layout name" } + // keymap: + // .{ .file = .{ .path = "keymap file path", .format = .text_v1 or .text_v2 } } + // or + // .{ + // .options = .{ + // .rules = ?[]const u8, + // .model = ?[]const u8, + // .layout = ?[]const u8, + // .variant = ?[]const u8, + // .options = ?[]const u8, + // } + // } + .xkb_keyboard_rules = .{ + // + }, + // @endif +} diff --git a/lupan-clock/Makefile b/lupan-clock/Makefile index b5494eb..e397f40 100644 --- a/lupan-clock/Makefile +++ b/lupan-clock/Makefile @@ -3,6 +3,9 @@ PREFIX = /usr/local lupan-clock: lupan-clock.c ${CC} -o $@ $< -lX11 -Wall +stdout-clock: stdout-clock.c + ${CC} -o $@ $< -Wall + install: mkdir -p ${DESTDIR}${PREFIX}/bin cp -f lupan-clock ${DESTDIR}${PREFIX}/bin diff --git a/lupan-clock/stdout-clock.c b/lupan-clock/stdout-clock.c new file mode 100644 index 0000000..dd34ae4 --- /dev/null +++ b/lupan-clock/stdout-clock.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include + +void show(struct tm *tm) +{ + char s[6]; + strftime(s, sizeof(s), "%H:%M", tm); + printf("%s\n", s); + fflush(stdout); +} + +int main() { + int h, m, init = 60; + time_t t; + struct tm *tm; + + while (1) { + t = time(NULL); + tm = localtime(&t); + if (tm->tm_hour != h || tm->tm_min != m || init > 0) { + show(tm); + h = tm->tm_hour; + m = tm->tm_min; + init = (init > 0) ? init - 1 : 0; + } + sleep(1); + } + return 1; +} diff --git a/river/.config/river/bar b/river/.config/river/bar deleted file mode 100755 index 247b53a..0000000 --- a/river/.config/river/bar +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env sh - -FIFO="$XDG_RUNTIME_DIR/sandbar" - -run() { - echo run - [ -e "$FIFO" ] && rm -f "$FIFO" - mkfifo "$FIFO" - - "$HOME/.config/river/status" & - - while cat "$FIFO"; do :; done | sandbar \ - -font "FiraCode Nerd Font Ret:size=10" \ - -active-fg-color "#000000" \ - -active-bg-color "#e8c47d" \ - -inactive-fg-color "#e8c47d" \ - -inactive-bg-color "#000000" \ - -urgent-fg-color "#000000" \ - -urgent-bg-color "#cc241d" \ - -title-fg-color "#000000" \ - -title-bg-color "#e8c47d" -} - -while true; do - run - CODE=$? - if [ $CODE -ne 139 && $CODE -ne 134 ]; then - echo exit because $CODE - exit - fi - echo sleep and continue - sleep 1 -done diff --git a/river/.config/river/init b/river/.config/river/init deleted file mode 100755 index 8943c24..0000000 --- a/river/.config/river/init +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -LOCK_COMMAND='swaylock -f -c 1f7693' -RANDR_COMMAND='${HOME}/.config/river/randr --on' -RANDR_OFF_COMMAND='${HOME}/.config/river/randr --off' - -riverctl spawn "${RANDR_COMMAND}" - -"${HOME}/.config/river/keymap" - -# Set the default layout generator to be rivertile and start it. -# River will send the process group of the init executable SIGTERM on exit. -riverctl default-layout rivertile -rivertile -view-padding 1 -outer-padding 0 & - -riverctl spawn "${HOME}/.config/river/bar" - -riverctl spawn "swayidle -w timeout 300 '${LOCK_COMMAND}' \ - timeout 330 '${RANDR_OFF_COMMAND}' resume '${RANDR_COMMAND}' \ - before-sleep '${LOCK_COMMAND}' after-resume '${RANDR_COMMAND}'" diff --git a/river/.config/river/keymap b/river/.config/river/keymap deleted file mode 100755 index 047feb7..0000000 --- a/river/.config/river/keymap +++ /dev/null @@ -1,164 +0,0 @@ -#!/bin/sh - -LOCK_COMMAND='swaylock -f -c 1f7693' - -# Note: the "Super" modifier is also known as Logo, GUI, Windows, Mod4, etc. - -# Super+Shift+Return to start an instance of foot (https://codeberg.org/dnkl/foot) -riverctl map normal Super+Shift Return spawn alacritty -riverctl map normal Super+Alt Return spawn alacritty - -riverctl map normal Super P spawn "wofi -S run" - -# Super+Q to close the focused view -riverctl map normal Super Q close - -# Super+Shift+E to exit river -riverctl map normal Super+Shift E exit - -# Super+J and Super+K to focus the next/previous view in the layout stack -riverctl map normal Super J focus-view next -riverctl map normal Super K focus-view previous - -# Super+Shift+J and Super+Shift+K to swap the focused view with the next/previous -# view in the layout stack -riverctl map normal Super+Shift J swap next -riverctl map normal Super+Shift K swap previous - -# Super+Period and Super+Comma to focus the next/previous output -riverctl map normal Super Period focus-output next -riverctl map normal Super Comma focus-output previous - -# Super+Shift+{Period,Comma} to send the focused view to the next/previous output -riverctl map normal Super+Shift Period send-to-output next -riverctl map normal Super+Shift Comma send-to-output previous - -# Super+Return to bump the focused view to the top of the layout stack -riverctl map normal Super Return zoom - -# Super+H and Super+L to decrease/increase the main ratio of rivertile(1) -riverctl map normal Super H send-layout-cmd rivertile "main-ratio -0.05" -riverctl map normal Super L send-layout-cmd rivertile "main-ratio +0.05" - -# Super+Shift+H and Super+Shift+L to increment/decrement the main count of rivertile(1) -riverctl map normal Super+Shift H send-layout-cmd rivertile "main-count +1" -riverctl map normal Super+Shift L send-layout-cmd rivertile "main-count -1" - -# Super+Alt+{H,J,K,L} to move views -riverctl map normal Super+Alt H move left 100 -riverctl map normal Super+Alt J move down 100 -riverctl map normal Super+Alt K move up 100 -riverctl map normal Super+Alt L move right 100 - -# Super+Alt+Control+{H,J,K,L} to snap views to screen edges -riverctl map normal Super+Alt+Control H snap left -riverctl map normal Super+Alt+Control J snap down -riverctl map normal Super+Alt+Control K snap up -riverctl map normal Super+Alt+Control L snap right - -# Super+Alt+Shift+{H,J,K,L} to resize views -riverctl map normal Super+Alt+Shift H resize horizontal -100 -riverctl map normal Super+Alt+Shift J resize vertical 100 -riverctl map normal Super+Alt+Shift K resize vertical -100 -riverctl map normal Super+Alt+Shift L resize horizontal 100 - -# Super + Left Mouse Button to move views -riverctl map-pointer normal Super BTN_LEFT move-view - -# Super + Right Mouse Button to resize views -riverctl map-pointer normal Super BTN_RIGHT resize-view - -# Super + Middle Mouse Button to toggle float -riverctl map-pointer normal Super BTN_MIDDLE toggle-float - -for i in $(seq 1 9) -do - tags=$((1 << ($i - 1))) - - # Super+[1-9] to focus tag [0-8] - riverctl map normal Super $i set-focused-tags $tags - - # Super+Shift+[1-9] to tag focused view with tag [0-8] - riverctl map normal Super+Shift $i set-view-tags $tags - - # Super+Control+[1-9] to toggle focus of tag [0-8] - riverctl map normal Super+Control $i toggle-focused-tags $tags - - # Super+Shift+Control+[1-9] to toggle tag [0-8] of focused view - riverctl map normal Super+Shift+Control $i toggle-view-tags $tags -done - -# Super+0 to focus all tags -# Super+Shift+0 to tag focused view with all tags -all_tags=$(((1 << 32) - 1)) -riverctl map normal Super 0 set-focused-tags $all_tags -riverctl map normal Super+Shift 0 set-view-tags $all_tags - -# Super+Space to toggle float -riverctl map normal Super Space toggle-float - -# Super+F to toggle fullscreen -riverctl map normal Super F toggle-fullscreen - -# Super+{Up,Right,Down,Left} to change layout orientation -riverctl map normal Super Up send-layout-cmd rivertile "main-location top" -riverctl map normal Super Right send-layout-cmd rivertile "main-location right" -riverctl map normal Super Down send-layout-cmd rivertile "main-location bottom" -riverctl map normal Super Left send-layout-cmd rivertile "main-location left" - -# Declare a passthrough mode. This mode has only a single mapping to return to -# normal mode. This makes it useful for testing a nested wayland compositor -riverctl declare-mode passthrough - -# Super+F11 to enter passthrough mode -riverctl map normal Super F11 enter-mode passthrough - -# Super+F11 to return to normal mode -riverctl map passthrough Super F11 enter-mode normal - -# Various media key mapping examples for both normal and locked mode which do -# not have a modifier -for mode in normal locked -do - # Eject the optical drive (well if you still have one that is) - riverctl map $mode None XF86Eject spawn 'eject -T' - - # Control pulse audio volume with pamixer (https://github.com/cdemoulins/pamixer) - riverctl map $mode None XF86AudioRaiseVolume spawn 'pamixer -i 5' - riverctl map $mode None XF86AudioLowerVolume spawn 'pamixer -d 5' - riverctl map $mode None XF86AudioMute spawn 'pamixer --toggle-mute' - - # Control MPRIS aware media players with playerctl (https://github.com/altdesktop/playerctl) - riverctl map $mode None XF86AudioMedia spawn 'playerctl play-pause' - riverctl map $mode None XF86AudioPlay spawn 'playerctl play-pause' - riverctl map $mode None XF86AudioPrev spawn 'playerctl previous' - riverctl map $mode None XF86AudioNext spawn 'playerctl next' - - # Control screen backlight brightness with brightnessctl (https://github.com/Hummer12007/brightnessctl) - riverctl map $mode None XF86MonBrightnessUp spawn 'brightnessctl set +5%' - riverctl map $mode None XF86MonBrightnessDown spawn 'brightnessctl set 5%-' -done - -riverctl map normal Super A focus-previous-tags -riverctl map normal Super+Control+Shift L spawn "${LOCK_COMMAND}" -riverctl map normal Super+Control+Shift S spawn "systemctl suspend" - -riverctl map normal Super+Alt O spawn "${LOCK_COMMAND}" -riverctl map normal Super+Alt S spawn "systemctl suspend" - -riverctl map normal Super+Alt T spawn "${HOME}/bin/lupan-set-theme toggle" - -# Set background and border color -riverctl background-color 0x002b36 -riverctl border-color-focused 0xac7853 -riverctl border-color-unfocused 0x5387ac - -riverctl keyboard-layout -options ctrl:nocaps pl -# Set keyboard repeat rate -riverctl set-repeat 50 300 - -# Make all views with an app-id that starts with "float" and title "foo" start floating. -riverctl rule-add -app-id 'float*' -title 'foo' float - -# Make all views with app-id "bar" and any title use client-side decorations -riverctl rule-add -app-id "bar" csd diff --git a/river/.config/river/randr b/river/.config/river/randr deleted file mode 100755 index d5c5f50..0000000 --- a/river/.config/river/randr +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env sh - -repeat() { - for x in {0..10}; do - echo "$@" - "$@" - sleep 1 - done -} - -case "$1" in - --on) - repeat wlr-randr --output DP-1 --on --scale 2 --pos 0,0 & - repeat wlr-randr --output DP-2 --on --scale 2 --pos 1920,0 & - sleep 10 - ;; - --off) - wlr-randr --output DP-1 --off - wlr-randr --output DP-2 --off - ;; -esac diff --git a/river/.config/river/status b/river/.config/river/status deleted file mode 100755 index 0cdb3b3..0000000 --- a/river/.config/river/status +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/env sh - -cpu() { - cpu="$(grep -o "^[^ ]*" /proc/loadavg)" -} - -memory() { - memory="$(free -h | sed -n "2s/\([^ ]* *\)\{2\}\([^ ]*\).*/\2/p")" -} - -disk() { - disk="$(df -h | awk 'NR==2{print $4}')" -} - -datetime() { - datetime="$(date "+%F %H:%M")" -} - -bat() { - read -r bat_status "$FIFO" -} - -printf "%s" "$$" > "$XDG_RUNTIME_DIR/status_pid" -FIFO="$XDG_RUNTIME_DIR/sandbar" -[ -e "$FIFO" ] || mkfifo "$FIFO" -sec=0 - -while true; do - sleep 1 & - wait && { - [ $((sec % 15)) -eq 0 ] && memory - [ $((sec % 15)) -eq 0 ] && cpu - [ $((sec % 15)) -eq 0 ] && disk - [ $((sec % 60)) -eq 0 ] && bat - [ $((sec % 5)) -eq 0 ] && vol - [ $((sec % 5)) -eq 0 ] && datetime - - [ $((sec % 5)) -eq 0 ] && display - - sec=$((sec + 1)) - } -done diff --git a/shell/.profile b/shell/.profile index 4e3fd40..de38c74 100644 --- a/shell/.profile +++ b/shell/.profile @@ -38,7 +38,9 @@ export GOBIN=~/.local/bin # start X or Hyprland at login if [ -z "$DISPLAY" -a -z "$WAYLAND_DISPLAY" -a "$(tty)" = /dev/tty1 ]; then - if which /usr/bin/sx > /dev/null; then + if which river kwm stdout-clock > /dev/null; then + exec river -c 'stdout-clock | kwm' + elif which /usr/bin/sx > /dev/null; then exec /usr/bin/sx ~/.xsession elif which /usr/bin/startx > /dev/null; then exec /usr/bin/startx ~/.xsession