Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
TIP ! Clipboard for Sway / Waybar - comfortable way
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
CooSee
Veteran
Veteran


Joined: 20 Nov 2004
Posts: 1444
Location: Earth

PostPosted: Thu Jul 21, 2022 8:43 pm    Post subject: TIP ! Clipboard for Sway / Waybar - comfortable way Reply with quote

hello,

you need to emerge dev-lang/go, gui-apps/wl-clipboard and gui-apps/rofi-wayland <<< from guru overlay.

additional info howto handle multiple repositories look here: https://forums.gentoo.org/viewtopic-p-8659032-highlight-.html#8659032

and download cliphist source code from (you need dev-vcs/git) :

git clone https://github.com/sentriz/cliphist.git

installing cliphist is easy >>> go install go.senan.xyz/cliphist

copy just generated cliphist (bin) from ~/go/bin to /usr/bin

or you can try with downloadable binary at (never tried myself):

download from https://github.com/sentriz/cliphist/releases/tag/v0.5.0

or via go install go.senan.xyz/cliphist@latest

---

entries for sway config:

! thanks to Manjaro - best implementation, imho !

# if-exists autostarts
Code:
    exec {

    '[ -x "$(command -v wl-paste)" ] && [ -x "$(command -v cliphist)" ] && wl-paste --watch cliphist store'
    '[ -x "$(command -v wl-paste)" ] && [ -x "$(command -v cliphist)" ] && wl-paste --watch pkill -RTMIN+9 waybar'
    }


# Launch // Clipboard ##
Code:
bindsym $mod+y exec $clipboard

change it to whatever available key you want !

# clipboard history
Code:
    set $clipboard cliphist list | rofi -dmenu -m -1 -font "Ubuntu Mono Nerd Font 9" -p "Select item to copy" -lines 10 -width 35 | cliphist decode | wl-copy
    set $clipboard-del cliphist list | rofi -dmenu -m -1 primary -font "Ubuntu Mono Nerd Font 9" -p "Select item to delete" -lines 10 -width 35 | cliphist delete


---

entries for waybar config:
Code:
"custom/clipboard",

to enable custom entry

and (icon hex is f0ea):
Code:
"custom/clipboard": {
    "format": "",
    "interval": "once",
    "return-type": "json",
    "on-click": "swaymsg -q exec '$clipboard'; pkill -RTMIN+9 waybar",
    "on-click-right": "swaymsg -q exec '$clipboard-del'; pkill -RTMIN+9 waybar",
    "on-click-middle": "rm -f ~/.cache/cliphist/db; pkill -RTMIN+9 waybar",
    "exec": "printf '{\"tooltip\":\"%s\"}' $(cliphist list | wc -l)' item(s) in the clipboard\r(Mid click to clear)'",
    "exec-if": "[ -x \"$(command -v cliphist)\" ] && [ $(cliphist list | wc -l) -gt 0 ]",
    "signal": 9
    },


---

this is my rofi (user) config in .config/rofi/config.rasi:
Code:
configuration {

  timeout {
      action: "kb-cancel";
      delay:  0;
  }
  filebrowser {
      directories-first: true;
      sorting-method:    "name";
  }
}

@import "paper-float"

that's it :!:

now you get an icon on waybar - middle click will delete the history - it'll look like this:

https://0x0.st/s/lN5FTfA_FzePBGW7zzzKyw/H4Vs.png

sway/waybar sometimes doesn't work correctly after reloading config via mod+shift+c - better restart your computer and you're good to go :!:

EDIT:

this is my first ebuild :!: - works for me, i hope it'll work for you too, no guarantee :D

Code:
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit go-module git-r3

EGIT_REPO_URI="https://github.com/sentriz/cliphist"

DESCRIPTION="ClipBoard History Manager for Wayland"
HOMEPAGE="https://github.com/sentriz/cliphist"

LICENSE="GPL3"
SLOT="0"
KEYWORDS="~amd64"

BDEPEND=">=dev-lang/go-1.19"

RDEPEND="gui-apps/wl-clipboard x11-misc/xdg-utils"

DEPEND="${RDEPEND}"

RESTRICT+="strip"

src_unpack() {
   git-r3_src_unpack
   go-module_live_vendor
}

src_compile() {
   go build || die
}

src_install() {
dobin cliphist
}


save it as cliphist-9999.ebuild

placed the ebuild in gui-apps/cliphist/cliphist-9999.ebuild in my local overlay >>> https://wiki.gentoo.org/wiki/Creating_an_ebuild_repository

greetings (...programs) 8)
_________________
" Die Realität ist eine Illusion, die durch Mangel an ehrlicher Kommunikation entsteht "
---
" Der Mensch ist von Natur aus neugierig, was am Ende übrig bleibt ist die Gier "


Last edited by CooSee on Thu Feb 22, 2024 2:28 am; edited 16 times in total
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30953
Location: here

PostPosted: Fri Jul 22, 2022 4:32 am    Post subject: Reply with quote

Moved from Desktop Environments to Documentation, Tips & Tricks.
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum