LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-25-2018, 06:44 AM   #1
Roihan
LQ Newbie
 
Registered: Jan 2018
Location: Surakarta, Central Java, Indonesia
Distribution: MX-Linux, Debian, Arch Linux
Posts: 12

Rep: Reputation: Disabled
Using cupsenable to resume the default printer


I know that we can use this command to resume a printer from terminal :
Code:
cupsenable printer_name
I need to create a launcher with that command as an easy way to resume my default printer. There are 3 printers in my room and I often switch my default printer from one to another.
Is there a way to resume the default printer without manually typing it's name?
So I don't need to edit the command every time I switch my default printer or create a launcher for each of those printers.

Thanks.
 
Old 01-25-2018, 06:53 AM   #2
Mill J
Senior Member
 
Registered: Feb 2017
Location: @127.0.0.1
Distribution: Mint, Void, MX, Haiku, PMOS, Plasma Mobile, and many others
Posts: 1,258
Blog Entries: 2

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Write a script for each printer than give the script shorter names. You could even link them to your bin.
 
Old 01-25-2018, 07:32 AM   #3
Roihan
LQ Newbie
 
Registered: Jan 2018
Location: Surakarta, Central Java, Indonesia
Distribution: MX-Linux, Debian, Arch Linux
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Mill J View Post
Write a script for each printer than give the script shorter names. You could even link them to your bin.
Well, that could work for me.
But I'll still need to copy this launcher to all computers in my workplace (about 50 computers 30 printers in total). It will take much time to edit the command to each of them.
Is there a way to get the default printer name? I've tried lpq and the output is
Code:
Epson_L120 is ready
no entries
Maybe there is something we can do with grep to get only the first block of that line (since space is not allowed in printer name). So I can copy the Epson_L120 and do something to run cupsenable using that copied text.

Last edited by Roihan; 01-25-2018 at 07:33 AM.
 
Old 01-25-2018, 08:03 AM   #4
Mill J
Senior Member
 
Registered: Feb 2017
Location: @127.0.0.1
Distribution: Mint, Void, MX, Haiku, PMOS, Plasma Mobile, and many others
Posts: 1,258
Blog Entries: 2

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
I've actually programmed my own front-end to lpadmin, lpinfo, etc(usb only so far), I found the cups help page a great resource https://www.cups.org/documentation.html
lpstat -d should show the current default.
 
Old 01-25-2018, 08:09 PM   #5
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
By a launcher do you mean an icon in the gui menu? Those are .desktop files.
Code:
$ nano printer_enable.desktop
will creat and open the desktop file. Then type this in the file
Code:
[Desktop Entry]
Name=Printer Enable
Comment=Enable Printer
GenericName=Printer
Exec=/usr/sbin/cupsenable printer_name &
Terminal=false
Type=Application
StartupNotify=true
Put the file in /home/user/Desktop/ and it should appear on the desktop. But why not just leave the printer as it is in the active state?

Last edited by AwesomeMachine; 01-25-2018 at 08:11 PM.
 
Old 01-26-2018, 11:09 PM   #6
Roihan
LQ Newbie
 
Registered: Jan 2018
Location: Surakarta, Central Java, Indonesia
Distribution: MX-Linux, Debian, Arch Linux
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Mill J View Post
I've actually programmed my own front-end to lpadmin, lpinfo, etc(usb only so far), I found the cups help page a great resource https://www.cups.org/documentation.html
lpstat -d should show the current default.
I use system-config-printer for that.
But resuming printer using system-config-printer or cups via web browser is quite complicated for most users. I need to create a one-click launcher to resume my printer. I've made many launchers to run specific commands that often be used by users such as setting display resolution using xrandr. Now I need to create this one.
I've read the cups documentation too but there is no command to resume a default printer. We can only resume a printer using cupsenable by specifying the printer name.
 
Old 01-26-2018, 11:20 PM   #7
Roihan
LQ Newbie
 
Registered: Jan 2018
Location: Surakarta, Central Java, Indonesia
Distribution: MX-Linux, Debian, Arch Linux
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by AwesomeMachine View Post
By a launcher do you mean an icon in the gui menu? Those are .desktop files.
Code:
$ nano printer_enable.desktop
will creat and open the desktop file. Then type this in the file
Code:
[Desktop Entry]
Name=Printer Enable
Comment=Enable Printer
GenericName=Printer
Exec=/usr/sbin/cupsenable printer_name &
Terminal=false
Type=Application
StartupNotify=true
Put the file in /home/user/Desktop/ and it should appear on the desktop. But why not just leave the printer as it is in the active state?
I knew about it. What I need to do is this :
Assume that I need to resume my default printer without knowing the printer name. It will be like cupsenable default-printer, but there is no such command available.
 
Old 01-27-2018, 12:56 AM   #8
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
Why not parse the output of 'lpstat -d'?
Code:
cupsenableprinter $(lpstat -d | cut -d: -f2)
 
1 members found this post helpful.
Old 01-27-2018, 05:18 AM   #9
Roihan
LQ Newbie
 
Registered: Jan 2018
Location: Surakarta, Central Java, Indonesia
Distribution: MX-Linux, Debian, Arch Linux
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by allend View Post
Why not parse the output of 'lpstat -d'?
Code:
cupsenableprinter $(lpstat -d | cut -d: -f2)
That's it!
I tought about lpq and grep.
I didn't know that there is a cut command.
Thanks for the help guys!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Slackware 14.0 Firefox printer duplex no longer using printer system default girvinh Slackware 1 06-14-2014 04:01 PM
resume: could not stat the resume device file Zaskar Debian 17 03-29-2012 10:10 PM
[SOLVED] Why do nVida drivers hose suspend/resume or hibernate/resume? taylorkh Linux - Hardware 3 06-23-2011 01:09 PM
resume: cannot stat resume device file sixerjman Linux - Kernel 0 05-27-2007 03:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration