Skip to content

furkanksl/clipboard-sync

Repository files navigation

Clipboard Sync

Clipboard Sync is a cross-platform application that allows users to synchronize their clipboard content between multiple devices seamlessly. The application runs in the system tray (menu bar) and supports both Linux and macOS.

Features

  • Clipboard Synchronization: Automatically sync clipboard content between devices.
  • System Tray Integration: Runs in the background and provides a menu bar icon for easy access.
  • Auto-Discovery: Automatically discovers the server on the local network using mDNS.
  • Start on Login: Option to start the application automatically when the user logs in.

Architecture

The application consists of two main components:

  1. Server: Runs on one device and listens for incoming connections from clients. It monitors its own clipboard and broadcasts changes to connected clients.
  2. Client: Runs on other devices and connects to the server. It monitors the clipboard and sends changes to the server.

Logic Flow

  1. Server Mode:

    • The server starts and advertises its presence on the local network.
    • It listens for incoming WebSocket connections from clients.
    • It monitors its clipboard for changes and broadcasts any updates to connected clients.
  2. Client Mode:

    • The client discovers the server on the local network.
    • It connects to the server and starts monitoring its clipboard.
    • Any changes in the clipboard are sent to the server, which then broadcasts them to all connected clients.

Installation

Prerequisites

  • Go: Ensure you have Go installed on your machine. You can download it from golang.org.
  • Linux Dependencies: For Linux, you need to install the following packages:
    sudo apt-get install -y xclip libayatana-appindicator3-dev libgtk-3-dev

Building the Application

For Linux

  1. Clone the Repository:

    git clone [email protected]:furkanksl/clipboard-sync.git
    cd clipboard-sync
  2. Build the Application:

    make clean
    make dist
  3. Install the .deb Package:

    sudo dpkg -i dist/clipboard-sync_*.deb
    sudo apt-get install -f  # To fix any dependency issues
  4. Run the Server:

    clipboard-sync -server -port 8080
  5. Run the Client (in another terminal):

    clipboard-sync

For macOS

  1. Clone the Repository:

    git clone [email protected]:furkanksl/clipboard-sync.git
    cd clipboard-sync
  2. Build the Application:

    go build -o bin/clipboard-sync cmd/desktop/main.go
  3. Create the macOS App Bundle:

    chmod +x build_macos.sh
    ./build_macos.sh
  4. Move the App to Applications:

    mv ClipboardSync.app /Applications/
  5. Run the Application:

    open /Applications/ClipboardSync.app

Running the Application

  • Server: Start the server on one device using the command:

    clipboard-sync -server -port 8080
  • Client: Start the client on other devices. The client will automatically discover the server on the local network.

Logging

The application logs its activity to a file located at ~/.clipboard-sync/clipboard-sync.log. You can view the logs using:

tail -f ~/.clipboard-sync/clipboard-sync.log

Auto-Start on Login

  • For Linux, the application can be set to start on login by creating an autostart entry in ~/.config/autostart/clipboard-sync.desktop.
  • For macOS, you can add the application to your login items in System Preferences.

Troubleshooting

  • If the application does not appear in the menu bar, ensure that the necessary dependencies are installed and that the application is running in the background.
  • Check the logs for any errors related to clipboard access or network issues.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

About

Share your clipboard between your mac and linux

Resources

Stars

Watchers

Forks