diff --git a/base.nim b/base.nim index b0512a4..07a3163 100644 --- a/base.nim +++ b/base.nim @@ -57,12 +57,15 @@ const secondary* = red const alert* = "#bd2c40" const MAX_LINES = 20 const font = "Hermit-12" +const WL_DMENU = "dmenu" +const WL_ROFI = "wofi --dmenu" var loop* = false var stoploop* = true var tool* = "dmenu" var passmenu* = false var command_wrapper* = false var run_command* = "" +var wayland* = false proc newInfo*(str: string = "Info"): Info = var title = str @@ -81,20 +84,29 @@ proc newInfo*(str: string = "Info"): Info = ) proc newMenuConfig(cmd: string = "dmenu"): Menu = + var run = cmd + if wayland and cmd == "dmenu": + run = WL_DMENU var menu = Menu() - menu.command = cmd + menu.command = run menu.prompt = "-p" menu.i_case = "-i" menu.lines_shown = "-l" return menu proc newRofiConfig(cmd: string = "rofi -dmenu"): Menu = - var menu = newMenuConfig(cmd) + var run = cmd + if wayland and cmd == "rofi -dmenu": + run = WL_ROFI + var menu = newMenuConfig(run) menu.extra_cmd = "-markup-rows -kb-row-select \"Tab\" -kb-row-tab \"\"" return menu proc newDmenuConfig(cmd: string = "dmenu"): Menu = - var menu = newMenuConfig(cmd) + var run = cmd + if wayland and cmd == "dmenu": + run = WL_DMENU + var menu = newMenuConfig(run) menu.bottom = "-b" menu.grabkb = "-f" menu.monitor = "-m" @@ -125,6 +137,11 @@ proc switchTwmMode*(mode: string = "default") = # I intend to add support for more twm as time goes on (I switch around a lot) # Switch out of an i3 bindsym mode if set discard execCmd("i3-msg mode \"" & mode & "\"") + discard execCmd("sway mode \"" & mode & "\"") + +proc checkWayland() = + if getEnv("XDG_SESSION_TYPE") == "wayland": + wayland = true proc parseInput*(): i3BarInput = let input = readLineFromStdin("") @@ -223,6 +240,8 @@ proc outputData*(data: Info, args: varargs[string]): string {.discardable.} = # Switch bindsym mode back to default as it could be being used. switchTwmMode() +checkWayland() + let args* = getArguments() for idx, arg in args: case arg: diff --git a/brightness.nim b/brightness.nim index 1cb3ffc..0e6651c 100644 --- a/brightness.nim +++ b/brightness.nim @@ -99,13 +99,13 @@ proc main() = if isMainModule: block start: + if wayland: + CMD = BACKLIGHT_CMD_WL + UP = UP_WL + DOWN = DOWN_WL + SET = SET_WL for arg in args: case arg: - of "-w": - CMD = BACKLIGHT_CMD_WL - UP = UP_WL - DOWN = DOWN_WL - SET = SET_WL of "up": brightnessUp() break start diff --git a/screenshot.nim b/screenshot.nim index d5b2422..f34ffc7 100755 --- a/screenshot.nim +++ b/screenshot.nim @@ -2,7 +2,6 @@ import base import std/[times,os,osproc,strutils,sequtils] var screenshot_type = "" -var wayland = false const TYPES = @["region", "fullscreen", "window"] const DATE_FORMAT = "yyyyMMdd-hhmmss" const FILENAME = "Screenshot-%d.png" @@ -89,11 +88,11 @@ proc takeScreenshot() = return if isMainModule: + if wayland: + RUN_CMD = SCREENSHOT_CMD_WL + REGION_CMD = REGION_FLAG_WL + CLIP_CMD = CLIPBOARD_CMD_WL for arg in args: - if arg == "-w": - RUN_CMD = SCREENSHOT_CMD_WL - REGION_CMD = REGION_FLAG_WL - CLIP_CMD = CLIPBOARD_CMD_WL if arg in TYPES: screenshot_type = arg break